001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.synapse.transport.vfs;
020:
021: import java.text.SimpleDateFormat;
022: import java.text.DateFormat;
023:
024: /**
025: * Holds information about an entry in the VFS transport poll table used by the
026: * VFS Transport Listener
027: */
028: public class PollTableEntry {
029:
030: // status of last scan
031: public static final int SUCCSESSFUL = 0;
032: public static final int WITH_ERRORS = 1;
033: public static final int FAILED = 2;
034: public static final int NONE = 3;
035:
036: // operation after scan
037: public static final int DELETE = 0;
038: public static final int MOVE = 1;
039:
040: /** Axis2 service name */
041: private String serviceName;
042: /** File or Directory to scan */
043: private String fileURI;
044: /** file name pattern for a directory or compressed file entry */
045: private String fileNamePattern;
046: /** Content-Type to use for the message */
047: private String contentType;
048:
049: /** last poll performed at */
050: private long lastPollTime;
051: /** duration in ms between successive polls */
052: private long pollInterval;
053: /** next poll time */
054: private long nextPollTime;
055: /** state of the last poll */
056: private int lastPollState;
057: /** action to take after a successful poll */
058: private int actionAfterProcess = DELETE;
059: /** action to take after a poll with errors */
060: private int actionAfterErrors = DELETE;
061: /** action to take after a failed poll */
062: private int actionAfterFailure = DELETE;
063:
064: /** where to move the file after processing */
065: private String moveAfterProcess;
066: /** where to move the file after encountering some errors */
067: private String moveAfterErrors;
068: /** where to move the file after total failure */
069: private String moveAfterFailure;
070: /** moved file will have this formatted timestamp prefix */
071: private DateFormat moveTimestampFormat;
072:
073: private int maxRetryCount;
074: private long reconnectTimeout;
075:
076: public String getServiceName() {
077: return serviceName;
078: }
079:
080: public void setServiceName(String serviceName) {
081: this .serviceName = serviceName;
082: }
083:
084: public String getFileURI() {
085: return fileURI;
086: }
087:
088: public void setFileURI(String fileURI) {
089: if (fileURI.startsWith(VFSConstants.VFS_PREFIX)) {
090: this .fileURI = fileURI.substring(VFSConstants.VFS_PREFIX
091: .length());
092: } else {
093: this .fileURI = fileURI;
094: }
095: }
096:
097: public String getFileNamePattern() {
098: return fileNamePattern;
099: }
100:
101: public void setFileNamePattern(String fileNamePattern) {
102: this .fileNamePattern = fileNamePattern;
103: }
104:
105: public String getContentType() {
106: return contentType;
107: }
108:
109: public void setContentType(String contentType) {
110: this .contentType = contentType;
111: }
112:
113: public long getLastPollTime() {
114: return lastPollTime;
115: }
116:
117: public void setLastPollTime(long lastPollTime) {
118: this .lastPollTime = lastPollTime;
119: }
120:
121: public long getPollInterval() {
122: return pollInterval;
123: }
124:
125: public void setPollInterval(long pollInterval) {
126: this .pollInterval = pollInterval;
127: }
128:
129: public long getNextPollTime() {
130: return nextPollTime;
131: }
132:
133: public void setNextPollTime(long nextPollTime) {
134: this .nextPollTime = nextPollTime;
135: }
136:
137: public int getLastPollState() {
138: return lastPollState;
139: }
140:
141: public void setLastPollState(int lastPollState) {
142: this .lastPollState = lastPollState;
143: }
144:
145: public int getActionAfterProcess() {
146: return actionAfterProcess;
147: }
148:
149: public void setActionAfterProcess(int actionAfterProcess) {
150: this .actionAfterProcess = actionAfterProcess;
151: }
152:
153: public int getActionAfterErrors() {
154: return actionAfterErrors;
155: }
156:
157: public void setActionAfterErrors(int actionAfterErrors) {
158: this .actionAfterErrors = actionAfterErrors;
159: }
160:
161: public int getActionAfterFailure() {
162: return actionAfterFailure;
163: }
164:
165: public void setActionAfterFailure(int actionAfterFailure) {
166: this .actionAfterFailure = actionAfterFailure;
167: }
168:
169: public String getMoveAfterProcess() {
170: return moveAfterProcess;
171: }
172:
173: public void setMoveAfterProcess(String moveAfterProcess) {
174: if (moveAfterProcess == null) {
175: this .moveAfterProcess = null;
176: } else if (moveAfterProcess.startsWith(VFSConstants.VFS_PREFIX)) {
177: // to recover a good directory location if user entered with the vfs: prefix
178: // because transport uris are given like that
179: this .moveAfterProcess = moveAfterProcess
180: .substring(VFSConstants.VFS_PREFIX.length());
181: } else {
182: this .moveAfterProcess = moveAfterProcess;
183: }
184: }
185:
186: public String getMoveAfterErrors() {
187: return moveAfterErrors;
188: }
189:
190: public void setMoveAfterErrors(String moveAfterErrors) {
191: if (moveAfterErrors == null) {
192: this .moveAfterErrors = null;
193: } else if (moveAfterErrors.startsWith(VFSConstants.VFS_PREFIX)) {
194: this .moveAfterErrors = moveAfterErrors
195: .substring(VFSConstants.VFS_PREFIX.length());
196: } else {
197: this .moveAfterErrors = moveAfterErrors;
198: }
199: }
200:
201: public String getMoveAfterFailure() {
202: return moveAfterFailure;
203: }
204:
205: public void setMoveAfterFailure(String moveAfterFailure) {
206: if (moveAfterFailure == null) {
207: this .moveAfterFailure = null;
208: } else if (moveAfterFailure.startsWith(VFSConstants.VFS_PREFIX)) {
209: this .moveAfterFailure = moveAfterFailure
210: .substring(VFSConstants.VFS_PREFIX.length());
211: } else {
212: this .moveAfterFailure = moveAfterFailure;
213: }
214: }
215:
216: public int getMaxRetryCount() {
217: return maxRetryCount;
218: }
219:
220: public void setMaxRetryCount(int maxRetryCount) {
221: this .maxRetryCount = maxRetryCount;
222: }
223:
224: public long getReconnectTimeout() {
225: return reconnectTimeout;
226: }
227:
228: public void setReconnectTimeout(long reconnectTimeout) {
229: this .reconnectTimeout = reconnectTimeout;
230: }
231:
232: public DateFormat getMoveTimestampFormat() {
233: return moveTimestampFormat;
234: }
235:
236: public void setMoveTimestampFormat(DateFormat moveTimestampFormat) {
237: this.moveTimestampFormat = moveTimestampFormat;
238: }
239: }
|