View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/filemanager/common/src/java/org/astrogrid/filemanager/common/FileManagerMock.java,v $</cvs:source>
3    * <cvs:author>$Author: clq2 $</cvs:author>
4    * <cvs:date>$Date: 2005/01/28 10:43:58 $</cvs:date>
5    * <cvs:version>$Revision: 1.5 $</cvs:version>
6    * <cvs:log>
7    *   $Log: FileManagerMock.java,v $
8    *   Revision 1.5  2005/01/28 10:43:58  clq2
9    *   dave_dev_200501141257 (filemanager)
10   *
11   *   Revision 1.4.2.2  2005/01/25 11:15:58  dave
12   *   Fixed NullPointer bug in manager.
13   *   Refactored client test case ...
14   *
15   *   Revision 1.4.2.1  2005/01/20 07:17:15  dave
16   *   Added import data from URL to server side logic ....
17   *   Tidied up tabs in some files.
18   *
19   *   Revision 1.4  2005/01/13 17:23:15  jdt
20   *   merges from dave-dev-200412201250
21   *
22   *   Revision 1.3.4.8  2005/01/12 14:33:48  dave
23   *   Removed System.out.println debug ...
24   *
25   *   Revision 1.3.4.7  2005/01/12 13:16:27  dave
26   *   Changed tabs to spaces ...
27   *
28   *   Revision 1.3.4.6  2005/01/12 12:40:08  dave
29   *   Added account handling to store ...
30   *
31   *   Revision 1.3.4.5  2005/01/10 21:27:47  dave
32   *   Refactores NodeMock as FileManagerStoreNode ...
33   *
34   *   Revision 1.3.4.4  2005/01/10 15:36:27  dave
35   *   Refactored store into a separate interface and mock impl ...
36   *
37   *   Revision 1.3.4.3  2005/01/07 12:18:00  dave
38   *   Added StoreClientWrapperTest
39   *   Added StoreFileWrapper
40   *
41   *   Revision 1.3.4.2  2004/12/24 02:42:45  dave
42   *   Changed delete to use ivorn ...
43   *
44   *   Revision 1.3.4.1  2004/12/24 02:05:05  dave
45   *   Refactored exception handling, removing IdentifierException from the public API ...
46   *
47   *   Revision 1.3  2004/12/16 17:25:49  jdt
48   *   merge from dave-dev-200410061224-200412161312
49   *
50   *   Revision 1.1.2.40  2004/12/14 17:17:01  dave
51   *   Added delete from filemanager ....
52   *
53   *   Revision 1.1.2.39  2004/12/14 16:51:27  dave
54   *   Added delete from filemanager ....
55   *
56   *   Revision 1.1.2.38  2004/12/14 16:02:09  dave
57   *   Added delete from filemanager ....
58   *
59   *   Revision 1.1.2.37  2004/12/14 15:48:54  dave
60   *   Added delete from filemanager ....
61   *
62   *   Revision 1.1.2.36  2004/12/14 15:44:12  dave
63   *   Added delete from filemanager ....
64   *
65   *   Revision 1.1.2.35  2004/12/14 14:56:25  dave
66   *   Added location change for copy empty ...
67   *
68   *   Revision 1.1.2.34  2004/12/14 14:44:46  dave
69   *   Added test for copy empty location ...
70   *
71   *   Revision 1.1.2.33  2004/12/14 14:11:57  dave
72   *   Added delete to the server API ....
73   *
74   *   Revision 1.1.2.32  2004/12/11 21:19:53  dave
75   *   Added copy accross remote filestore(s) ...
76   *
77   *   Revision 1.1.2.31  2004/12/11 05:59:17  dave
78   *   Added internal copy for nodes ...
79   *   Added local copy for data ...
80   *
81   *   Revision 1.1.2.30  2004/12/10 05:21:25  dave
82   *   Added node and iterator to client API ...
83   *
84   *   Revision 1.1.2.29  2004/12/08 17:54:55  dave
85   *   Added update to FileManager client and server side ...
86   *
87   *   Revision 1.1.2.28  2004/12/08 01:56:04  dave
88   *   Added filestore location to move ...
89   *
90   *   Revision 1.1.2.27  2004/12/06 13:29:02  dave
91   *   Added initial code for move location ....
92   *
93   *   Revision 1.1.2.26  2004/12/04 05:22:21  dave
94   *   Fixed null parent mistake ...
95   *
96   *   Revision 1.1.2.25  2004/12/02 19:11:54  dave
97   *   Added move name and parent to manager ...
98   *
99   * </cvs:log>
100  *
101  */
102 package org.astrogrid.filemanager.common ;
103 
104 import java.net.URL ;
105 
106 import java.util.Map ;
107 import java.util.Vector ;
108 import java.util.HashMap ;
109 import java.util.Iterator ;
110 import java.util.Collection ;
111 import java.util.StringTokenizer ;
112 
113 import org.apache.commons.logging.Log ;
114 import org.apache.commons.logging.LogFactory ;
115 
116 import org.astrogrid.store.Ivorn ;
117 
118 import org.astrogrid.filestore.common.file.FileProperty ;
119 import org.astrogrid.filestore.common.file.FileProperties ;
120 
121 import org.astrogrid.filestore.common.transfer.UrlGetRequest  ;
122 import org.astrogrid.filestore.common.transfer.UrlGetTransfer ;
123 import org.astrogrid.filestore.common.transfer.UrlPutTransfer ;
124 import org.astrogrid.filestore.common.transfer.TransferProperties ;
125 
126 import org.astrogrid.filestore.common.exception.FileStoreServiceException ;
127 import org.astrogrid.filestore.common.exception.FileStoreIdentifierException ;
128 
129 import org.astrogrid.filestore.client.FileStoreDelegate ;
130 import org.astrogrid.filestore.resolver.FileStoreDelegateResolver ;
131 
132 import org.astrogrid.filemanager.common.ivorn.FileManagerIvornFactory ;
133 import org.astrogrid.filemanager.common.ivorn.FileManagerIvornParser ;
134 
135 import org.astrogrid.filemanager.common.exception.NodeNotFoundException ;
136 import org.astrogrid.filemanager.common.exception.DuplicateNodeException ;
137 import org.astrogrid.filemanager.common.exception.FileManagerServiceException ;
138 import org.astrogrid.filemanager.common.exception.FileManagerIdentifierException ;
139 import org.astrogrid.filemanager.common.exception.FileManagerPropertiesException ;
140 
141 /***
142  * A mock implementation of the file manager interface.
143  *
144  */
145 public class FileManagerMock
146     implements FileManager
147     {
148     /***
149      * Our debug logger.
150      *
151      */
152     private static Log log = LogFactory.getLog(FileManagerMock.class);
153 
154     /***
155      * Our FileManager configuration.
156      *
157      */
158     private FileManagerConfig config ;
159 
160     /***
161      * Our FileManager store.
162      *
163      */
164     private FileManagerStore store ;
165 
166     /***
167      * Our FileStore resolver.
168      *
169      */
170     private FileStoreDelegateResolver resolver ;
171 
172     /***
173      * Our identifier factory.
174      *
175      */
176     private FileManagerIvornFactory factory ;
177 
178     /***
179      * Public constructor, using a custom configuration, identifier factory and resolver.
180      * @param config   The local file manager configuration.
181      * @param store    The local file manager store.
182      * @param factory  A factory for creating resource identifiers.
183      * @param resolver A resolver to locate filestores.
184      *
185      */
186     public FileManagerMock(
187         FileManagerConfig config,
188         FileManagerStore  store,
189         FileManagerIvornFactory factory,
190         FileStoreDelegateResolver resolver
191         )
192         {
193         if (null == config)
194             {
195             throw new IllegalArgumentException(
196                 "Null manager configuration"
197                 );
198             }
199         if (null == store)
200             {
201             throw new IllegalArgumentException(
202                 "Null manager store"
203                 );
204             }
205         if (null == factory)
206             {
207             throw new IllegalArgumentException(
208                 "Null identifier factory"
209                 );
210             }
211         if (null == resolver)
212             {
213             throw new IllegalArgumentException(
214                 "Null FileStore resolver"
215                 );
216             }
217         this.store    = store ;
218         this.config   = config ;
219         this.factory  = factory ;
220         this.resolver = resolver ;
221         }
222 
223     /***
224      * Get the manager identifier.
225      * @return The manager identifier (ivorn).
226      * @throws FileManagerServiceException If a problem occurs when handling the request.
227      *
228      */
229     public String getIdentifier()
230         throws FileManagerServiceException
231         {
232         return config.getFileManagerIvorn().toString() ;
233         }
234 
235     /***
236      * Create a root node for a new account.
237      * @param ident The identifier for the account.
238      * @return An array of properties for the new account node.
239      * @throws DuplicateNodeException If the the account already exists.
240      * @throws FileManagerServiceException If a problem occurs when handling the request.
241      *
242      */
243     public FileProperty[] addAccount(String ident)
244         throws FileManagerServiceException, DuplicateNodeException
245         {
246         log.debug("");
247         log.debug("FileManagerMock.addAccount()");
248         log.debug("  Account : " + ident);
249         if (null == ident)
250             {
251             throw new IllegalArgumentException(
252                 "Null account identifier"
253                 );
254             }
255         //
256         // Check if the account already exists.
257         if (store.hasAccount(ident))
258             {
259             throw new DuplicateNodeException(
260                 "Account already exists"
261                 ) ;
262             }
263         //
264         // Create the new node.
265         FileManagerStoreNode node = this.addNode(
266             (FileManagerStoreNode) null,
267             "home",
268             FileManagerProperties.CONTAINER_NODE_TYPE
269             ) ;
270         //
271         // Add the node to our map of accounts.
272         store.addAccount(
273             ident,
274             node
275             ) ;
276         //
277         // Return the new node.
278         return node.getProperties().toArray() ;
279         }
280 
281     /***
282      * Get the root node for an account
283      * @param ident The account identifier.
284      * @return An array of properties for the account node.
285      * @throws NodeNotFoundException If the node does not exist.
286      * @throws FileManagerServiceException If a problem occurs when handling the request.
287      *
288      */
289     public FileProperty[] getAccount(String ident)
290         throws FileManagerServiceException, NodeNotFoundException
291         {
292         log.debug("");
293         log.debug("FileManagerMock.getAccount()");
294         log.debug("  Account : " + ident);
295         if (null == ident)
296             {
297             throw new IllegalArgumentException(
298                 "Null account identifier"
299                 ) ;
300             }
301         //
302         // Check if the node exists.
303         if (store.hasAccount(ident))
304             {
305             //
306             // Get the account root.
307             FileManagerStoreNode node = store.getAccount(ident);
308             //
309             // Return the node properties.
310             return node.getProperties().toArray() ;
311             }
312         //
313         // If the node does not exist.
314         else {
315             throw new NodeNotFoundException() ;
316             }
317         }
318 
319     /***
320      * Get a specific node, indexed by ivorn identifier.
321      * @param ivorn The node (ivorn) identifier.
322      * @return The node specified by the identifier.
323      * @throws NodeNotFoundException If the node does not exist.
324      * @throws FileManagerServiceException If a problem occurs when handling the request.
325      * @todo Refactor this as getNode(ivorn, [path])
326      *
327      */
328     public FileProperty[] getNode(String ivorn)
329         throws FileManagerServiceException, NodeNotFoundException
330         {
331         log.debug("");
332         log.debug("FileManagerMock.getNode()");
333         log.debug("  Ivorn : " + ivorn);
334         if (null == ivorn)
335             {
336             throw new NodeNotFoundException(
337                 "Null identifier"
338                 ) ;
339             }
340         //
341         // Parse the node ivorn.
342         String path = null ;
343         try {
344             path = new FileManagerIvornParser(
345                 ivorn
346                 ).getResourceIdent();
347             }
348         catch (FileManagerIdentifierException ouch)
349             {
350             throw new NodeNotFoundException(
351                 "Unable to parse node identifier"
352                 );
353             }
354         if (null == path)
355             {
356             throw new NodeNotFoundException(
357                 "Null node identifier"
358                 ) ;
359             }
360         //
361         // Split the ident on '/'
362         StringTokenizer tokens = new StringTokenizer(path, "/") ;
363         //
364         // If we have an initial token.
365         if (tokens.hasMoreTokens())
366             {
367             String ident = tokens.nextToken();
368             //
369             // Check if the node exists.
370             if (store.hasNode(ident))
371                 {
372                 FileManagerStoreNode node = store.getNode(ident) ;
373                 //
374                 // If we have more tokens.
375                 if (tokens.hasMoreTokens())
376                     {
377                     node = node.getChild(tokens) ;
378                     }
379                 return node.getProperties().toArray() ;
380                 }
381             //
382             // If the node does not exist.
383             else {
384                 throw new NodeNotFoundException() ;
385                 }
386             }
387         //
388         // If the path is empty
389         else {
390             throw new NodeNotFoundException() ;
391             }
392         }
393 
394     /***
395      * Refresh the properties for a node, indexed by ivorn identifier.
396      * If this node has stored data, this will trigger a call to the FileStore to update the data properties.
397      * @param ivorn The node (ivorn) identifier.
398      * @return The node properties.
399      * @throws NodeNotFoundException If the node does not exist.
400      * @throws FileManagerServiceException If a problem occurs when handling the request.
401      *
402      */
403     public FileProperty[] refresh(String ivorn)
404         throws FileManagerServiceException, NodeNotFoundException
405         {
406         log.debug("");
407         log.debug("FileManagerMock.refresh()");
408         log.debug("  Ivorn : " + ivorn);
409         if (null == ivorn)
410             {
411             throw new IllegalArgumentException(
412                 "Null identifier"
413                 ) ;
414             }
415         //
416         // Parse the node ivorn.
417         String path = null ;
418         try {
419             path = new FileManagerIvornParser(
420                 ivorn
421                 ).getResourceIdent();
422             }
423         catch (FileManagerIdentifierException ouch)
424             {
425             throw new NodeNotFoundException(
426                 "Unable to parse node identifier"
427                 );
428             }
429         //
430         // Split the ident on '/'
431         StringTokenizer tokens = new StringTokenizer(path, "/") ;
432         //
433         // If we have an initial token.
434         if (tokens.hasMoreTokens())
435             {
436             String ident = tokens.nextToken();
437             //
438             // Check if the node exists.
439             if (store.hasNode(ident))
440                 {
441                 FileManagerStoreNode node = store.getNode(ident) ;
442                 //
443                 // If we have more tokens.
444                 if (tokens.hasMoreTokens())
445                     {
446                     node = node.getChild(tokens) ;
447                     }
448                 log.debug("Found node ...");
449                 //
450                 // Get the current node properties.
451                 FileManagerProperties current = node.getProperties();
452                 //
453                 // If this is a file node.
454                 if (node.isDataNode())
455                     {
456                     log.debug("Found data node ...");
457                     //
458                     // Get the current store location.
459                     Ivorn  dataIvorn = null ;
460                     String dataIdent = null ;
461                     try {
462                         dataIvorn = current.getStoreResourceIvorn() ;
463                         dataIdent = current.getStoreResourceIdent() ;
464                         }
465                     catch (FileStoreIdentifierException ouch)
466                         {
467                         log.warn("");
468                         log.warn("Unable to parse current store resource ivorn");
469                         log.warn(ouch);
470                         throw new FileManagerServiceException(
471                             "Unable to parse current store resource ivorn"
472                             );
473                         }
474                     //
475                     // If the node has stored data.
476                     if (null != dataIvorn)
477                         {
478                         log.debug("Found store location ...");
479                         log.debug("  Ivorn : " + dataIvorn.toString());
480                         //
481                         // Resolve the source filestore
482                         FileStoreDelegate filestore = resolve(
483                             dataIvorn
484                             ) ;
485                         log.debug("  PASS  : Got data filestore");
486                         //
487                         // Update the filestore properties.
488                         try {
489                             //
490                             // Get the filestore properties.
491                             FileManagerProperties updated = new FileManagerProperties(
492                                 filestore.properties(
493                                     dataIdent
494                                     )
495                                 );
496                             log.debug("  PASS  : Got updated properties");
497                             log.debug("  Size  : " + String.valueOf(updated.getContentSize()));
498                             //
499                             // Update the local properties.
500                             current.merge(
501                                 updated,
502                                 new FileManagerPropertyFilter()
503                                 );
504                             log.debug("  PASS  : Merged updated properties");
505                             log.debug("  Size  : " + String.valueOf(current.getContentSize()));
506                             }
507 //
508 // Should we treat this differently ?
509 // FileStoreNotFoundException
510                         catch(Exception ouch)
511                             {
512                             log.warn("Exception thrown by FileStore.properties()");
513                             log.warn("  Exception : " + ouch);
514 //
515 // Set a property to indicate the data can't be accessed ?
516 //
517                             }
518                         }
519                     }
520                 //
521                 // Return the node properties.
522                 return current.toArray() ;
523                 }
524             //
525             // If the node does not exist.
526             else {
527                 throw new NodeNotFoundException() ;
528                 }
529             }
530         //
531         // If the path is empty
532         else {
533             throw new NodeNotFoundException() ;
534             }
535         }
536 
537     /***
538      * Get a specific child node, indexed by path.
539      * @param ivorn The parent node (ivorn) identifier.
540      * @param path  The target node path, from the parent node.
541      * @return The node specified by the parent and path.
542      * @throws NodeNotFoundException If the node does not exist.
543      * @throws FileManagerServiceException If a problem occurs when handling the request.
544      * @todo Refactor this as getNode(ivorn, [path])
545      *
546      */
547     public FileProperty[] getChild(String ivorn, String path)
548         throws FileManagerServiceException, NodeNotFoundException
549         {
550         log.debug("");
551         log.debug("FileManagerMock.getChild()");
552         log.debug("  Ivorn : " + ivorn);
553         log.debug("  Path  : " + path);
554         if (null == ivorn)
555             {
556             throw new IllegalArgumentException(
557                 "Null identifier"
558                 ) ;
559             }
560         if (null == path)
561             {
562             throw new IllegalArgumentException(
563                 "Null path"
564                 ) ;
565             }
566         //
567         // Parse the parent ivorn.
568         String ident = null ;
569         try {
570             ident = new FileManagerIvornParser(
571                 ivorn
572                 ).getResourceIdent();
573             }
574         catch (FileManagerIdentifierException ouch)
575             {
576             throw new NodeNotFoundException(
577                 "Unable to parse parent identifier"
578                 );
579             }
580         //
581         // Check if the root node exists.
582         if (store.hasNode(ident))
583             {
584             FileManagerStoreNode node = store.getNode(ident) ;
585             log.debug("");
586             log.debug("  Node : " + node.getName());
587             log.debug("  Node : " + node.getIdent());
588             //
589             // Get the child node.
590             return node.getChild(path).getProperties().toArray() ;
591             }
592         //
593         // If the root node does not exist.
594         else {
595             throw new NodeNotFoundException() ;
596             }
597         }
598 
599     /***
600      * Add a new child node.
601      * @param ivorn The (ivorn) identifier of the parent node.
602      * @param path  The new node name (and path).
603      * @param type  The new node type.
604      * @return The new node.
605      * @throws DuplicateNodeException If a node with the same name already exists.
606      * @throws NodeNotFoundException If the parent node does not exist.
607      * @throws FileManagerServiceException If a problem occurs when handling the request.
608      * @todo Refactor this to handle path, and create missing folders.
609      *
610      */
611     public FileProperty[] addNode(String ivorn, String name, String type)
612         throws FileManagerServiceException, DuplicateNodeException, NodeNotFoundException
613         {
614         log.debug("");
615         log.debug("FileManagerMock.addNode(String, String, String)");
616         log.debug("  Parent : " + ivorn);
617         log.debug("  Name   : " + name);
618         log.debug("  Type   : " + type);
619         if (null == ivorn)
620             {
621             throw new IllegalArgumentException(
622                 "Null parent identifier"
623                 ) ;
624             }
625         //
626         // Parse the parent ivorn.
627         String ident = null ;
628         try {
629             ident = new FileManagerIvornParser(
630                 ivorn
631                 ).getResourceIdent();
632             }
633         catch (FileManagerIdentifierException ouch)
634             {
635             throw new NodeNotFoundException(
636                 "Unable to parse parent identifier"
637                 );
638             }
639         //
640         // Get the parent node.
641         FileManagerStoreNode node = store.getNode(ident) ;
642         //
643         // If we found the parent node.
644         if (null != node)
645             {
646             //
647             // If the node is a container 
648             if (node.isContainer())
649                 {
650                 FileManagerStoreNode child = this.addNode(
651                     node,
652                     name,
653                     type
654                     ) ;
655                 return child.getProperties().toArray() ;
656                 }
657             //
658             // If the node isn't a container.
659             else {
660                 throw new UnsupportedOperationException(
661                     "Parent must be a container"
662                     );
663                 }
664             }
665         //
666         // If we didn't find the parent node.
667         else {
668             throw new NodeNotFoundException() ;
669             }
670         }
671 
672     /***
673      * Add a new child node.
674      * @param parent The parent node.
675      * @param path   The new node name (and path).
676      * @param type   The new node type.
677      * @return The new node.
678      * @throws DuplicateNodeException If a node with the same name already exists.
679      * @throws NodeNotFoundException If the parent node does not exist.
680      * @throws FileManagerServiceException If a problem occurs when handling the request.
681      * @todo Refactor this to handle path, and create missing folders.
682      *
683      */
684     protected FileManagerStoreNode addNode(FileManagerStoreNode parent, String name, String type)
685         throws FileManagerServiceException, DuplicateNodeException
686         {
687         log.debug("");
688         log.debug("FileManagerMock.addNode(Node, String, String)");
689         log.debug("  Name   : " + name);
690         log.debug("  Type   : " + type);
691         if (null == parent)
692             {
693             log.debug("  Parent : -");
694             }
695         else {
696             log.debug("  Parent : " + parent.getIdent());
697             log.debug("  Parent : " + parent.getName());
698             }
699         if (null == name)
700             {
701             throw new IllegalArgumentException(
702                 "Null name"
703                 ) ;
704             }
705         if (null == type)
706             {
707             throw new IllegalArgumentException(
708                 "Null type"
709                 ) ;
710             }
711         try {
712             //
713             // Create the new node.
714             FileManagerStoreNode node = store.addNode(
715                 (null != parent) ? parent.getIvorn() : null ,
716                 factory.ivorn(
717                     config.getFileManagerIvorn()
718                     ),
719                 name,
720                 type
721                 );
722             //
723             // If it is a data node.
724             if (node.isDataNode())
725                 {
726                 //
727                 // Set the default location.
728                 node.getProperties().setManagerLocationIvorn(
729                     config.getFileStoreIvorn()
730                     );
731                 }
732             //
733             // Add the child to the parent.
734             if (null != parent)
735                 {
736                 parent.addNode(
737                     node
738                     ) ;
739                 }
740             //
741             // Return the new node.
742             return node ;
743             }
744         catch (FileManagerIdentifierException ouch)
745             {
746             log.debug("Unable to create node identifier");
747             log.debug("Exception : " + ouch);
748             throw new FileManagerServiceException(
749                 "Unable to create node identifier"
750                 );
751             }
752         }
753 
754     /***
755      * Template for generating an array of strings.
756      *
757      */
758     private static final String[] template = new String[0] ;
759 
760     /***
761      * Get a list of the children of a specific node.
762      * @param ivorn The parent node (ivorn) identifier.
763      * @return An array of ivorn(s) for the child node(s).
764      * @throws NodeNotFoundException If the parent node does not exist.
765      * @throws FileManagerServiceException If a problem occurs when handling the request.
766      * @todo Refactor this to listNodes(ivorn, [path])
767      *
768      */
769     public String[] getChildren(String ivorn)
770         throws FileManagerServiceException, NodeNotFoundException
771         {
772         log.debug("");
773         log.debug("FileManagerMock.getChildren(String)");
774         log.debug("  Ivorn : " + ivorn);
775         if (null == ivorn)
776             {
777             throw new IllegalArgumentException(
778                 "Null parent identifier"
779                 ) ;
780             }
781         //
782         // Parse the parent ivorn.
783         String ident = null ;
784         try {
785             ident = new FileManagerIvornParser(
786                 ivorn
787                 ).getResourceIdent();
788             }
789         catch (FileManagerIdentifierException ouch)
790             {
791             throw new NodeNotFoundException(
792                 "Unable to parse parent identifier"
793                 );
794             }
795         //
796         // Check if the node exists.
797         if (store.hasNode(ident))
798             {
799             //
800             // Get the parent node.
801             FileManagerStoreNode node = store.getNode(ident) ;
802             log.debug("");
803             log.debug("  Node : " + node.getName());
804             log.debug("  Node : " + node.getIdent());
805             //
806             // Create an array of the child nodes.
807             Collection nodes = node.getChildren() ;
808             Iterator   iter  = nodes.iterator() ;
809             Vector    vector = new Vector();
810             while(iter.hasNext())
811                 {
812                 try {
813                     Ivorn child = ((FileManagerStoreNode) iter.next()).getIvorn();
814                     if (null != child)
815                         {
816                         vector.add(
817                             child.toString()
818                             );
819                         }
820                     }
821                 catch (FileManagerIdentifierException ouch)
822                     {
823                     log.warn("Unable to parse child node ivorn");
824                     }
825                 }
826             String[] array = (String[]) vector.toArray(
827                 template
828                 );
829             return array ;
830             }
831         //
832         // If the node does not exist.
833         else {
834             throw new NodeNotFoundException() ;
835             }
836         }
837 
838     /***
839      * Resolve a filestore.
840      * @param ivorn The file store ivorn.
841      * @return A delegate interface for the filestore.
842      * @throws FileManagerServiceException If unbale to resolve the filestore.
843      * @todo Ping the filestore to check it is available ?
844      *
845      */
846     protected FileStoreDelegate resolve(Ivorn ivorn)
847         throws FileManagerServiceException
848         {
849         try {
850             return resolver.resolve(
851                 ivorn
852                 ) ;
853             }
854         catch (Exception ouch)
855             {
856             log.debug("Exception thrown by FileStoreResolver.resolve()");
857             log.debug("  Exception : " + ouch);
858             throw new FileManagerServiceException(
859                 "Unable to locate FileStore service"
860                 );
861             }
862         }
863 
864     /***
865      * Initialise a data transfer into a FileStore.
866      * The request properties need to specify the (ivorn) identifier of an existing node, or the identifier of a parent node and the new node name and path.
867      * @param request The request properties.
868      * @throws NodeNotFoundException If the target node does not exist.
869      * @throws FileManagerServiceException If a problem occurs when handling the request.
870      * @todo Refactor this to handle path, and create missing folders.
871      *
872      */
873     public TransferProperties importInit(FileProperty[] request)
874         throws FileManagerServiceException, NodeNotFoundException
875         {
876         log.debug("");
877         log.debug("FileManagerMock.importInit(FileProperty[])");
878         if (null == request)
879             {
880             throw new NodeNotFoundException(
881                 "Null request properties"
882                 ) ;
883             }
884         //
885         // Wrap the request properties.
886         FileManagerProperties properties = new FileManagerProperties(
887             request
888             );
889         //
890         // Parse the node identifier.
891         String ident = null ;
892         try {
893             ident = properties.getManagerResourceIdent();
894             }
895         catch (FileManagerIdentifierException ouch)
896             {
897             throw new NodeNotFoundException(
898                 "Unable to parse node identifier"
899                 );
900             }
901         //
902         // If we don't have a node identifier.
903         if (null == ident)
904             {
905             throw new NodeNotFoundException(
906                 "Null node identifier"
907                 );
908             }
909         //
910         // If we have a node identifier.
911         else {
912             //
913             // Check if the node exists.
914             if (store.hasNode(ident))
915                 {
916                 FileManagerStoreNode node = store.getNode(ident) ;
917                 log.debug("");
918                 log.debug("  Node : " + node.getName());
919                 log.debug("  Node : " + node.getIdent());
920                 //
921                 // Initiate the transfer.
922                 return this.importInit(
923                     node,
924                     properties
925                     ) ;
926                 }
927             //
928             // If the node does not exist.
929             else {
930                 throw new NodeNotFoundException();
931                 }
932             }
933         }
934 
935     /***
936      * Initialise a data transfer into a FileStore.
937      * The request properties need to specify the (ivorn) identifier of an existing node, or the identifier of a parent node and the new node name and path.
938      * @param node    The target node.
939      * @param request The request properties.
940      * @throws NodeNotFoundException If the target node does not exist.
941      * @throws FileManagerServiceException If a problem occurs when handling the request.
942      *
943      */
944     protected TransferProperties importInit(FileManagerStoreNode node, FileManagerProperties request)
945         throws FileManagerServiceException, NodeNotFoundException
946         {
947         log.debug("");
948         log.debug("FileManagerMock.importInit(Node, Properties)");
949         log.debug("  Node : " + node.getName());
950         log.debug("  Node : " + node.getIdent());
951         //
952         // Check the node is a data node.
953         if (node.isDataNode() != true)
954             {
955             throw new FileManagerServiceException(
956                 "Invalid operation, not a data node"
957                 );
958             }
959         //
960         // Get the current node properties.
961         FileManagerProperties current = node.getProperties();
962         //
963         // Check for an impled move
964         // request.filemanager.name   != current.filemanager.name
965         // request.filemanager.name   != current.filemanager.type
966         // request.filemanager.parent != current.filemanager.parent
967 
968         //
969         // Get the current location.
970         Ivorn target = null ;
971         try {
972             target = current.getStoreResourceIvorn() ;
973             }
974         catch (FileStoreIdentifierException ouch)
975             {
976             log.warn("");
977             log.warn("Unable to parse store location");
978             log.warn(ouch);
979             throw new FileManagerServiceException(
980                 "Unable to parse store location"
981                 );
982             }
983         //
984         // If the node has already been stored.
985         if (null != target)
986             {
987             //
988             // Use the current store location.
989             request.setStoreResourceIvorn(
990                 target
991                 );
992             }
993         //
994         // If the node has not been stored yet.
995         else {
996             //
997             // Use the node location.
998             try {
999                 target = current.getManagerLocationIvorn();
1000                 }
1001             catch (FileManagerIdentifierException ouch)
1002                 {
1003                 log.warn("");
1004                 log.warn("Unable to parse store location");
1005                 log.warn(ouch);
1006                 throw new FileManagerServiceException(
1007                     "Unable to parse store location"
1008                     );
1009                 }
1010             //
1011             // If the target location is still null.
1012             if (null == target)
1013                 {
1014                 //
1015                 // Use the default filestore.
1016                 target = config.getFileStoreIvorn() ;
1017                 }
1018             }
1019         //
1020         // Update the request properties.
1021         try {
1022             request.setManagerResourceIvorn(
1023                 current.getManagerResourceIvorn()
1024                 );
1025             }
1026         catch (FileManagerIdentifierException ouch)
1027             {
1028             log.warn("");
1029             log.warn("Unable to set resource ivorn");
1030             log.warn(ouch);
1031             throw new FileManagerServiceException(
1032                 "Unable to parse resource ivorn"
1033                 );
1034             }
1035         try {
1036             request.setManagerParentIvorn(
1037                 current.getManagerParentIvorn()
1038                 );
1039             }
1040         catch (FileManagerIdentifierException ouch)
1041             {
1042             log.warn("");
1043             log.warn("Unable to set parent ivorn");
1044             log.warn(ouch);
1045             throw new FileManagerServiceException(
1046                 "Unable to parse parent ivorn"
1047                 );
1048             }
1049         request.setManagerResourceName(
1050             current.getManagerResourceName()
1051             );
1052         request.setManagerResourceType(
1053             current.getManagerResourceType()
1054             );
1055         //
1056         // Resolve the target filestore.
1057         FileStoreDelegate filestore = resolve(
1058             target
1059             ) ;
1060         //
1061         // Call the filestore to initiate the transfer.
1062         TransferProperties transfer = null ;
1063         try {
1064             transfer = 
1065                 filestore.importInit(
1066                     new UrlPutTransfer(
1067                         request
1068                         )
1069                     ) ;
1070             }
1071         catch (Exception ouch)
1072             {
1073             log.debug("Exception thrown by FileStore.importInit()");
1074             log.debug("  Exception : " + ouch);
1075             throw new FileManagerServiceException(
1076                 "Error occurred when calling FileStore service"
1077                 );
1078             }
1079         //
1080         // Get the response properties.
1081         FileManagerProperties response = new FileManagerProperties(
1082             transfer.getFileProperties()
1083             ) ;
1084         //
1085         // Update the response properties.
1086         // This repairs any changes to the manager properties made by the filestore.
1087         try {
1088             response.setManagerResourceIvorn(
1089                 current.getManagerResourceIvorn()
1090                 );
1091             }
1092         catch (FileManagerIdentifierException ouch)
1093             {
1094             log.warn("");
1095             log.warn("Unable to set resource ivorn");
1096             log.warn(ouch);
1097             throw new FileManagerServiceException(
1098                 "Unable to parse resource ivorn"
1099                 );
1100             }
1101         try {
1102             response.setManagerParentIvorn(
1103                 current.getManagerParentIvorn()
1104                 );
1105             }
1106         catch (FileManagerIdentifierException ouch)
1107             {
1108             log.warn("");
1109             log.warn("Unable to set parent ivorn");
1110             log.warn(ouch);
1111             throw new FileManagerServiceException(
1112                 "Unable to parse parent ivorn"
1113                 );
1114             }
1115         response.setManagerResourceName(
1116             current.getManagerResourceName()
1117             );
1118         response.setManagerResourceType(
1119             current.getManagerResourceType()
1120             );
1121         //
1122         // Update the store location.
1123         try {
1124             response.setManagerLocationIvorn(
1125                 response.getStoreServiceIvorn()
1126                 );
1127             }
1128         catch (FileStoreIdentifierException ouch)
1129             {
1130             log.warn("");
1131             log.warn("Unable to set location ivorn");
1132             log.warn(ouch);
1133             response.setManagerLocationIvorn(
1134                 target
1135                 );
1136             }
1137         //
1138         // Save these as the new properties.
1139         node.setProperties(
1140             response
1141             ) ;
1142         //
1143         // Update the transfer properties.
1144         transfer.setFileProperties(
1145             response
1146             );
1147         return transfer ;
1148         }
1149 
1150     /***
1151      * Initialise a data transfer from a FileStore.
1152      * This calls the FileStore to request the HTTP (GET) URL to read the data from the FileStore.
1153      * @param request The request properties.
1154      * @throws NodeNotFoundException If the target node does not exist.
1155      * @throws FileManagerServiceException If a problem occurs when handling the request.
1156      *
1157      */
1158     public TransferProperties exportInit(FileProperty[] request)
1159         throws FileManagerServiceException, NodeNotFoundException
1160         {
1161         log.debug("");
1162         log.debug("FileManagerMock.exportInit(FileProperty[])");
1163         if (null == request)
1164             {
1165             throw new NodeNotFoundException(
1166                 "Null request properties"
1167                 ) ;
1168             }
1169         //
1170         // Wrap the request properties.
1171         FileManagerProperties properties = new FileManagerProperties(
1172             request
1173             );
1174         //
1175         // Parse the node identifier.
1176         String ident = null ;
1177         try {
1178             ident = properties.getManagerResourceIdent() ;
1179             }
1180         catch (FileManagerIdentifierException ouch)
1181             {
1182             throw new NodeNotFoundException(
1183                 "Unable to parse resource ivorn"
1184                 );
1185             }
1186         //
1187         // If we don't have a node identifier.
1188         if (null == ident)
1189             {
1190             throw new NodeNotFoundException(
1191                 "Null node identifier"
1192                 );
1193             }
1194         //
1195         // If we have a node identifier.
1196         else {
1197             //
1198             // Check if the node exists.
1199             if (store.hasNode(ident))
1200                 {
1201                 FileManagerStoreNode node = store.getNode(ident) ;
1202                 log.debug("");
1203                 log.debug("  Node : " + node.getName());
1204                 log.debug("  Node : " + node.getIdent());
1205                 //
1206                 // Initiate the transfer.
1207                 return this.exportInit(
1208                     node,
1209                     properties
1210                     ) ;
1211                 }
1212             //
1213             // If the node does not exist.
1214             else {
1215                 throw new NodeNotFoundException();
1216                 }
1217             }
1218         }
1219 
1220     /***
1221      * Initialise a data transfer from a FileStore.
1222      * This calls the FileStore to request the HTTP (GET) URL to read the data from the FileStore.
1223      * @param node    The target node.
1224      * @param request The request properties.
1225      * @throws NodeNotFoundException If the target node does not exist.
1226      * @throws FileManagerServiceException If a problem occurs when handling the request.
1227      *
1228      */
1229     protected TransferProperties exportInit(FileManagerStoreNode node, FileManagerProperties request)
1230         throws FileManagerServiceException, NodeNotFoundException
1231         {
1232         log.debug("");
1233         log.debug("FileManagerMock.exportInit(Node, Properties)");
1234         log.debug("  Node : " + node.getName());
1235         log.debug("  Node : " + node.getIdent());
1236         //
1237         // Get the current node properties.
1238         FileManagerProperties current = node.getProperties();
1239         //
1240         // Check for an impled move
1241         // request.filemanager.name   != current.filemanager.name
1242         // request.filemanager.name   != current.filemanager.type
1243         // request.filemanager.parent != current.filemanager.parent
1244         //
1245         // Get the current location.
1246         Ivorn target = null ;
1247         try {
1248             target = current.getStoreResourceIvorn() ;
1249             }
1250         catch (FileStoreIdentifierException ouch)
1251             {
1252             throw new FileManagerServiceException(
1253                 "Unable to parse current filestore ivorn"
1254                 );
1255             }
1256         //
1257         // If the node has already been stored.
1258         if (null != target)
1259             {
1260             //
1261             // Override the request location.
1262             request.setStoreResourceIvorn(
1263                 target
1264                 );
1265             }
1266         //
1267         // If the node has not been stored yet.
1268         else {
1269             throw new NodeNotFoundException(
1270                 "Node does not have any data"
1271                 );
1272             }
1273         //
1274         // Update the request properties.
1275         try {
1276             request.setManagerResourceIvorn(
1277                 current.getManagerResourceIvorn()
1278                 );
1279             }
1280         catch (FileManagerIdentifierException ouch)
1281             {
1282             throw new FileManagerServiceException(
1283                 "Unable to parse resource ivorn"
1284                 );
1285             }
1286         try {
1287             request.setManagerParentIvorn(
1288                 current.getManagerParentIvorn()
1289                 );
1290             }
1291         catch (FileManagerIdentifierException ouch)
1292             {
1293             throw new FileManagerServiceException(
1294                 "Unable to parse parent ivorn"
1295                 );
1296             }
1297         request.setManagerResourceName(
1298             current.getManagerResourceName()
1299             );
1300         request.setManagerResourceType(
1301             current.getManagerResourceType()
1302             );
1303         //
1304         // Resolve the target filestore.
1305         FileStoreDelegate filestore = resolve(target) ;
1306         //
1307         // Call the filestore to initiate the transfer.
1308         TransferProperties transfer = null ;
1309         try {
1310             transfer = 
1311                 filestore.exportInit(
1312                     new UrlGetRequest(
1313                         request
1314                         )
1315                     ) ;
1316             }
1317         catch (Exception ouch)
1318             {
1319             log.debug("Exception thrown by FileStore.importInit()");
1320             log.debug("  Exception : " + ouch);
1321             throw new FileManagerServiceException(
1322                 "Error occurred when calling FileStore service"
1323                 );
1324             }
1325         //
1326         // Get the response properties.
1327         FileManagerProperties response = new FileManagerProperties(
1328             transfer.getFileProperties()
1329             ) ;
1330         //
1331         // Update the response properties.
1332         // This repairs any changes to the manager properties made by the filestore.
1333         try {
1334             response.setManagerResourceIvorn(
1335                 current.getManagerResourceIvorn()
1336                 );
1337             }
1338         catch (FileManagerIdentifierException ouch)
1339             {
1340             throw new FileManagerServiceException(
1341                 "Unable to parse resource ivorn"
1342                 );
1343             }
1344         try {
1345             response.setManagerParentIvorn(
1346                 current.getManagerParentIvorn()
1347                 );
1348             }
1349         catch (FileManagerIdentifierException ouch)
1350             {
1351             throw new FileManagerServiceException(
1352                 "Unable to parse parent ivorn"
1353                 );
1354             }
1355         response.setManagerResourceName(
1356             current.getManagerResourceName()
1357             );
1358         response.setManagerResourceType(
1359             current.getManagerResourceType()
1360             );
1361         //
1362         // Save these as the new properties.
1363         node.setProperties(
1364             response
1365             ) ;
1366         //
1367         // Update the transfer properties.
1368         transfer.setFileProperties(
1369             response
1370             );
1371         return transfer ;
1372         }
1373 
1374     /***
1375      * Move a node to a new location.
1376      * If the node already has stored data, then this may involve transfering the data to a new location.
1377      * @param  request The request properties.
1378      * @return A new set of properties for the node.
1379      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
1380      * @throws NodeNotFoundException If the current node is no longer in the database.
1381      * @throws NodeNotFoundException If the new parent node is no longer in the database.
1382      * @throws FileManagerServiceException If a problem occurs when handling the request.
1383      *
1384      */
1385     public FileProperty[] move(FileProperty[] request)
1386         throws FileManagerServiceException, DuplicateNodeException, NodeNotFoundException
1387         {
1388         log.debug("");
1389         log.debug("FileManagerMock.move(FileProperty[])");
1390         if (null == request)
1391             {
1392             throw new NodeNotFoundException(
1393                 "Null request properties"
1394                 ) ;
1395             }
1396         //
1397         // Wrap the request properties.
1398         FileManagerProperties properties = new FileManagerProperties(
1399             request
1400             );
1401         //
1402         // Parse the node ivorn.
1403         Ivorn ivorn = null ;
1404         try {
1405             ivorn = properties.getManagerResourceIvorn();
1406             }
1407         catch (FileManagerIdentifierException ouch)
1408             {
1409             throw new NodeNotFoundException(
1410                 "Unable to parse node ivorn"
1411                 );
1412             }
1413         //
1414         // Initiate the transfer.
1415         return this.move(
1416             this.node(
1417                 ivorn
1418                 ),
1419             properties
1420             ) ;
1421         }
1422 
1423     /***
1424      * Move a node to a new location.
1425      * If the node already has stored data, then this may involve transfering the data to a new location.
1426      * @param  node    The target node.
1427      * @param  request The request properties.
1428      * @return A new set of properties for the node.
1429      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
1430      * @throws NodeNotFoundException If the new parent node is no longer in the database.
1431      * @throws FileManagerServiceException If a problem occurs when handling the request.
1432      *
1433      */
1434     public FileProperty[] move(FileManagerStoreNode node, FileManagerProperties request)
1435         throws DuplicateNodeException, NodeNotFoundException, FileManagerServiceException
1436         {
1437         log.debug("");
1438         log.debug("FileManagerMock.move(Node, FileManagerProperties)");
1439         log.debug("  Node : " + node.getName());
1440         log.debug("  Node : " + node.getIdent());
1441         //
1442         // Get the current node properties.
1443         FileManagerProperties current = node.getProperties();
1444         //
1445         // Get the set of changed properties.
1446         FileManagerProperties changed = current.difference(
1447             request
1448             );
1449         //
1450         // Get the target parent node.
1451         Ivorn dest = null ;
1452         try {
1453             dest = changed.getManagerParentIvorn();
1454             }
1455         catch (FileManagerIdentifierException ouch)
1456             {
1457             throw new NodeNotFoundException(
1458                 "Unable to parse node ivorn"
1459                 );
1460             }
1461         //
1462         // Get the target node name.
1463         String name = changed.getManagerResourceName();
1464         //
1465         // If the node name or parent have changed.
1466         if ((null != name) || (null != dest))
1467             {
1468             this.moveNode(
1469                 node,
1470                 name,
1471                 dest
1472                 );
1473             }
1474         //
1475         // Get the target store location.
1476         Ivorn store = null ;
1477         try {
1478             store = changed.getManagerLocationIvorn();
1479             }
1480         catch (FileManagerIdentifierException ouch)
1481             {
1482             throw new NodeNotFoundException(
1483                 "Unable to parse store ivorn"
1484                 );
1485             }
1486         //
1487         // If the node location has changed.
1488         if (null != store)
1489             {
1490             this.moveStore(
1491                 node,
1492                 store
1493                 );
1494             }
1495         //
1496         // Return the new node properties.
1497         return node.getProperties().toArray();
1498         }
1499 
1500     /***
1501      * Move a node in the tree.
1502      * @param node The node to move.
1503      * @param name The new name for the node.
1504      * @param dest The (ivorn) identifier of the new parent.
1505      * @return The updated node.
1506      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
1507      * @throws NodeNotFoundException If the new parent node is no longer in the database.
1508      * @throws FileManagerServiceException If a problem occurs when handling the request.
1509      *
1510      */
1511     protected void moveNode(FileManagerStoreNode node, String name, Ivorn dest)
1512         throws FileManagerServiceException, DuplicateNodeException, NodeNotFoundException
1513         {
1514         log.debug("");
1515         log.debug("FileManagerMock.move(Node, String, Ivorn)");
1516         log.debug("  Node : " + node.getName());
1517         log.debug("  Node : " + node.getIdent());
1518         log.debug("  Name : " + name);
1519         log.debug("  Dest : " + ((null != dest) ? dest.toString() : "null"));
1520         //
1521         // If the destination parent is set.
1522         if (null != dest)
1523             {
1524             //
1525             // Locate the destination node and use that.
1526             this.moveNode(
1527                 node,
1528                 name,
1529                 this.node(
1530                     dest
1531                     )
1532                 );
1533             }
1534         //
1535         // If the destination parent is not set.
1536         else {
1537             //
1538             // Locate the current parent and use that.
1539             FileManagerStoreNode parent = null ;
1540             try {
1541                 parent = this.node(
1542                     node.getParentIvorn()
1543                     );
1544                 }
1545             catch (FileManagerIdentifierException ouch)
1546                 {
1547                 throw new FileManagerServiceException(
1548                     "Unable to oarse parent node ivorn"
1549                     );
1550                 }
1551             this.moveNode(
1552                 node,
1553                 name,
1554                 parent
1555                 );
1556             }
1557         }
1558 
1559     /***
1560      * Move a node in the tree.
1561      * @param node The node to move.
1562      * @param name The new name for the node.
1563      * @param dest The new parent node.
1564      * @return The updated node.
1565      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
1566      * @throws FileManagerServiceException If a problem occurs when handling the request.
1567      *
1568      */
1569     protected void moveNode(FileManagerStoreNode node, String name, FileManagerStoreNode dest)
1570         throws FileManagerServiceException, DuplicateNodeException
1571         {
1572         log.debug("");
1573         log.debug("FileManagerMock.moveNode(Node, String, Node)");
1574         log.debug("  Node : " + node.getName());
1575         log.debug("  Node : " + node.getIdent());
1576         log.debug("  Name : " + name);
1577         log.debug("  Dest : " + dest.getName());
1578         log.debug("  Dest : " + dest.getIdent());
1579         //
1580         // Get the current parent.
1581         FileManagerStoreNode parent = null;
1582         try {
1583             parent = this.node(
1584                 node.getParentIvorn()
1585                 );
1586             }
1587         catch (FileManagerIdentifierException ouch)
1588             {
1589             throw new FileManagerServiceException(
1590                 "Unable to parse parent node identifier"
1591                 );
1592             }
1593         catch (NodeNotFoundException ouch)
1594             {
1595             throw new FileManagerServiceException(
1596                 "Unable to locate parent node"
1597                 );
1598             }
1599         //
1600         // Keep a record of the old name.
1601         String prev = node.getName();
1602         //
1603         // If the name has changed.
1604         if (null != name)
1605             {
1606             //
1607             // Check the name does not contain a '/'.
1608             if (name.indexOf('/') != -1)
1609                 {
1610                 throw new FileManagerServiceException(
1611                     "Node name cannot contain '/'"
1612                     );
1613                 }
1614             node.setName(
1615                 name
1616                 );
1617             }
1618         //
1619         // Add the node into the new parent.
1620         try {
1621             dest.addNode(
1622                 node
1623                 );
1624             }
1625         catch (DuplicateNodeException ouch)
1626             {
1627             //
1628             // Put the name back to what it was.
1629             node.setName(
1630                 prev
1631                 );
1632             //
1633             // Re-throw the Exception.
1634             throw ouch ;
1635             }
1636         //
1637         // Remove the node from the old parent.
1638         try {
1639             parent.delNode(
1640                 prev
1641                 );
1642             }
1643         catch (NodeNotFoundException ouch)
1644             {
1645             //
1646             // Log the error.
1647             log.warn("");
1648             log.warn("Move failed to remove node from original parent");
1649             log.warn("Parent : " + parent.getIdent());
1650             log.warn("Child  : " + node.getIdent());
1651             }
1652         }
1653 
1654     /***
1655      * Get a node from our map.
1656      * @param ivorn The node (ivorn) identifier.
1657      * @throws NodeNotFoundException If the node is not in the database.
1658      * @throws FileManagerServiceException If a problem occurs when handling the request.
1659      *
1660      */
1661     private FileManagerStoreNode node(Ivorn ivorn)
1662         throws NodeNotFoundException, FileManagerServiceException
1663         {
1664         try {
1665             return this.node(
1666                 new FileManagerIvornParser(
1667                     ivorn
1668                     ).getResourceIdent()
1669                 );
1670             }
1671         catch (FileManagerIdentifierException ouch)
1672             {
1673             throw new NodeNotFoundException(
1674                 "Unable to parse node ivorn"
1675                 ) ;
1676             }
1677         }
1678 
1679     /***
1680      * Get a node from our map.
1681      * @param ident The node identifier.
1682      * @throws NodeNotFoundException If the node is not in the database.
1683      * @throws FileManagerServiceException If a problem occurs when handling the request.
1684      *
1685      */
1686     private FileManagerStoreNode node(String ident)
1687         throws NodeNotFoundException, FileManagerServiceException
1688         {
1689         if (null != ident)
1690             {
1691             if (store.hasNode(ident))
1692                 {
1693                 return store.getNode(ident) ;
1694                 }
1695             else {
1696                 throw new NodeNotFoundException(
1697                     "Unable to locate node"
1698                     ) ;
1699                 }
1700             }
1701         else {
1702             throw new NodeNotFoundException(
1703                 "Null node identifier"
1704                 ) ;
1705             }
1706         }
1707 
1708     /***
1709      * Move a file from one location to another.
1710      * @param node The node to move.
1711      * @param targetIvorn The destination filestore (ivorn) identifier).
1712      * @throws DuplicateNodeException If the target node already exists.
1713      * @throws NodeNotFoundException If the current node does not exist.
1714      * @throws NodeNotFoundException If the target parent node does not exist.
1715      * @throws FileManagerServiceException If a problem occurs when handling the request.
1716      *
1717      */
1718     protected void moveStore(FileManagerStoreNode node, Ivorn targetIvorn)
1719         throws DuplicateNodeException, NodeNotFoundException, FileManagerServiceException
1720         {
1721         log.debug("");
1722         log.debug("FileManagerMock.moveStore(Node, Ivorn)");
1723         log.debug("  Node  : " + node.getName());
1724         log.debug("  Node  : " + node.getIdent());
1725         log.debug("  Dest  : " + targetIvorn.toString());
1726         //
1727         // If the node is a data node.
1728         if (node.isDataNode())
1729             {
1730             log.debug("");
1731             log.debug("  PASS  : Node is a data node");
1732             //
1733             // Get the current node properties.
1734             FileManagerProperties current = node.getProperties();
1735             //
1736             // Get the current store location.
1737             Ivorn  sourceIvorn = null ;
1738             String sourceIdent = null ;
1739             try {
1740                 sourceIvorn = current.getStoreResourceIvorn() ;
1741                 sourceIdent = current.getStoreResourceIdent() ;
1742                 }
1743             catch (FileStoreIdentifierException ouch)
1744                 {
1745                 log.warn("");
1746                 log.warn("Unable to parse current store resource ivorn");
1747                 log.warn(ouch);
1748                 throw new FileManagerServiceException(
1749                     "Unable to parse current store resource ivorn"
1750                     );
1751                 }
1752             //
1753             // If the node has some stored data.
1754             if (null != sourceIvorn)
1755                 {
1756                 log.debug("");
1757                 log.debug("  PASS  : Got store resource ivorn");
1758                 log.debug("  Ivorn : " + sourceIvorn.toString());
1759                 //
1760                 // Resolve the source filestore
1761                 FileStoreDelegate sourceStore = resolve(
1762                     sourceIvorn
1763                     ) ;
1764                 log.debug("  PASS  : Got source filestore");
1765                 //
1766                 // Resolve the target filestore
1767                 FileStoreDelegate targetStore = resolve(
1768                     targetIvorn
1769                     ) ;
1770                 log.debug("  PASS  : Got target filestore");
1771                 //
1772                 // Initiate the transfer from the source store.
1773                 TransferProperties transfer = null ;
1774                 try {
1775                     transfer = 
1776                         sourceStore.exportInit(
1777                             new UrlGetRequest(
1778                                 current
1779                                 )
1780                             ) ;
1781                     }
1782                 catch (Exception ouch)
1783                     {
1784                     log.debug("Exception thrown by FileStore.importInit()");
1785                     log.debug("  Exception : " + ouch);
1786                     throw new FileManagerServiceException(
1787                         "Error occurred when calling FileStore service"
1788                         );
1789                     }
1790                 //
1791                 // Transfer the data into the destination store.
1792                 TransferProperties result = null ;
1793                 try {
1794                     result = 
1795                         targetStore.importData(
1796                             transfer
1797                             ) ;
1798                     }
1799                 catch (Exception ouch)
1800                     {
1801                     log.debug("Exception thrown by FileStore.importInit()");
1802                     log.debug("  Exception : " + ouch);
1803                     throw new FileManagerServiceException(
1804                         "Error occurred when calling FileStore service"
1805                         );
1806                     }
1807                 //
1808                 // Update the local properties.
1809                 current.merge(
1810                     result.getFileProperties(),
1811                     new FileManagerPropertyFilter()
1812                     );
1813                 //
1814                 // Set the store location.
1815                 current.setManagerLocationIvorn(
1816                     targetIvorn
1817                     );
1818                 //
1819                 // Remove the data from the original store.
1820                 try {
1821                     sourceStore.delete(
1822                         sourceIdent
1823                         ) ;
1824                     }
1825                 catch (Exception ouch)
1826                     {
1827                     log.warn("Exception thrown by FileStore.delete()");
1828                     log.warn("  Exception : " + ouch);
1829 //
1830 // Ignore any problems with the delete.
1831 // If the data has moved to the new server, then we shouldn't throw an Exception.
1832 //                    throw new FileManagerServiceException(
1833 //                        "Error occurred when calling FileStore service"
1834 //                        );
1835                     }
1836                 }
1837             //
1838             // If the node does not have any stored data yet.
1839             else {
1840                 log.debug("  PASS  : No data stored yet.");
1841                 log.debug("Setting location ivorn");
1842                 log.debug("  Dest  : " + targetIvorn.toString());
1843 //
1844 // Should we try to resolve the filestore, just to check ?
1845 //
1846                 //
1847                 // Update the default store location.
1848                 current.setManagerLocationIvorn(
1849                     targetIvorn
1850                     );
1851                 }
1852             }
1853         //
1854         // If the node is not a data node.
1855         else {
1856             log.debug("");
1857             log.debug("FAIL  : Node is not a data node");
1858             //
1859             // This implies a recursive move for all the child nodes ....
1860             //
1861             throw new UnsupportedOperationException(
1862                 "Container location move not implemented yet"
1863                 );
1864             }
1865         }
1866 
1867     /***
1868      * Create a copy of a node.
1869      * If the node already has stored data, then this will create a new copy of the data.
1870      * @param  request The request properties.
1871      * @return A set of properties for the new node.
1872      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
1873      * @throws NodeNotFoundException If the current node is no longer in the database.
1874      * @throws NodeNotFoundException If the new parent node is no longer in the database.
1875      * @throws FileManagerServiceException If a problem occurs when handling the request.
1876      *
1877      */
1878     public FileProperty[] copy(FileProperty[] request)
1879         throws
1880             NodeNotFoundException,
1881             DuplicateNodeException,
1882             FileManagerServiceException
1883         {
1884         log.debug("");
1885         log.debug("FileManagerMock.copy(FileProperty[])");
1886         if (null == request)
1887             {
1888             throw new NodeNotFoundException(
1889                 "Null request properties"
1890                 ) ;
1891             }
1892         //
1893         // Wrap the request properties.
1894         FileManagerProperties properties = new FileManagerProperties(
1895             request
1896             );
1897         //
1898         // Parse the node ivorn.
1899         Ivorn ivorn = null ;
1900         try {
1901             ivorn = properties.getManagerResourceIvorn();
1902             }
1903         catch (FileManagerIdentifierException ouch)
1904             {
1905             throw new NodeNotFoundException(
1906                 "Unable to parse node ivorn"
1907                 );
1908             }
1909         //
1910         // Copy the node.
1911         return this.copy(
1912             this.node(
1913                 ivorn
1914                 ),
1915             properties
1916             ).getProperties().toArray() ;
1917         }
1918 
1919     /***
1920      * Create a copy of a node.
1921      * If the node already has stored data, then this will create a new copy of the data.
1922      * @param  node    The target node.
1923      * @param  request The request properties.
1924      * @return A set of properties for the new node.
1925      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
1926      * @throws NodeNotFoundException If the new parent node is no longer in the database.
1927      * @throws FileManagerServiceException If a problem occurs when handling the request.
1928      *
1929      */
1930     protected FileManagerStoreNode copy(FileManagerStoreNode node, FileManagerProperties request)
1931         throws DuplicateNodeException, NodeNotFoundException, FileManagerServiceException
1932         {
1933         log.debug("");
1934         log.debug("FileManagerMock.copy(Node, FileManagerProperties)");
1935         log.debug("  Node : " + node.getName());
1936         log.debug("  Node : " + node.getIdent());
1937         //
1938         // Check the node is a data node.
1939         if (node.isDataNode())
1940             {
1941             log.debug("");
1942             log.debug("PASS  : Node is a data node");
1943             //
1944             // Get the current node properties.
1945             FileManagerProperties currentProperties = node.getProperties();
1946             //
1947             // Get the set of changed properties.
1948             FileManagerProperties changedProperties = currentProperties.difference(
1949                 request
1950                 );
1951             //
1952             // Create the target properties.
1953             FileManagerProperties targetProperties = new FileManagerProperties(
1954                 currentProperties
1955                 );
1956             targetProperties.merge(
1957                 request,
1958                 new FileManagerResourceFilter()
1959                 );
1960             //
1961             // Try to find our target parent.
1962             FileManagerStoreNode parentNode = null ;
1963             try {
1964                 parentNode = this.node(
1965                     targetProperties.getManagerParentIvorn()
1966                     );
1967                 }
1968             catch (FileManagerIdentifierException ouch)
1969                 {
1970                 throw new NodeNotFoundException(
1971                     "Unable to parse parent node ivorn"
1972                     );
1973                 }
1974             //
1975             // Try to create the new node.
1976             FileManagerStoreNode resultNode = this.addNode(
1977                 parentNode,
1978                 targetProperties.getManagerResourceName(),
1979                 FileManagerProperties.DATA_NODE_TYPE
1980                 );
1981             log.debug("  PASS  : Created node copy");
1982             //
1983             // Get the new node properties.
1984             FileManagerProperties resultProperties = resultNode.getProperties();
1985             //
1986             // Get the current data location.
1987             Ivorn  currentStoreIvorn = null ;
1988             String currentStoreIdent = null ;
1989             try {
1990                 currentStoreIvorn = currentProperties.getStoreResourceIvorn() ;
1991                 currentStoreIdent = currentProperties.getStoreResourceIdent() ;
1992                 }
1993             catch (FileStoreIdentifierException ouch)
1994                 {
1995                 throw new FileManagerServiceException(
1996                     "Unable to parse current filestore ivorn"
1997                     );
1998                 }
1999             //
2000             // If the node has already been stored.
2001             if (null != currentStoreIvorn)
2002                 {
2003                 log.debug("  PASS  : Node has data");
2004                 //
2005                 // Get the changed data location.
2006                 Ivorn changedLocation = null ;
2007                 try {
2008                     changedLocation = changedProperties.getManagerLocationIvorn() ;
2009                     }
2010                 catch (FileManagerIdentifierException ouch)
2011                     {
2012                     throw new FileManagerServiceException(
2013                         "Unable to parse changed filestore ivorn"
2014                         );
2015                     }
2016                 //
2017                 // If the data location has changed.
2018                 if (null != changedLocation)
2019                     {
2020                     FileStoreDelegate sourceStore = null ;
2021                     FileStoreDelegate targetStore = null ;
2022                     //
2023                     // Resolve the current filestore.
2024                     try {
2025                         sourceStore = resolve(
2026                             currentStoreIvorn
2027                             ) ;
2028                         }
2029                     catch (Exception ouch)
2030                         {
2031                         throw new FileManagerServiceException(
2032                             "Unable to resolve current filestore"
2033                             );
2034                         }
2035                     //
2036                     // Resolve the target filestore.
2037                     try {
2038                         targetStore = resolve(
2039                             changedLocation
2040                             ) ;
2041                         }
2042                     catch (Exception ouch)
2043                         {
2044                         throw new FileManagerServiceException(
2045                             "Unable to resolve target filestore"
2046                             );
2047                         }
2048                     //
2049                     // Initiate the transfer from the source store.
2050                     TransferProperties transfer = null ;
2051                     try {
2052                         transfer = 
2053                             sourceStore.exportInit(
2054                                 new UrlGetRequest(
2055                                     currentProperties
2056                                     )
2057                                 ) ;
2058                         }
2059                     catch (Exception ouch)
2060                         {
2061                         log.debug("Exception thrown by FileStore.importInit()");
2062                         log.debug("  Exception : " + ouch);
2063                         throw new FileManagerServiceException(
2064                             "Unable to initiate data transfer"
2065                             );
2066                         }
2067                     //
2068                     // Transfer the data into the destination store.
2069                     TransferProperties transferResult = null ;
2070                     try {
2071                         transferResult = 
2072                             targetStore.importData(
2073                                 transfer
2074                                 ) ;
2075                         }
2076                     catch (Exception ouch)
2077                         {
2078                         log.debug("Exception thrown by FileStore.importInit()");
2079                         log.debug("  Exception : " + ouch);
2080                         throw new FileManagerServiceException(
2081                             "Unable to complete data transfer"
2082                             );
2083                         }
2084                     //
2085                     // Update the result properties.
2086                     resultProperties.merge(
2087                         transferResult.getFileProperties(),
2088                         new FileManagerPropertyFilter()
2089                         );
2090                     //
2091                     // Set the store location.
2092                     resultProperties.setManagerLocationIvorn(
2093                         changedLocation
2094                         );
2095                     }
2096                 //
2097                 // If the data location has not changed.
2098                 else {
2099                     log.debug("  PASS  : Location not changed");
2100                     //
2101                     // Resolve the current filestore.
2102                     FileStoreDelegate filestore = resolve(
2103                         currentStoreIvorn
2104                         ) ;
2105                     log.debug("  PASS  : Got current filestore");
2106                     //
2107                     // Ask the filestore to duplicate the data.
2108                     try {
2109                         log.debug("  PASS  : Asking filestore for duplicate");
2110                         //
2111                         // Ask the filestore to duplicate the data.
2112                         FileManagerProperties updatedProperties = new FileManagerProperties(
2113                             filestore.duplicate(
2114                                 currentStoreIdent,
2115                                 resultProperties.toArray()
2116                                 )
2117                             );
2118                         log.debug("  PASS  : Got duplicate from filestore");
2119                         //
2120                         // Update the local properties.
2121                         resultProperties.merge(
2122                             updatedProperties,
2123                             new FileManagerPropertyFilter()
2124                             );
2125                         log.debug("  PASS  : Merged updated properties");
2126                         }
2127                     catch(Exception ouch)
2128                         {
2129                         log.warn("Exception thrown by FileStore.duplicate()");
2130                         log.warn("  Exception : " + ouch);
2131 //
2132 // Set a property to indicate the data can't be accessed ?
2133 // Pass the Exception on ?
2134 // Rollback the transaction and delete the new node ?
2135 //
2136                         }
2137                     }
2138                 }
2139             //
2140             // If the node has not been stored yet.
2141             else {
2142                 log.debug("  PASS  : Node is empty");
2143                 //
2144                 // Get the changed data location.
2145                 Ivorn changedLocation = null ;
2146                 try {
2147                     changedLocation = changedProperties.getManagerLocationIvorn() ;
2148                     }
2149                 catch (FileManagerIdentifierException ouch)
2150                     {
2151                     throw new FileManagerServiceException(
2152                         "Unable to parse changed filestore ivorn"
2153                         );
2154                     }
2155                 //
2156                 // If the data location has changed.
2157                 if (null != changedLocation)
2158                     {
2159                     log.debug("  PASS  : Location changed");
2160                     //
2161                     // Set the target location.
2162                     resultProperties.setManagerLocationIvorn(
2163                         changedLocation
2164                         );
2165 //
2166 // Make sure the store ivorn is blank ?
2167 // Should already be, but need to check ...
2168 //
2169                     }
2170                 }
2171             //
2172             // Return the new node properties.
2173             return resultNode ;
2174             }
2175         //
2176         // If the node is not a data node.
2177         else {
2178             log.debug("");
2179             log.debug("FAIL  : Node is not a data node");
2180             //
2181             // This implies a recursive copy for all the child nodes ....
2182             throw new UnsupportedOperationException(
2183                 "Container location copy not implemented yet"
2184                 );
2185             }
2186         }
2187 
2188     /***
2189      * Delete a node.
2190      * @param ivorn The node (ivorn) identifier.
2191      * @throws NodeNotFoundException If the node does not exist.
2192      * @throws FileManagerServiceException If a problem occurs when handling the request.
2193      * @todo Refactor this to take an ivorn.
2194      *
2195      */
2196     public void delete(String ivorn)
2197         throws
2198             NodeNotFoundException,
2199             FileManagerServiceException
2200         {
2201         log.debug("");
2202         log.debug("FileManagerMock.delete(String)");
2203         log.debug("  Ivorn : " + ivorn);
2204         if (null == ivorn)
2205             {
2206             throw new IllegalArgumentException(
2207                 "Null node identifier"
2208                 ) ;
2209             }
2210         //
2211         // Parse the node ivorn.
2212         String ident = null ;
2213         try {
2214             ident = new FileManagerIvornParser(
2215                 ivorn
2216                 ).getResourceIdent();
2217             }
2218         catch (FileManagerIdentifierException ouch)
2219             {
2220             throw new NodeNotFoundException(
2221                 "Unable to parse node identifier"
2222                 );
2223             }
2224         //
2225         // Try to delete the node.
2226         deleteNode(
2227             this.node(
2228                 ident
2229                 )
2230             );
2231         }
2232 
2233     /***
2234      * Delete a node.
2235      * @param node The node to delete.
2236      * @throws NodeNotFoundException If the node does not exist.
2237      * @throws FileManagerServiceException If a problem occurs when handling the request.
2238      *
2239      */
2240     protected void deleteNode(FileManagerStoreNode node)
2241         throws NodeNotFoundException, FileManagerServiceException
2242         {
2243         log.debug("");
2244         log.debug("FileManagerMock.delete(Node)");
2245         log.debug("  Node : " + node.getName());
2246         log.debug("  Node : " + node.getIdent());
2247         //
2248         // Get the node parent.
2249         FileManagerStoreNode parent = null;
2250         try {
2251             parent = this.node(
2252                 node.getParentIvorn()
2253                 );
2254             }
2255         catch (FileManagerIdentifierException ouch)
2256             {
2257             throw new FileManagerServiceException(
2258                 "Unable to parse parent node identifier"
2259                 );
2260             }
2261         catch (NodeNotFoundException ouch)
2262             {
2263             throw new FileManagerServiceException(
2264                 "Unable to locate parent node"
2265                 );
2266             }
2267         //
2268         // If the node is a data node.
2269         if (node.isDataNode())
2270             {
2271             log.debug("");
2272             log.debug("PASS  : Node is a data node");
2273             //
2274             // Get the current node properties.
2275             FileManagerProperties current = node.getProperties();
2276             //
2277             // Get the current store location.
2278             Ivorn  sourceIvorn = null ;
2279             String sourceIdent = null ;
2280             try {
2281                 sourceIvorn = current.getStoreResourceIvorn() ;
2282                 sourceIdent = current.getStoreResourceIdent() ;
2283                 }
2284             catch (FileStoreIdentifierException ouch)
2285                 {
2286                 log.warn("");
2287                 log.warn("Unable to parse current store resource ivorn");
2288                 log.warn(ouch);
2289                 throw new FileManagerServiceException(
2290                     "Unable to parse current store resource ivorn"
2291                     );
2292                 }
2293             //
2294             // If the node has some stored data.
2295             if (null != sourceIvorn)
2296                 {
2297                 log.debug("");
2298                 log.debug("  PASS  : Node has stored data");
2299                 log.debug("  PASS  : Got store resource ivorn");
2300                 log.debug("  Ivorn : " + sourceIvorn.toString());
2301                 //
2302                 // Resolve the source filestore
2303                 FileStoreDelegate sourceStore = resolve(
2304                     sourceIvorn
2305                     ) ;
2306                 log.debug("  PASS  : Got source filestore");
2307                 //
2308                 // Remove the data from the filestore.
2309                 try {
2310                     sourceStore.delete(
2311                         sourceIdent
2312                         ) ;
2313                     }
2314                 catch (Exception ouch)
2315                     {
2316                     log.warn("Exception thrown by FileStore.delete()");
2317                     log.warn("  Exception : " + ouch);
2318 //
2319 // Ignore any problems with the delete.
2320 //                    throw new FileManagerServiceException(
2321 //                        "Error occurred when calling FileStore service"
2322 //                        );
2323                     }
2324                 }
2325             //
2326             // If the node does not have any stored data.
2327             else {
2328                 log.debug("  PASS  : Node is empty");
2329                 }
2330             //
2331             // Remove the node from our global map.
2332             store.delNode(
2333                 node
2334                 );
2335             //
2336             // Remove the node from the tree.
2337             try {
2338                 parent.delNode(
2339                     node.getName()
2340                     );
2341                 }
2342             catch (NodeNotFoundException ouch)
2343                 {
2344                 //
2345                 // Log the error.
2346                 log.warn("");
2347                 log.warn("Move failed to remove node from original parent");
2348                 log.warn("Parent : " + parent.getIdent());
2349                 log.warn("Child  : " + node.getIdent());
2350                 }
2351             }
2352         //
2353         // If the node is a container.
2354         else {
2355             log.debug("");
2356             log.debug("FAIL  : Node is a container node");
2357             }
2358         }
2359 
2360     /***
2361      * Transfer data from a source URL into a node.
2362      * @param request The transfer request properties.
2363      * @return The updated file properties for the node, after the transfer.
2364      * @throws NodeNotFoundException If the target node does not exist.
2365      * @throws FileManagerServiceException If a problem occurs when handling the request.
2366      * @todo Refactor this to handle path, and create missing folders.
2367      *
2368      */
2369     public FileProperty[] importData(TransferProperties request)
2370         throws
2371             NodeNotFoundException,
2372             FileManagerServiceException
2373         {
2374         log.debug("");
2375         log.debug("FileManagerMock.importData(TransferProperties)");
2376         if (null == request)
2377             {
2378             throw new NodeNotFoundException(
2379                 "Null transfer properties"
2380                 ) ;
2381             }
2382         //
2383         // Get the node properties from the transfer.
2384         FileManagerProperties properties = new FileManagerProperties(
2385             request.getFileProperties()
2386             );
2387         if (null == properties)
2388             {
2389             throw new NodeNotFoundException(
2390                 "Null target properties"
2391                 ) ;
2392             }
2393         //
2394         // Parse the node identifier.
2395         String ident = null ;
2396         try {
2397             ident = properties.getManagerResourceIdent() ;
2398             }
2399         catch (FileManagerIdentifierException ouch)
2400             {
2401             throw new NodeNotFoundException(
2402                 "Unable to parse resource ivorn"
2403                 );
2404             }
2405         //
2406         // If we don't have a node identifier.
2407         if (null == ident)
2408             {
2409             throw new NodeNotFoundException(
2410                 "Null node identifier"
2411                 );
2412             }
2413         //
2414         // If we have a node identifier.
2415         else {
2416             //
2417             // Check if the node exists.
2418             if (store.hasNode(ident))
2419                 {
2420                 FileManagerStoreNode node = store.getNode(ident) ;
2421                 log.debug("");
2422                 log.debug("  Node : " + node.getName());
2423                 log.debug("  Node : " + node.getIdent());
2424                 //
2425                 // Initiate the transfer.
2426                 return this.importData(
2427                     node,
2428                     request
2429                     ) ;
2430                 }
2431             //
2432             // If the node does not exist.
2433             else {
2434                 throw new NodeNotFoundException();
2435                 }
2436             }
2437         }
2438 
2439     /***
2440      * Transfer data from a source URL into a node.
2441      * @param node The target node.
2442      * @param request The transfer request properties.
2443      * @return The updated properties for the node.
2444      * @throws NodeNotFoundException If the target node does not exist.
2445      * @throws FileManagerServiceException If a problem occurs when handling the request.
2446      * @todo Refactor this to handle path, and create missing folders.
2447      *
2448      */
2449     protected FileProperty[] importData(FileManagerStoreNode node, TransferProperties request)
2450         throws FileManagerServiceException, NodeNotFoundException
2451         {
2452         log.debug("");
2453         log.debug("FileManagerMock.importData(Node, TransferProperties)");
2454         log.debug("  Node : " + node.getName());
2455         log.debug("  Node : " + node.getIdent());
2456         //
2457         // Check the node is a data node.
2458         if (node.isDataNode() != true)
2459             {
2460             throw new FileManagerServiceException(
2461                 "Invalid operation, not a data node"
2462                 );
2463             }
2464         //
2465         // Check the transfer request has a URL.
2466         if (null == request.getLocation())
2467             {
2468             throw new FileManagerServiceException(
2469                 "Null source URL"
2470                 );
2471             }
2472         //
2473         // Parse the source URL.
2474         URL source = null ;
2475         try {
2476             source = new URL(
2477                 request.getLocation()
2478                 );
2479             }
2480         catch(Exception ouch)
2481             {
2482             throw new FileManagerServiceException(
2483                 "Invalid source URL",
2484                 ouch
2485                 );
2486             }
2487         //
2488         // Get the current node properties.
2489         FileManagerProperties current = node.getProperties();
2490         //
2491         // Merge the request properties.
2492         current.merge(
2493             request.getFileProperties(),
2494             new FileManagerPropertyFilter()
2495             );
2496         //
2497         // Create a new transfer request.
2498         TransferProperties transfer = new UrlGetTransfer(
2499             source,
2500             current
2501             );
2502         //
2503         // Get the current filestore.
2504         Ivorn target = null ;
2505         try {
2506             target = current.getStoreResourceIvorn() ;
2507             }
2508         catch (FileStoreIdentifierException ouch)
2509             {
2510             log.warn("");
2511             log.warn("Unable to parse store location");
2512             log.warn(ouch);
2513             throw new FileManagerServiceException(
2514                 "Unable to parse store location"
2515                 );
2516             }
2517         //
2518         // If we don't have a target filestore.
2519         if (null == target)
2520             {
2521             //
2522             // Use the node location.
2523             try {
2524                 target = current.getManagerLocationIvorn();
2525                 }
2526             catch (FileManagerIdentifierException ouch)
2527                 {
2528                 log.warn("");
2529                 log.warn("Unable to parse store location");
2530                 log.warn(ouch);
2531                 throw new FileManagerServiceException(
2532                     "Unable to parse store location"
2533                     );
2534                 }
2535             //
2536             // If the target location is still null.
2537             if (null == target)
2538                 {
2539                 //
2540                 // Use the default filestore.
2541                 target = config.getFileStoreIvorn() ;
2542                 }
2543             }
2544         //
2545         // Resolve the target filestore.
2546         FileStoreDelegate filestore = resolve(
2547             target
2548             ) ;
2549         //
2550         // Call the filestore to transfer the data.
2551         TransferProperties response = null ;
2552         try {
2553             response = 
2554                 filestore.importData(
2555                     transfer
2556                     ) ;
2557             }
2558         catch (Exception ouch)
2559             {
2560             log.debug("Exception thrown by FileStore.importdata()");
2561             log.debug("  Exception : " + ouch);
2562             throw new FileManagerServiceException(
2563                 "Error occurred when calling FileStore service"
2564                 );
2565             }
2566         //
2567         // Merge the response properties.
2568         current.merge(
2569             response.getFileProperties(),
2570             new FileManagerPropertyFilter()
2571             );
2572         //
2573         // Save these as the new properties.
2574         node.setProperties(
2575             current
2576             ) ;
2577         //
2578         // Return the response properties.
2579         return current.toArray() ;
2580         }
2581 
2582 
2583     /***
2584      * Transfer data transfer from a node into destination URL.
2585      * @param request The request properties.
2586      * @throws NodeNotFoundException If the target node does not exist.
2587      * @throws FileManagerServiceException If a problem occurs when handling the request.
2588      *
2589      */
2590     public TransferProperties exportData(FileProperty[] request)
2591         throws
2592             NodeNotFoundException,
2593             FileManagerServiceException
2594         {
2595         return null ;
2596         }
2597 
2598     }