forked from openmrs/openmrs-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the exception classes - TRUNK-4696
Refactored the exception classes - TRUNK-4696 Refactored the exception classes - TRUNK-4696
- Loading branch information
Showing
23 changed files
with
410 additions
and
451 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
api/src/main/java/org/openmrs/api/CannotDeleteObjectInUseException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http:https://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http:https://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.api; | ||
|
||
/** | ||
* An instance of this exception is thrown if a delete operation is attempted on an object that is | ||
* referenced by others, typically this should be thrown when deleting an existing object is | ||
* detrimental to the integrity of objects referencing it or any other existing associated data. | ||
* | ||
* @since 2.1 | ||
*/ | ||
public class CannotDeleteObjectInUseException extends InvalidOperationOnObjectException { | ||
|
||
public CannotDeleteObjectInUseException(String message) { | ||
super(message); | ||
} | ||
|
||
public CannotDeleteObjectInUseException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public CannotDeleteObjectInUseException(String messageKey, Object[] parameters) { | ||
super(messageKey, parameters); | ||
} | ||
|
||
/** | ||
* @see InvalidOperationOnObjectException#InvalidOperationOnObjectException(Class) | ||
*/ | ||
public CannotDeleteObjectInUseException(Class clazz) { | ||
super(clazz); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
api/src/main/java/org/openmrs/api/CannotUpdateObjectInUseException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http:https://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http:https://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.api; | ||
|
||
/** | ||
* An instance of this exception is thrown if an update operation is attempted on an object that is | ||
* referenced by others, typically this should be thrown when altering an existing object is | ||
* detrimental to the integrity of objects referencing it or any other existing associated data. | ||
* | ||
* @since 2.1 | ||
*/ | ||
public class CannotUpdateObjectInUseException extends InvalidOperationOnObjectException { | ||
|
||
public CannotUpdateObjectInUseException(String message) { | ||
super(message); | ||
} | ||
|
||
public CannotUpdateObjectInUseException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public CannotUpdateObjectInUseException(String messageKey, Object[] parameters) { | ||
super(messageKey, parameters); | ||
} | ||
|
||
/** | ||
* @see InvalidOperationOnObjectException#InvalidOperationOnObjectException(Class) | ||
*/ | ||
public CannotUpdateObjectInUseException(Class clazz) { | ||
super(clazz); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
api/src/main/java/org/openmrs/api/InvalidOperationOnObjectException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http:https://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http:https://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.api; | ||
|
||
/** | ||
* An instance of this exception is thrown if an operation is attempted on an object, typically this | ||
* should be thrown when any operation is made to an existing object and is considered detrimental | ||
* to the integrity of any existing associated data. This is a more generic exception that doesn't | ||
* convey any specifics on the actual operation that was attempted on the object. | ||
* | ||
* @see UnchangeableObjectException | ||
* @see CannotDeleteObjectInUseException | ||
* @see CannotUpdateObjectInUseException | ||
* @since 2.1 | ||
*/ | ||
public class InvalidOperationOnObjectException extends APIException { | ||
|
||
public InvalidOperationOnObjectException(String message) { | ||
super(message); | ||
} | ||
|
||
public InvalidOperationOnObjectException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public InvalidOperationOnObjectException(String messageKey, Object[] parameters) { | ||
super(messageKey, parameters); | ||
} | ||
|
||
/** | ||
* @param clazz the type of the object on which the operation was attempted | ||
*/ | ||
public InvalidOperationOnObjectException(Class clazz) { | ||
this("An invalid operation was attempted on an instance of " + clazz.getName()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
api/src/main/java/org/openmrs/api/MissingRequiredPropertyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http:https://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http:https://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.api; | ||
|
||
/** | ||
* An instance of this exception is thrown when a required property has not been set on an Object. | ||
* | ||
* @since 2.1 | ||
*/ | ||
public class MissingRequiredPropertyException extends APIException { | ||
|
||
public MissingRequiredPropertyException(String message) { | ||
super(message); | ||
} | ||
|
||
public MissingRequiredPropertyException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public MissingRequiredPropertyException(String messageKey, Object[] parameters) { | ||
super(messageKey, parameters); | ||
} | ||
|
||
/** | ||
* @param clazz the class of the object on which the property is required | ||
* @param property the name of the missing required property | ||
*/ | ||
public MissingRequiredPropertyException(Class clazz, String property) { | ||
this(clazz.getName() + "." + property + " is required"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
api/src/main/java/org/openmrs/api/UnchangeableObjectException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http:https://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http:https://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.api; | ||
|
||
/** | ||
* An instance of this exception is thrown if an attempt is made to update an unchangeable object | ||
* | ||
* @since 2.1 | ||
*/ | ||
public class UnchangeableObjectException extends InvalidOperationOnObjectException { | ||
|
||
public UnchangeableObjectException() { | ||
this("Cannot update an unchangeable object"); | ||
} | ||
|
||
public UnchangeableObjectException(String message) { | ||
super(message); | ||
} | ||
|
||
public UnchangeableObjectException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public UnchangeableObjectException(String messageKey, Object[] parameters) { | ||
super(messageKey, parameters); | ||
} | ||
|
||
/** | ||
* @see InvalidOperationOnObjectException#InvalidOperationOnObjectException(Class) | ||
*/ | ||
public UnchangeableObjectException(Class clazz) { | ||
super(clazz); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
api/src/main/java/org/openmrs/api/UnchangeablePropertyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http:https://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http:https://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.api; | ||
|
||
/** | ||
* An instance of this exception is thrown if an attempt is made to update an unchangeable property | ||
* on an object | ||
* | ||
* @since 2.1 | ||
*/ | ||
public class UnchangeablePropertyException extends APIException { | ||
|
||
public UnchangeablePropertyException(String message) { | ||
super(message); | ||
} | ||
|
||
public UnchangeablePropertyException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public UnchangeablePropertyException(String messageKey, Object[] parameters) { | ||
super(messageKey, parameters); | ||
} | ||
|
||
/** | ||
* @param clazz the class of the object on which it was changed | ||
* @param property the name of the unchangeable property | ||
*/ | ||
public UnchangeablePropertyException(Class clazz, String property) { | ||
this(clazz.getName() + "." + property + " cannot be changed"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.