source: ndgCommon/trunk/ndg/common/src/clients/interfacecrudclient.py @ 4918

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/src/clients/interfacecrudclient.py@4918
Revision 4918, 3.9 KB checked in by cbyrom, 11 years ago (diff)

Define interfaces for the following clients - to improve implementation
and extensibility:

  • search client
  • xml db crud client
  • xml db low level ops client (e.g. to be implemented with XML-RPC/REST interface)
  • atom client for xml db
Line 
1'''
2 Interface for clients extending search functionality to include standard CRUD
3 (create, replace, update, delete) functionality for metadata documents
4 
5 @author: C Byrom - Tessella, Feb 09
6'''
7import os, sys, logging
8from interfacesearchclient import InterfaceSearchClient
9
10class InterfaceCRUDClient(InterfaceSearchClient):
11
12    def isNewDoc(self, docPath):
13        '''
14        Test if a doc already exists in the XML DB
15        @param docPath: path of file to look up
16        @return: True if a new doc, False if otherwise
17        '''
18        raise NotImplementedError("This is an interface class and this method has not " + \
19                                  "been implemented yet")
20
21
22    def backupDoc(self, collection, fileName, runAsynch = True):
23        '''
24        Backup a file that exists in the XML DB
25        - NB, this really just creates a new file with the same contents in a
26        backup dir
27        @param collection: path of the collection to store the file in
28        @param fileName: name of file to add
29        @param runAsynch: if True, do the backup asynchronously in a separate thread
30        @return: path to new backup file
31        '''
32        raise NotImplementedError("This is an interface class and this method has not " + \
33                                  "been implemented yet")
34
35
36    def restoreBackup(self, docPath):
37        '''
38        Restore the backed up file - effectively recreating in the non-backup collection
39        @param docPath: path to file to backup
40        @param restoredFileName: path to newly restored file
41        '''
42        raise NotImplementedError("This is an interface class and this method has not " + \
43                                  "been implemented yet")
44
45    def createDoc(self, xml, collection, fileName):
46        '''
47        Add the input doc to the XML DB
48        @param xml: contents of xml file to create in the XML DB
49        @param collection: path of the collection to store the file in
50        @param fileName: name of file to add
51        @return: True, if file created successfully
52        '''
53        raise NotImplementedError("This is an interface class and this method has not " + \
54                                  "been implemented yet")
55
56
57    def deleteDoc(self, docPath):
58        '''
59        Delete the input file from the XML DB
60        @param docPath: path of document to delete
61        @return: True, if file deleted successfully
62        '''
63        raise NotImplementedError("This is an interface class and this method has not " + \
64                                  "been implemented yet")
65
66
67    def createOrUpdateDoc(self, xml, collection, fileName):
68        '''
69        Check if a file already exists in the XML DB; if it does, run an
70        update (which will backup the existing file), otherwise create
71        the file in eXist
72        @param xml: contents of xml file to create/update in the XML DB
73        @param collection: path of the collection to store the file in
74        @param fileName: name of file to add
75        @return name of backup file, if file needed to be backed up - or None, otherwise
76        '''
77        raise NotImplementedError("This is an interface class and this method has not " + \
78                                  "been implemented yet")
79       
80
81    def isNewCollection(self, collectionPath):
82        '''
83        Look up a collection in using XPath
84        @param collectionPath: path to collection to look up
85        @return: False if collection exists, True otherwise
86        '''
87        raise NotImplementedError("This is an interface class and this method has not " + \
88                                  "been implemented yet")
89
90
91    def createCollections(self, collections):
92        '''
93        Create the specified collections in eXist
94        @param collections: array of collections to create
95        @return True if successful
96        '''
97        raise NotImplementedError("This is an interface class and this method has not " + \
98                                  "been implemented yet")
Note: See TracBrowser for help on using the repository browser.