001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.stream;
034:
035: import com.flexive.shared.FxContext;
036:
037: import java.io.Serializable;
038:
039: /**
040: * Payload for binary uploads.
041: *
042: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
043: */
044: public final class BinaryUploadPayload implements Serializable {
045: private static final long serialVersionUID = -54895840376576935L;
046:
047: private String handle = null; //handle and optional error message
048: private long timeToLive = 0;
049: private long expectedLength = 0;
050: private boolean serverError = false;
051: private int division = -1;
052: private boolean finished = false;
053:
054: /**
055: * Constructor for the 'calling user'
056: *
057: * @param expectedLength expected length of the stream/binary
058: * @param timeToLive desired TTL
059: */
060: public BinaryUploadPayload(long expectedLength, long timeToLive) {
061: this .expectedLength = expectedLength;
062: this .timeToLive = timeToLive;
063: this .division = FxContext.get().getDivisionId();
064: }
065:
066: /**
067: * Server side constructor
068: *
069: * @param handle db handle assigned to the binary
070: */
071: public BinaryUploadPayload(String handle) {
072: this .handle = handle;
073: }
074:
075: /**
076: * Server side constructor incase of errors
077: *
078: * @param serverError error occured
079: * @param msg error message
080: */
081: public BinaryUploadPayload(boolean serverError, String msg) {
082: this .serverError = serverError;
083: this .handle = msg;
084: }
085:
086: public BinaryUploadPayload() {
087: this .finished = true;
088: }
089:
090: public long getExpectedLength() {
091: return expectedLength;
092: }
093:
094: public String getHandle() {
095: return handle;
096: }
097:
098: public boolean isServerError() {
099: return serverError;
100: }
101:
102: public String getErrorMessage() {
103: return handle;
104: }
105:
106: public long getTimeToLive() {
107: return timeToLive;
108: }
109:
110: public int getDivision() {
111: return division;
112: }
113:
114: public boolean isFinished() {
115: return finished;
116: }
117: }
|