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 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() {
41 return FcpUtils.safeParseLong(getField("DataLength"));
45 * Returns whether the request is on the global queue.
47 * @return <code>true</code> if the request is on the global queue,
48 * <code>false</code> otherwise
50 public boolean isGlobal() {
51 return Boolean.valueOf(getField("Global"));
55 * Returns the identifier of the request.
57 * @return The identifier of the request
59 public String getIdentifier() {
60 return getField("Identifier");
64 * Returns the maximum number of retries for failed blocks. When
65 * <code>-1</code> is returned each block is tried forever.
67 * @return The maximum number of retries for failed blocks, or
68 * <code>-1</code> for unlimited retries, or <code>-2</code> if
69 * the number of retries could not be parsed
71 public int getMaxRetries() {
72 return FcpUtils.safeParseInt(getField("MaxRetries"));
76 * Returns the content type of the data.
78 * @return The content type
80 public String getMetadataContentType() {
81 return getField("Metadata.ContentType");
85 * Returns the persistence of the request.
87 * @return The persistence of the request
89 public Persistence getPersistence() {
90 return Persistence.valueOf(getField("Persistence"));
94 * Returns the priority of the request.
96 * @return The priority of the request, or {@link Priority#unknown} if the
97 * priority could not be parsed
99 public Priority getPriority() {
101 return Priority.values()[Integer.valueOf(getField("PriorityClass"))];
102 } catch (NumberFormatException nfe1) {
103 return Priority.unknown;
108 * Returns whether this request has started.
110 * @return <code>true</code> if the request has started,
111 * <code>false</code> otherwise
113 public boolean isStarted() {
114 return Boolean.valueOf(getField("Started"));
118 * Returns the target filename of the request.
120 * @return The target filename of the request
122 public String getTargetFilename() {
123 return getField("TargetFilename");
127 * Returns the upload source of the request.
129 * @return The upload source of the request
131 public UploadFrom getUploadFrom() {
132 return UploadFrom.valueOf(getField("UploadFrom"));
136 * Returns the target URI of the request.
138 * @return The target URI of the request
140 public String getURI() {
141 return getField("URI");
145 * Returns the verbosity of the request.
147 * @return The verbosity of the request
149 public Verbosity getVerbosity() {
150 return Verbosity.valueOf(getField("Verbosity"));