001 package jmaster.jumploader.jsface.api;
002
003 import jmaster.jumploader.model.api.common.IAttributeSet;
004 import jmaster.jumploader.model.api.common.IListSelection;
005 import jmaster.jumploader.model.api.common.ITransferProgress;
006 import jmaster.jumploader.model.api.exception.UploaderException;
007 import jmaster.jumploader.model.api.upload.IImageInfo;
008 import jmaster.jumploader.model.api.upload.IUploadFile;
009
010 /**
011 * IJSUploader
012 *
013 * @author timur
014 */
015
016 public interface IJSUploader {
017 //---------------------------------------------------------------
018 // constants
019 //---------------------------------------------------------------
020 public static final int STATUS_READY = 0;
021 public static final int STATUS_UPLOADING = 1;
022 //---------------------------------------------------------------
023 // business methods
024 //---------------------------------------------------------------
025 /**
026 * destroy
027 */
028 public void destroy();
029 /**
030 * shows whether file addition is enabled
031 */
032 public boolean isFileAdditionEnabled();
033 /**
034 * set file addition is enabled
035 */
036 public void setFileAdditionEnabled( boolean enabled );
037 /**
038 * shows whether file removal is enabled
039 */
040 public boolean isFileRemovalEnabled();
041 /**
042 * set file removal is enabled
043 */
044 public void setFileRemovalEnabled( boolean enabled );
045 /**
046 * upload file count retrieval
047 */
048 public int getFileCount();
049 /**
050 * upload file retrieval
051 */
052 public IUploadFile getFile( String index );
053 /**
054 * all files snapshot retrieval
055 */
056 public IUploadFile[] getAllFiles();
057 /**
058 * upload file retrieval by path
059 * @return null if not found
060 */
061 public IUploadFile getFileByPath( String path );
062 /**
063 * upload file count retrieval by status
064 * @param status see IUploadFile constants
065 */
066 public int getFileCountByStatus( String status );
067 /**
068 * upload files retrieval by status
069 * @return array of IUploadFile or null, if no such files
070 */
071 public IUploadFile[] getFilesByStatus( String status );
072 /**
073 * index of file retrieval
074 */
075 public int indexOfFile( IUploadFile uf );
076 /**
077 * all files length retrieval
078 */
079 public long getFilesLength();
080 /**
081 * add upload file
082 * @return error message or null if ok
083 */
084 public String addFile( String path );
085 /**
086 * add upload file with specifdied status
087 * @return error message or null if ok
088 */
089 public String addFile( String path, String status );
090 /**
091 * add upload file with specifdied status and error message
092 * @return error message or null if ok
093 */
094 public String addFile( String path, String status, String error );
095 /**
096 * remove upload file
097 * @return error message or null if ok
098 */
099 public String removeFile( IUploadFile uploadFile );
100 /**
101 * remove upload file at specified index
102 * @return error message or null if ok
103 */
104 public String removeFileAt( String index );
105 /**
106 * status retrieval
107 */
108 public int getStatus();
109 /**
110 * ready status check
111 */
112 public boolean isReady();
113 /**
114 * uploading status check
115 */
116 public boolean isUploading();
117 /**
118 * start upload
119 * @return error message or null if ok
120 */
121 public String startUpload();
122 /**
123 * stop upload
124 * @return error message or null if ok
125 */
126 public String stopUpload();
127 /**
128 * shows whether startUpload() action is applicable
129 */
130 public boolean canStartUpload();
131 /**
132 * shows whether stopUpload() action is applicable
133 */
134 public boolean canStopUpload();
135 /**
136 * stop uploading specified file
137 * @return error message or null if ok
138 */
139 public String stopFileUpload( IUploadFile file );
140 /**
141 * stop uploading file specified by index
142 * @return error message or null if ok
143 */
144 public String stopFileUploadAt( String index );
145 /**
146 * retry uplod of specified upload file
147 * @return error message or null if ok
148 */
149 public String retryFileUpload( IUploadFile file );
150 /**
151 * retry uplod of upload file specified by index
152 * @return error message or null if ok
153 */
154 public String retryFileUploadAt( String index );
155 /**
156 * transfer progress retrieval, valid if uploading
157 */
158 public ITransferProgress getTransferProgress();
159 /**
160 * attribute set retrieval
161 */
162 public IAttributeSet getAttributeSet();
163 /**
164 * selection retrieval
165 */
166 public IListSelection getSelection();
167 /**
168 * upload enabled set
169 */
170 public void setUploadEnabled( boolean enabled );
171 /**
172 * upload enabled retrieval
173 */
174 public boolean isUploadEnabled();
175 /**
176 * retrieve image info for specified file
177 */
178 public IImageInfo getImageInfo(IUploadFile file) throws UploaderException;
179 /**
180 * invoke method against specified target.
181 * this method specially introduced as workaround for poor implementation
182 * of liveconnect on safari. particular problems are:
183 * - can't pass and retrieve particular types of arguments (i.e. long, arrays, ...)
184 * - null object passed as "null" string
185 * @param target a target to invoke method of
186 * @param methodName a method name
187 * @param args method arguments, if method has no arguments "noargs" string should be passed,
188 * multiple arguments should be separated by semicolon (;),
189 * null argument value should be specified by "null" string
190 * @return invocation result converted to string
191 */
192 public String invoke(Object target, String methodName, String args);
193 /**
194 * updates file name being displayed and sent to server
195 */
196 public void updateFileName(IUploadFile uploadFile, String name);
197 //---------------------------------------------------------------
198 // document download/edit related methods
199 //---------------------------------------------------------------
200 /**
201 * process document - first download to the temporary file, open
202 * editor, then upload back.
203 */
204 public IUploadFile processDocument( String key, String downloadLocation,
205 String uploadLocation, String filename, String options )
206 throws UploaderException;
207 public IUploadFile processDocument( String key, String downloadLocation,
208 String uploadLocation, String filename )
209 throws UploaderException;
210 /**
211 * shows whether has downloading files
212 */
213 public boolean isDownloading();
214 /**
215 * process that document again
216 */
217 public void processDocument(IUploadFile file);
218 }