source: mauRepo/MolesManager/trunk/src/libs/migration/exception/exceptions.py @ 8254

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/exception/exceptions.py@8254
Revision 8254, 3.1 KB checked in by mnagni, 8 years ago (diff)

Complete - # 22386: CEDA Observation - title
 http://team.ceda.ac.uk/trac/ceda/ticket/22386

Line 
1'''
2Created on 15 Nov 2011
3
4@author: mnagni
5'''
6
7def _migrationObjectDescription(migrationObject):
8    try:
9        return "%s %s %s" % (migrationObject.doc_status, migrationObject.doc_owner, migrationObject.doc_name)
10    except (Exception, RuntimeError) as ex:
11        print ex
12
13class NoDBManager(Exception):
14    def __init__(self, value):
15        self.value = value
16    def __str__(self):
17        return "No DBManager has been set for %s" % (self.value) 
18   
19class NoCreationDate(Exception):
20    def __init__(self, value):
21        self.value = value
22    def __str__(self):
23        return "The resource %s has no creation date" % (self.value) 
24   
25class Moles3ObjectException(Exception):
26    def __init__(self, value):
27        self.value = value
28    def __str__(self):
29        return self.value   
30   
31class NoDocumentID(Exception):
32    def __init__(self, value):
33        self.value = value
34    def __str__(self):
35        return "The resource %s has no creation date" % (self.value)   
36
37class MigrationObjectException(Exception):
38    """
39        Raises a generic MigrationObject related exception.       
40    """
41    def __init__(self, migrationObject, comment = ''):
42        """
43            Creates a new instance
44            @param migrationObject: the MigrationObject instance that raised the error
45            @param comment:additional comment
46        """       
47        self.migrationObject = migrationObject
48        self.comment = comment
49    def __str__(self):
50        return "Error on migration object %s " % (_migrationObjectDescription(self.migrationObject))
51
52class NoAssociatedAuthor(MigrationObjectException):
53    """
54        Raises a missing associatedAuthor exception.       
55    """   
56    def __init__(self, author, migrationObject = None, comment = ''):
57        self.author = author
58        super(NoAssociatedAuthor, self).__init__(migrationObject, comment = '')
59    def __str__(self):
60        return "The MigrationObject %s has no author mapping for %s" % (_migrationObjectDescription(self.migrationObject), self.author)           
61
62class NoAssociatedDeployments(Exception):
63    def __init__(self, data_entityMigration, deploymentName = None):
64        """
65            @param data_entityMigration: the data_entity migration associated
66            @param deploymentName: the associated deployment document name
67        """
68        self._migrationObject = data_entityMigration
69        self._deploymentName = deploymentName       
70        super(NoAssociatedDeployments, self).__init__()
71    def __str__(self):
72        if self._deploymentName:
73            return "The DataEntity %s has no associated deployment named %s" % (_migrationObjectDescription(self.migrationObject), self._deploymentName)
74        else:
75            return "The DataEntity %s has no associated deployment" % (_migrationObjectDescription(self.migrationObject))
76   
77class NoDataLineage(MigrationObjectException):
78    """
79        Raises a missing dataLineage exception.       
80    """   
81    def __init__(self, migrationObject, comment = ''):       
82        super(NoDataLineage, self).__init__(migrationObject, comment = '')
Note: See TracBrowser for help on using the repository browser.