View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/mySpace/server/src/java/org/astrogrid/mySpace/mySpaceManager/FileStoreDriver.java,v $</cvs:source>
3    * <cvs:author>$Author: jdt $</cvs:author>
4    * <cvs:date>$Date: 2004/11/25 10:52:49 $</cvs:date>
5    * <cvs:version>$Revision: 1.6 $</cvs:version>
6    * <cvs:log>
7    *   $Log: FileStoreDriver.java,v $
8    *   Revision 1.6  2004/11/25 10:52:49  jdt
9    *   Merge from dave-dev-200410061224-200411221626
10   *
11   *   Revision 1.5.24.3  2004/11/19 11:11:28  dave
12   *   Updated FileStoreDriver to match changes in FileStore
13   *
14   *   Revision 1.5.24.2  2004/11/02 23:18:17  dave
15   *   Updated to match changes to FileStore FileProperties ...
16   *
17   *   Revision 1.5.24.1  2004/10/26 13:34:27  dave
18   *   Updated FileStoreDelegateResolver to FileStoreDelegateResolverImpl ....
19   *
20   *   Revision 1.5  2004/09/09 01:19:50  dave
21   *   Updated MIME type handling in MySpace.
22   *   Extended test coverage for MIME types in FileStore and MySpace.
23   *   Added VM memory data to community ServiceStatusData.
24   *
25   *   Revision 1.4.6.3  2004/09/08 20:59:40  dave
26   *   Added check for fake null in mime type ....
27   *
28   *   Revision 1.4.6.2  2004/09/08 14:06:35  dave
29   *   Added check for existing mime type.
30   *
31   *   Revision 1.4.6.1  2004/09/08 13:20:24  dave
32   *   Updated mime type handling and tests ...
33   *
34   *   Revision 1.4  2004/09/02 10:25:41  dave
35   *   Updated FileStore and MySpace to handle mime type and file size.
36   *   Updated Community deployment script.
37   *
38   *   Revision 1.3.2.1  2004/09/01 03:01:48  dave
39   *   Updated to pass mime type to filestore.
40   *
41   *   Revision 1.3  2004/08/27 22:43:15  dave
42   *   Updated filestore and myspace to report file size correctly.
43   *
44   *   Revision 1.2.12.1  2004/08/27 14:06:52  dave
45   *   Modified FileStoreDriver and DataItemRecord to propagate size.
46   *
47   *   Revision 1.2  2004/08/18 19:00:01  dave
48   *   Myspace manager modified to use remote filestore.
49   *   Tested before checkin - integration tests at 91%.
50   *
51   *   Revision 1.1.2.12  2004/08/09 11:17:00  dave
52   *   Added resource URL and resource IVORN to properties.
53   *
54   *   Revision 1.1.2.11  2004/08/06 13:43:18  dave
55   *   Added initial filestore copy
56   *
57   *   Revision 1.1.2.10  2004/08/05 16:58:28  dave
58   *   Added delete to filestore driver
59   *
60   *   Revision 1.1.2.9  2004/08/05 15:44:27  dave
61   *   Added delete to filestore driver
62   *
63   *   Revision 1.1.2.8  2004/08/05 15:39:10  dave
64   *   Added delete to filestore driver
65   *
66   *   Revision 1.1.2.7  2004/08/04 04:55:21  dave
67   *   Refactored Actions to use filestore for get URL transfer ....
68   *
69   *   Revision 1.1.2.6  2004/08/04 02:56:43  dave
70   *   Reafactored Action.getBytes to use filestore
71   *
72   *   Revision 1.1.2.5  2004/08/04 01:51:03  dave
73   *   Refactored Actions and FileStoreDriver to use Ivorn rather than Uri
74   *
75   *   Revision 1.1.2.4  2004/08/02 18:19:15  dave
76   *   Added export string to filestore driver
77   *
78   *   Revision 1.1.2.3  2004/08/02 16:14:41  dave
79   *   Added debug for property
80   *
81   *   Revision 1.1.2.2  2004/08/02 14:54:15  dave
82   *   Trying to get integration tests to run
83   *
84   *   Revision 1.1.2.1  2004/07/28 05:01:09  dave
85   *   Started adding the FileStore driver .... extremely broke at the moment
86   *
87   * </cvs:log>
88   *
89   */
90  package org.astrogrid.mySpace.mySpaceManager ;
91  
92  import org.astrogrid.mySpace.mySpaceStatus.Logger ;
93  
94  import java.net.URL ;
95  import java.net.URISyntaxException ;
96  import java.net.MalformedURLException ;
97  
98  import org.astrogrid.store.Ivorn ;
99  
100 import org.astrogrid.filestore.client.FileStoreDelegate ;
101 
102 import org.astrogrid.filestore.common.file.FileProperty ;
103 import org.astrogrid.filestore.common.file.FileProperties ;
104 
105 import org.astrogrid.filestore.common.transfer.UrlGetTransfer ;
106 
107 import org.astrogrid.filestore.resolver.FileStoreDelegateResolver ;
108 import org.astrogrid.filestore.resolver.FileStoreDelegateResolverImpl ;
109 import org.astrogrid.filestore.resolver.FileStoreResolverException ;
110 
111 import org.astrogrid.filestore.common.exception.FileStoreIdentifierException ;
112 
113 import org.astrogrid.filestore.common.exception.FileStoreException ;
114 import org.astrogrid.filestore.common.exception.FileStoreNotFoundException ;
115 import org.astrogrid.filestore.common.exception.FileStoreIdentifierException ;
116 import org.astrogrid.filestore.common.exception.FileStoreServiceException ;
117 import org.astrogrid.filestore.common.exception.FileStoreTransferException ;
118 
119 
120 /***
121  * A wrapper class to integrate the FileStore delegate into the MySpaceManager.
122  *
123  */
124 public class FileStoreDriver
125 	{
126 	/***
127 	 * Switch for our debug statements.
128 	 *
129 	 */
130 	protected static final boolean DEBUG_FLAG = true ;
131 
132 	/***
133 	 * Property key for the myspace file name.
134 	 *
135 	 */
136 	public static final String MYSPACE_NAME_PROPERTY = "org.astrogrid.myspace.name" ;
137 
138 	/***
139 	 * Property key for the myspace file ident.
140 	 *
141 	 */
142 	public static final String MYSPACE_IDENT_PROPERTY = "org.astrogrid.myspace.ident" ;
143 
144 	/***
145 	 * A reference to our FileStore delegate.
146 	 *
147 	 */
148 	private FileStoreDelegate filestore ;
149 
150 	/***
151 	 * Public constructor using a specific filestore delegate.
152 	 * @paran filestore Our filestore delegate.
153 	 *
154 	 */
155 	public FileStoreDriver(FileStoreDelegate filestore)
156 		{
157 		if (null == filestore)
158 			{
159 			throw new IllegalArgumentException(
160 				"Null filestore delegate"
161 				) ;
162 			}
163 		this.filestore = filestore ;
164 		}
165 
166 	/***
167 	 * A factory to create a new FileStoreDriver using the default registry and filestore.
168 	 * This uses the astrogrid configuration to lookup the default registry URL.
169 	 * This uses the MMC configurator to lookup the default filestore ivorn.
170      * @throws FileStoreIdentifierException If the identifier is not valid.
171      * @throws FileStoreResolverException If unable to resolve the identifier.
172 	 *
173 	 */
174 	public static FileStoreDriver create()
175 		throws FileStoreResolverException, FileStoreIdentifierException
176 		{
177 		if (DEBUG_FLAG) System.out.println("") ;
178 		if (DEBUG_FLAG) System.out.println("----\"----") ;
179 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.create()") ;
180 		try {
181 			String property = MMC.getProperty(
182 				"MYSPACESERVERURL",
183 				"MYSPACEMANAGER"
184 				) ;
185 			if (DEBUG_FLAG) System.out.println("  property : " + property) ;
186 			return create(
187 				new Ivorn(
188 				 	property
189 					)
190 				) ;
191 			}
192 		catch(FileStoreResolverException ouch)
193 			{
194 			throw ouch ;
195 			}
196 		catch(FileStoreIdentifierException ouch)
197 			{
198 			throw ouch ;
199 			}
200 		catch(Throwable ouch)
201 			{
202 			throw new FileStoreResolverException(
203 				"Failed to resolve filestore delegate",
204 				ouch
205 				) ;
206 			}
207 		}
208 
209 	/***
210 	 * A factory to create a new FileStoreDriver using the default registry.
211 	 * This uses the astrogrid configuration to lookup the default registry URL.
212 	 * @param ivorn The ivorn of the filestore service.
213      * @throws FileStoreIdentifierException If the identifier is not valid.
214      * @throws FileStoreResolverException If unable to resolve the identifier.
215 	 *
216 	 */
217 	public static FileStoreDriver create(String ivorn)
218 		throws FileStoreResolverException, FileStoreIdentifierException
219 		{
220 		if (DEBUG_FLAG) System.out.println("") ;
221 		if (DEBUG_FLAG) System.out.println("----\"----") ;
222 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.create()") ;
223 		if (DEBUG_FLAG) System.out.println("  Ivorn : " + ivorn) ;
224 		try {
225 			return create(
226 				new Ivorn(
227 					ivorn
228 					)
229 				) ;
230 			}
231 		catch (URISyntaxException ouch)
232 			{
233 			throw new FileStoreIdentifierException(
234 				ouch
235 				) ;
236 			}
237 		}
238 
239 	/***
240 	 * A factory to create a new FileStoreDriver using the default registry.
241 	 * This uses the astrogrid configuration to lookup the default registry URL.
242 	 * @param ivorn The ivorn of the filestore service.
243      * @throws FileStoreIdentifierException If the identifier is not valid.
244      * @throws FileStoreResolverException If unable to resolve the identifier.
245 	 *
246 	 */
247 	public static FileStoreDriver create(Ivorn ivorn)
248 		throws FileStoreResolverException, FileStoreIdentifierException
249 		{
250 		if (DEBUG_FLAG) System.out.println("") ;
251 		if (DEBUG_FLAG) System.out.println("----\"----") ;
252 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.create()") ;
253 		if (DEBUG_FLAG) System.out.println("  Ivorn : " + ivorn) ;
254 		//
255 		// Create our resolver using the default registry.
256 		FileStoreDelegateResolver resolver =
257 			new FileStoreDelegateResolverImpl() ;
258 		//
259 		// Use our resolver to create our filestore delegate.
260 		return new FileStoreDriver(
261 			resolver.resolve(
262 				ivorn
263 				)
264 			) ;
265 		}
266 
267 	/***
268 	 * A factory to create a new FileStoreDriver.
269 	 * @paran ivorn The ivorn for our FileStore service.
270 	 * @paran registry The endpoint URL for our registry service.
271      * @throws FileStoreIdentifierException If the identifier is not valid.
272      * @throws FileStoreResolverException If unable to resolve the identifier.
273 	 *
274 	 */
275 	public static FileStoreDriver create(Ivorn ivorn, URL registry)
276 		throws FileStoreResolverException, FileStoreIdentifierException
277 		{
278 		if (DEBUG_FLAG) System.out.println("") ;
279 		if (DEBUG_FLAG) System.out.println("----\"----") ;
280 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.create()") ;
281 		if (DEBUG_FLAG) System.out.println("  Registry : " + registry) ;
282 		if (DEBUG_FLAG) System.out.println("  Ivorn    : " + ivorn) ;
283 		//
284 		// Create our resolver using the registry endpoint.
285 		FileStoreDelegateResolver resolver =
286 			new FileStoreDelegateResolverImpl(
287 				registry
288 				) ;
289 		//
290 		// Use our resolver to create our filestore delegate.
291 		return new FileStoreDriver(
292 			resolver.resolve(
293 				ivorn
294 				)
295 			) ;
296 		}
297 
298 	/***
299 	 * Import (store) a string in a new file.
300 	 * @param item The data item record for the data.
301 	 * @param data The string of data to store.
302 	 * @throws FileStoreException if the data string is null.
303 	 * @throws FileStoreServiceException if unable handle the request.
304 	 *
305 	 */
306 	public void importString(DataItemRecord item, String data)
307 		throws FileStoreServiceException, FileStoreException
308 		{
309 		if (DEBUG_FLAG) System.out.println("") ;
310 		if (DEBUG_FLAG) System.out.println("----\"----") ;
311 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.importString()") ;
312 		//
313 		// Transfer the data, and update the item with the results.
314 		updateDataItem(
315 			item,
316 			filestore.importString(
317 				initProperties(item),
318 				data
319 				)
320 			) ;
321 		}
322 
323 	/***
324 	 * Import (store) an array of bytes in a new file.
325 	 * @param item The data item record for the data.
326 	 * @param data The data to store.
327 	 * @throws FileStoreException if the data string is null.
328 	 * @throws FileStoreServiceException if unable handle the request.
329 	 *
330 	 */
331 	public void importBytes(DataItemRecord item, byte[] data)
332 		throws FileStoreServiceException, FileStoreException
333 		{
334 		if (DEBUG_FLAG) System.out.println("") ;
335 		if (DEBUG_FLAG) System.out.println("----\"----") ;
336 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.importBytes()") ;
337 		//
338 		// Transfer the data, and update the item with the results.
339 		updateDataItem(
340 			item,
341 			filestore.importBytes(
342 				initProperties(item),
343 				data
344 				)
345 			) ;
346 		}
347 
348 	/***
349 	 * Append (store) a string to an existing file.
350 	 * @param item The data item record for the data.
351 	 * @param data The string of data to store.
352 	 * @throws FileStoreIdentifierException if the identifier is null or not valid.
353 	 * @throws FileStoreNotFoundException if unable to locate the file.
354 	 * @throws FileStoreException if the string is null.
355 	 * @throws FileStoreServiceException if unable handle the request.
356 	 *
357 	 */
358 	public void appendString(DataItemRecord item, String data)
359 		throws FileStoreServiceException, FileStoreIdentifierException, FileStoreNotFoundException, FileStoreException
360 		{
361 		if (DEBUG_FLAG) System.out.println("") ;
362 		if (DEBUG_FLAG) System.out.println("----\"----") ;
363 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.appendString()") ;
364 		//
365 		// Transfer the data, and update the item with the results.
366 		updateDataItem(
367 			item,
368 			filestore.appendString(
369 				item.getDataItemFile(),
370 				data
371 				)
372 			) ;
373 		}
374 
375 	/***
376 	 * Append (store) an array of bytes to an existing file.
377 	 * @param item The data item record for the data.
378 	 * @param data The data to store.
379 	 * @throws FileStoreIdentifierException if the identifier is null or not valid.
380 	 * @throws FileStoreNotFoundException if unable to locate the file.
381 	 * @throws FileStoreException if the string is null.
382 	 * @throws FileStoreServiceException if unable handle the request.
383 	 *
384 	 */
385 	public void appendBytes(DataItemRecord item, byte[] data)
386 		throws FileStoreServiceException, FileStoreIdentifierException, FileStoreNotFoundException, FileStoreException
387 		{
388 		if (DEBUG_FLAG) System.out.println("") ;
389 		if (DEBUG_FLAG) System.out.println("----\"----") ;
390 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.appendBytes()") ;
391 		//
392 		// Transfer the data, and update the item with the results.
393 		updateDataItem(
394 			item,
395 			filestore.appendBytes(
396 				item.getDataItemFile(),
397 				data
398 				)
399 			) ;
400 		}
401 
402 	/***
403 	 * Import (store) the contents of a URL in a new file.
404 	 * @param item The data item record for the data.
405 	 * @param source The source URL.
406 	 * @throws FileStoreServiceException if unable handle the request.
407 	 * @throws FileStoreTransferException if the transfer properties not valid.
408 	 *
409 	 */
410 	public void importUrl(DataItemRecord item, URL source)
411 		throws FileStoreServiceException, FileStoreTransferException, FileStoreIdentifierException
412 		{
413 		if (DEBUG_FLAG) System.out.println("") ;
414 		if (DEBUG_FLAG) System.out.println("----\"----") ;
415 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.importUrl()") ;
416 		//
417 		// Transfer the data, and update the item with the results.
418 		updateDataItem(
419 			item,
420 			filestore.importData(
421 				new UrlGetTransfer(
422 					source,
423 					initProperties(item)
424 					)
425 				)
426 				.getFileProperties()
427 			) ;
428 		}
429 
430 	/***
431 	 * Get a file contents as a string.
432 	 * @param item The data item record for the data.
433 	 * @throws FileStoreIdentifierException if the identifier is null or not valid.
434 	 * @throws FileStoreNotFoundException if unable to locate the file.
435 	 * @throws FileStoreServiceException if unable handle the request.
436 	 *
437 	 */
438 	public String exportString(DataItemRecord item)
439 		throws FileStoreServiceException, FileStoreIdentifierException, FileStoreNotFoundException
440 		{
441 		if (DEBUG_FLAG) System.out.println("") ;
442 		if (DEBUG_FLAG) System.out.println("----\"----") ;
443 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.exportString()") ;
444 		return filestore.exportString(
445 			item.getDataItemFile()
446 			) ;
447 		}
448 
449 	/***
450 	 * Get a file contents as a byte array.
451 	 * @param item The data item record for the data.
452 	 * @throws FileStoreIdentifierException if the identifier is null or not valid.
453 	 * @throws FileStoreNotFoundException if unable to locate the file.
454 	 * @throws FileStoreServiceException if unable handle the request.
455 	 *
456 	 */
457 	public byte[] exportBytes(DataItemRecord item)
458 		throws FileStoreServiceException, FileStoreIdentifierException, FileStoreNotFoundException
459 		{
460 		if (DEBUG_FLAG) System.out.println("") ;
461 		if (DEBUG_FLAG) System.out.println("----\"----") ;
462 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.exportBytes()") ;
463 		return filestore.exportBytes(
464 			item.getDataItemFile()
465 			) ;
466 		}
467 
468 	/***
469 	 * Delete data from the store.
470 	 * @param item The data item record for the data.
471 	 * @throws FileStoreIdentifierException if the identifier is null or not valid.
472 	 * @throws FileStoreNotFoundException if unable to locate the file.
473 	 * @throws FileStoreServiceException if unable handle the request.
474 	 *
475 	 *
476 	 */
477 	public void delete(DataItemRecord item)
478 		throws FileStoreServiceException, FileStoreIdentifierException, FileStoreNotFoundException
479 		{
480 		if (DEBUG_FLAG) System.out.println("") ;
481 		if (DEBUG_FLAG) System.out.println("----\"----") ;
482 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.delete()") ;
483 		updateDataItem(
484 			item,
485 			filestore.delete(
486 				item.getDataItemFile()
487 				)
488 			) ;
489 		}
490 
491 	/***
492 	 * Copy a file within the server.
493 	 * @param source      - the data item to copy from.
494 	 * @param destination - the data item to copy into.
495 	 * @throws FileStoreTransferException if unable to transfer the data.
496 	 * @throws FileStoreIdentifierException if the source identifier is null or not valid.
497 	 * @throws FileStoreNotFoundException if unable to locate the file.
498 	 * @throws FileStoreServiceException if unable handle the request.
499 	 *
500 	 */
501 	public void duplicate(DataItemRecord source, DataItemRecord destination)
502 		throws FileStoreServiceException, FileStoreIdentifierException, FileStoreNotFoundException, FileStoreTransferException
503 		{
504 		if (DEBUG_FLAG) System.out.println("") ;
505 		if (DEBUG_FLAG) System.out.println("----\"----") ;
506 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.duplicate()") ;
507 		updateDataItem(
508 			destination,
509 			filestore.duplicate(
510 				source.getDataItemFile(),
511 				null
512 				)
513 			) ;
514 		}
515 
516 	/***
517 	 * Update a DataItemRecord from data in an array of FileProperty.
518 	 * @param item - the myspace data item to update.
519 	 * @param properties - the original properties from the file store.
520 	 *
521 	 */
522 	private void updateDataItem(DataItemRecord item, FileProperty[] properties)
523 		throws FileStoreIdentifierException
524 		{
525 		updateDataItem(
526 			item,
527 			new FileProperties(
528 				properties
529 				)
530 			) ;
531 		}
532 
533 	/***
534 	 * Update a DataItemRecord from data in a FileProperties.
535 	 * @param item - the myspace data item to update.
536 	 * @param properties - the original properties from the file store.
537 	 *
538 	 */
539 	private void updateDataItem(DataItemRecord item, FileProperties properties)
540 		throws FileStoreIdentifierException
541 		{
542 		//
543 		// Update the data item properties.
544 		item.setDataItemFile(
545 			properties.getStoreResourceIdent()
546 			) ;
547 		item.setDataItemIvorn(
548 			properties.getStoreResourceIvorn().toString()
549 			) ;
550 		item.setDataItemUri(
551 			properties.getStoreResourceUrl().toString()
552 			) ;
553 		item.setSize(
554 			properties.getContentSize()
555 			) ;
556 		item.setDataItemMime(
557 			properties.getContentType()
558 			) ;
559 		}
560 
561 	/***
562 	 * Create an initial set of properties for an item.
563 	 * This includes the guess for the mime type based on the file name.
564 	 * @param item The data item record.
565 	 * @return An array of properties for the item.
566 	 *
567 	 */
568 	private FileProperty[] initProperties(DataItemRecord item)
569 		{
570 		if (DEBUG_FLAG) System.out.println("") ;
571 		if (DEBUG_FLAG) System.out.println("----\"----") ;
572 		if (DEBUG_FLAG) System.out.println("FileStoreDriver.initProperties()") ;
573 		if (DEBUG_FLAG) System.out.println("  Name : " + item.getDataItemName()) ;
574 		if (DEBUG_FLAG) System.out.println("  Mime : " + item.getDataItemMime()) ;
575 		//
576 		// Create our file properties.
577 		FileProperties properties = new FileProperties() ;
578 		//
579 		// Set the myspace properties.
580 		properties.setProperty(
581 			MYSPACE_NAME_PROPERTY,
582 			item.getDataItemName()
583 			) ;
584 		properties.setProperty(
585 			MYSPACE_IDENT_PROPERTY,
586 			String.valueOf(item.getDataItemID())
587 			) ;
588 		//
589 		// Get the current mime type.
590 		String mime = item.getDataItemMime() ;
591 		//
592 		// Check for a fake null.
593 		if ("null".equals(mime))
594 			{
595 			if (DEBUG_FLAG) System.out.println("  Fake null in data item mime type.") ;
596 			mime = null ;
597 			}
598 		//
599 		// If the mime type has not already been set.
600 		if (null == mime)
601 			{
602 			if (DEBUG_FLAG) System.out.println("  Null mime type in data item.") ;
603 			if (DEBUG_FLAG) System.out.println("  Generating mime type from name.") ;
604 			//
605 			// Get the item file name.
606 			String name = item.getDataItemName() ;
607 			//
608 			// If we have a file name.
609 			if (null != name)
610 				{
611 				//
612 				// Find the last '.' in the name.
613 				int index = name.lastIndexOf('.') ;
614 				//
615 				// If we found a '.' in the name.
616 				if (index != -1)
617 					{
618 					//
619 					// Check for recognised types.
620 					String type = name.substring(
621 						index
622 						).toLowerCase() ;
623 					//
624 					// Vanilla XML.
625 					if (".xml".equals(type))
626 						{
627 						mime = FileProperties.MIME_TYPE_XML ;
628 						}
629 					//
630 					// Vanilla XSL.
631 					if (".xsl".equals(type))
632 						{
633 						mime = FileProperties.MIME_TYPE_XML ;
634 						}
635 					//
636 					// Astrogrid VoTable.
637 					if (".vot".equals(type))
638 						{
639 						mime = FileProperties.MIME_TYPE_VOTABLE ;
640 						}
641 					if (".votable".equals(type))
642 						{
643 						mime = FileProperties.MIME_TYPE_VOTABLE ;
644 						}
645 					//
646 					// Astrogrid VoList.
647 					if (".vol".equals(type))
648 						{
649 						mime = FileProperties.MIME_TYPE_VOLIST ;
650 						}
651 					if (".volist".equals(type))
652 						{
653 						mime = FileProperties.MIME_TYPE_VOLIST ;
654 						}
655 					//
656 					// Astrogrid Job details.
657 					if (".job".equals(type))
658 						{
659 						mime = FileProperties.MIME_TYPE_JOB ;
660 						}
661 					//
662 					// Astrogrid workflow.
663 					if (".work".equals(type))
664 						{
665 						mime = FileProperties.MIME_TYPE_WORKFLOW ;
666 						}
667 					if (".flow".equals(type))
668 						{
669 						mime = FileProperties.MIME_TYPE_WORKFLOW ;
670 						}
671 					if (".workflow".equals(type))
672 						{
673 						mime = FileProperties.MIME_TYPE_WORKFLOW ;
674 						}
675 					//
676 					// Astrogrid ADQL.
677 					if (".adql".equals(type))
678 						{
679 						mime = FileProperties.MIME_TYPE_ADQL ;
680 						}
681 					}
682 				}
683 			}
684 		//
685 		// If we found a mime type.
686 		if (null != mime)
687 			{
688 			//
689 			// Set the mime property.
690 			properties.setProperty(
691 				FileProperties.MIME_TYPE_PROPERTY,
692 				mime
693 				) ;
694 			}
695 		//
696 		// Return the new properties as an array.
697 		return properties.toArray() ;
698 		}
699 	}
700