2 * © 2008 INA Service GmbH
4 package net.pterodactylus.util.fcp;
7 * A “PersistentPut” message notifies a client about a persistent
8 * {@link ClientPut} request.
10 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
13 public class PersistentPut extends BaseMessage {
16 * Creates a new “PersistentPut” message that wraps the received message.
18 * @param receivedMessage
19 * The received message
21 public PersistentPut(FcpMessage receivedMessage) {
22 super(receivedMessage);
26 * Returns the client token of the request.
28 * @return The client token of the request
30 public String getClientToken() {
31 return getField("ClientToken");
35 * Returns the data length of the request.
37 * @return The data length of the request, or <code>-1</code> if the
38 * length could not be parsed
40 public long getDataLength() {
42 return Long.valueOf(getField("DataLength"));
43 } catch (NumberFormatException nfe1) {
49 * Returns whether the request is on the global queue.
51 * @return <code>true</code> if the request is on the global queue,
52 * <code>false</code> otherwise
54 public boolean isGlobal() {
55 return Boolean.valueOf(getField("Global"));
59 * Returns the identifier of the request.
61 * @return The identifier of the request
63 public String getIdentifier() {
64 return getField("Identifier");
68 * Returns the maximum number of retries for failed blocks. When
69 * <code>-1</code> is returned each block is tried forever.
71 * @return The maximum number of retries for failed blocks, or
72 * <code>-1</code> for unlimited retries, or <code>-2</code> if
73 * the number of retries could not be parsed
75 public int getMaxRetries() {
77 return Integer.valueOf(getField("MaxRetries"));
78 } catch (NumberFormatException nfe1) {
79 /* we need to return -2 here as -1 is also a valid value. */
85 * Returns the content type of the data.
87 * @return The content type
89 public String getMetadataContentType() {
90 return getField("Metadata.ContentType");
94 * Returns the persistence of the request.
96 * @return The persistence of the request
98 public Persistence getPersistence() {
99 return Persistence.valueOf(getField("Persistence"));
103 * Returns the priority of the request.
105 * @return The priority of the request, or {@link Priority#unknown} if the
106 * priority could not be parsed
108 public Priority getPriority() {
110 return Priority.values()[Integer.valueOf(getField("PriorityClass"))];
111 } catch (NumberFormatException nfe1) {
112 return Priority.unknown;
117 * Returns whether this request has started.
119 * @return <code>true</code> if the request has started,
120 * <code>false</code> otherwise
122 public boolean isStarted() {
123 return Boolean.valueOf(getField("Started"));
127 * Returns the target filename of the request.
129 * @return The target filename of the request
131 public String getTargetFilename() {
132 return getField("TargetFilename");
136 * Returns the upload source of the request.
138 * @return The upload source of the request
140 public UploadFrom getUploadFrom() {
141 return UploadFrom.valueOf(getField("UploadFrom"));
145 * Returns the target URI of the request.
147 * @return The target URI of the request
149 public String getURI() {
150 return getField("URI");
154 * Returns the verbosity of the request.
156 * @return The verbosity of the request
158 public Verbosity getVerbosity() {
159 return Verbosity.valueOf(getField("Verbosity"));