Changeset 6030
- Timestamp:
- 02/02/10 09:12:40 (7 weeks ago)
- Location:
- trunk/components/blitz
- Files:
-
- 2 modified
-
resources/omero/Repositories.ice (modified) (1 diff)
-
src/ome/services/blitz/repo/PublicRepositoryI.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/blitz/resources/omero/Repositories.ice
r5965 r6030 39 39 */ 40 40 41 // T ODO should we return OriginalFiles here for acmTime, etc.42 omero::api:: StringSet list(string path) throws ServerError;43 omero::api:: StringSet listDirs(string path) throws ServerError;44 omero::api:: StringSet listFiles(string path) throws ServerError;41 // These list methods provide all files, registered or not. 42 omero::api::OriginalFileList list(string path) throws ServerError; 43 omero::api::OriginalFileList listDirs(string path) throws ServerError; 44 omero::api::OriginalFileList listFiles(string path) throws ServerError; 45 45 46 46 // These list methods provide only registered files -
trunk/components/blitz/src/ome/services/blitz/repo/PublicRepositoryI.java
r5966 r6030 29 29 import omero.grid._RepositoryDisp; 30 30 import omero.model.Format; 31 import omero.model.FormatI; 31 32 import omero.model.OriginalFile; 32 33 import omero.model.OriginalFileI; … … 124 125 125 126 @SuppressWarnings("unchecked") 126 public List<String> list(String path, Current __current) throws ServerError { 127 128 public List<OriginalFile> list(String path, Current __current) throws ServerError { 127 129 File file = checkPath(path); 128 130 List<File> files = Arrays.asList(file.listFiles()); 129 return filesTo Paths(files);130 } 131 132 public List< String> listDirs(String path, Current __current)131 return filesToOriginalFiles(files); 132 } 133 134 public List<OriginalFile> listDirs(String path, Current __current) 133 135 throws ServerError { 134 136 File file = checkPath(path); 135 137 List<File> files = Arrays.asList(file.listFiles((FileFilter)FileFilterUtils.directoryFileFilter())); 136 return filesTo Paths(files);137 } 138 139 public List< String> listFiles(String path, Current __current)138 return filesToOriginalFiles(files); 139 } 140 141 public List<OriginalFile> listFiles(String path, Current __current) 140 142 throws ServerError { 141 143 File file = checkPath(path); 142 144 List<File> files = Arrays.asList(file.listFiles((FileFilter)FileFilterUtils.fileFileFilter())); 143 return filesTo Paths(files);145 return filesToOriginalFiles(files); 144 146 } 145 147 … … 192 194 public List<OriginalFile> listKnown(String path, Current __current) 193 195 throws ServerError { 194 // TODO Auto-generated method stub 195 return null; 196 File file = checkPath(path); 197 List<File> files = Arrays.asList(file.listFiles()); 198 return knownOriginalFiles(files); 196 199 } 197 200 198 201 public List<OriginalFile> listKnownDirs(String path, Current __current) 199 202 throws ServerError { 200 // TODO Auto-generated method stub 201 return null; 203 File file = checkPath(path); 204 List<File> files = Arrays.asList(file.listFiles((FileFilter)FileFilterUtils.directoryFileFilter())); 205 return knownOriginalFiles(files); 202 206 } 203 207 204 208 public List<OriginalFile> listKnownFiles(String path, Current __current) 205 209 throws ServerError { 206 // TODO Auto-generated method stub 207 return null; 210 File file = checkPath(path); 211 List<File> files = Arrays.asList(file.listFiles((FileFilter)FileFilterUtils.fileFileFilter())); 212 return knownOriginalFiles(files); 208 213 } 209 214 210 215 public Format format(String path, Current __current) throws ServerError { 211 // TODO Auto-generated method stub 212 return null; 216 return getFileFormat(path); 213 217 } 214 218 … … 244 248 } 245 249 250 // Just return a dummy format for testing purposes. 251 private Format getFileFormat(String path) { 252 Format dummy = new FormatI(); 253 dummy.setValue(rstring("DUMMY-FORMAT")); 254 return dummy; 255 } 246 256 247 257 private List<String> filesToPaths(Collection<File> files) { … … 252 262 return rv; 253 263 } 264 265 private List<OriginalFile> filesToOriginalFiles(Collection<File> files) { 266 List rv = new ArrayList<OriginalFile>(); 267 for (File f : files) { 268 rv.add(createOriginalFile(f)); 269 } 270 return rv; 271 } 272 273 private List<OriginalFile> knownOriginalFiles(Collection<File> files) { 274 List rv = new ArrayList<OriginalFile>(); 275 /* for (File f : files) { 276 OriginalFile file = getOriginalFileOrNull(f.getAbsolutePath()); 277 if (file != null) { 278 rv.add(file); 279 } 280 } */ 281 return rv; 282 } 283 284 285 private OriginalFile createOriginalFile(File f) { 286 // How do I confirm if an OriginalFle is already registered? 287 // Is that necessary here? 288 OriginalFile file = new OriginalFileI(); 289 file.setPath(rstring(f.getAbsolutePath())); 290 file.setSize(rlong(f.length())); 291 file.setSha1(rstring("UNKNOWN")); 292 // What more do I need to set here, times, details? 293 294 // This needs to be unique - see # 295 file.setName(rstring(f.getAbsolutePath())); 296 297 // How should I get the format of a file? 298 file.setFormat(getFileFormat(f.getAbsolutePath())); 299 300 return file; 301 } 302 303 // THIS FAILS AT PRESENT. NEED TO SORT OUT THE RETURN TYPE FROM THE QUERY 304 // ome.model.core.OriginalFile vs omero.model.OriginalFile 305 // Very weak at present, returns one file. 306 // No checking further for uniqueness 307 private OriginalFile getOriginalFileOrNull(String path) { 308 try { 309 final String queryString = "from OriginalFile as o where o.path = '" 310 + path + "'"; 311 OriginalFile file = (OriginalFile) executor.execute( 312 principal, new Executor.SimpleWork(this, 313 "getOriginalFileOrNull") { 314 315 @Transactional(readOnly = true) 316 public Object doWork(Session session, ServiceFactory sf) { 317 return sf.getQueryService().findByQuery( 318 queryString, null); 319 } 320 }); 321 return file; 322 } catch (RuntimeException re) { 323 return null; 324 } 325 } 326 327 328 254 329 }