Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update exception handling framework for web services.
A new EucalyptusWebServiceException class is added for extention by service specific exceptions. The new ErrorHandlerSupport class uses the exception information to support handling of service errors. The new QueryBindingInfo annotation allows error sub-classes to declare the HTTP status code for use with that error condition. A Role enumeration is added to identify the party at fault for an error condition. BaseMessageSupplier is added to encapsulate a message and any associated binding details (initially just the HTTP status code) and web services framework code is updated to allow responses of this type.
- Loading branch information
Showing
10 changed files
with
370 additions
and
11 deletions.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
clc/modules/msgs/src/main/java/com/eucalyptus/ws/EucalyptusWebServiceException.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,66 @@ | ||
/************************************************************************* | ||
* Copyright 2009-2013 Eucalyptus Systems, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
* Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta | ||
* CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need | ||
* additional information or have any questions. | ||
************************************************************************/ | ||
package com.eucalyptus.ws; | ||
|
||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString; | ||
import static com.eucalyptus.util.Parameters.checkParam; | ||
import javax.annotation.Nonnull; | ||
import com.eucalyptus.util.EucalyptusCloudException; | ||
import com.eucalyptus.ws.protocol.QueryBindingInfo; | ||
|
||
/** | ||
* Represents an expected error condition from a web service. | ||
* | ||
* <p>The codes used will be service specific, the {@link Role} should be | ||
* interpreted at binding time to a valid meaningful to the service.</p> | ||
* | ||
* <p>Annotations for binding specific defaults should be placed on this | ||
* class and overridden as appropriate in the exception class hierarchy.</p> | ||
*/ | ||
@QueryBindingInfo( statusCode = 500 ) | ||
public class EucalyptusWebServiceException extends EucalyptusCloudException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private final String code; | ||
private final Role role; | ||
|
||
public EucalyptusWebServiceException( final String code, | ||
final Role role, | ||
final String message ) { | ||
super( message ); | ||
checkParam( code, not( isEmptyOrNullString() ) ); | ||
checkParam( role, notNullValue() ); | ||
checkParam( message, not( isEmptyOrNullString() ) ); | ||
this.code = code; | ||
this.role = role; | ||
} | ||
|
||
@Nonnull | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Nonnull | ||
public Role getRole() { | ||
return role; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
clc/modules/msgs/src/main/java/com/eucalyptus/ws/Role.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,36 @@ | ||
/************************************************************************* | ||
* Copyright 2009-2013 Eucalyptus Systems, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
* Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta | ||
* CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need | ||
* additional information or have any questions. | ||
************************************************************************/ | ||
package com.eucalyptus.ws; | ||
|
||
/** | ||
* Represents a role in a message exchange pattern. | ||
*/ | ||
public enum Role { | ||
|
||
/** | ||
* The message sender, a.k.a. client | ||
*/ | ||
Sender, | ||
|
||
/** | ||
* The message recipient, a.k.a. server | ||
*/ | ||
Receiver | ||
} |
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
40 changes: 40 additions & 0 deletions
40
clc/modules/msgs/src/main/java/com/eucalyptus/ws/protocol/QueryBindingInfo.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,40 @@ | ||
/************************************************************************* | ||
* Copyright 2009-2013 Eucalyptus Systems, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
* Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta | ||
* CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need | ||
* additional information or have any questions. | ||
************************************************************************/ | ||
package com.eucalyptus.ws.protocol; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotation to use for classes that define Query API binding details. | ||
*/ | ||
@Target( ElementType.TYPE ) | ||
@Retention( RetentionPolicy.RUNTIME ) | ||
public @interface QueryBindingInfo { | ||
|
||
/** | ||
* The HTTP status code to use. | ||
* | ||
* @return The status code. | ||
*/ | ||
int statusCode() default 200; | ||
} |
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
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.