2 * jSite2 - PersistentPut.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.fcp;
23 * A “PersistentPut” message notifies a client about a persistent
24 * {@link ClientPut} request.
26 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
29 public class PersistentPut extends BaseMessage {
32 * Creates a new “PersistentPut” message that wraps the received message.
34 * @param receivedMessage
35 * The received message
37 PersistentPut(FcpMessage receivedMessage) {
38 super(receivedMessage);
42 * Returns the client token of the request.
44 * @return The client token of the request
46 public String getClientToken() {
47 return getField("ClientToken");
51 * Returns the data length of the request.
53 * @return The data length of the request, or <code>-1</code> if the
54 * length could not be parsed
56 public long getDataLength() {
57 return FcpUtils.safeParseLong(getField("DataLength"));
61 * Returns whether the request is on the global queue.
63 * @return <code>true</code> if the request is on the global queue,
64 * <code>false</code> otherwise
66 public boolean isGlobal() {
67 return Boolean.valueOf(getField("Global"));
71 * Returns the identifier of the request.
73 * @return The identifier of the request
75 public String getIdentifier() {
76 return getField("Identifier");
80 * Returns the maximum number of retries for failed blocks. When
81 * <code>-1</code> is returned each block is tried forever.
83 * @return The maximum number of retries for failed blocks, or
84 * <code>-1</code> for unlimited retries, or <code>-2</code> if
85 * the number of retries could not be parsed
87 public int getMaxRetries() {
88 return FcpUtils.safeParseInt(getField("MaxRetries"));
92 * Returns the content type of the data.
94 * @return The content type
96 public String getMetadataContentType() {
97 return getField("Metadata.ContentType");
101 * Returns the persistence of the request.
103 * @return The persistence of the request
105 public Persistence getPersistence() {
106 return Persistence.valueOf(getField("Persistence"));
110 * Returns the priority of the request.
112 * @return The priority of the request, or {@link Priority#unknown} if the
113 * priority could not be parsed
115 public Priority getPriority() {
117 return Priority.values()[Integer.valueOf(getField("PriorityClass"))];
118 } catch (NumberFormatException nfe1) {
119 return Priority.unknown;
124 * Returns whether this request has started.
126 * @return <code>true</code> if the request has started,
127 * <code>false</code> otherwise
129 public boolean isStarted() {
130 return Boolean.valueOf(getField("Started"));
134 * Returns the target filename of the request.
136 * @return The target filename of the request
138 public String getTargetFilename() {
139 return getField("TargetFilename");
143 * Returns the upload source of the request.
145 * @return The upload source of the request
147 public UploadFrom getUploadFrom() {
148 return UploadFrom.valueOf(getField("UploadFrom"));
152 * Returns the target URI of the request.
154 * @return The target URI of the request
156 public String getURI() {
157 return getField("URI");
161 * Returns the verbosity of the request.
163 * @return The verbosity of the request
165 public Verbosity getVerbosity() {
166 return Verbosity.valueOf(getField("Verbosity"));