You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by pr...@apache.org on 2014/04/24 08:04:47 UTC
[3/5] git commit: adding throwable exception mapper. Now we return
json error objects in all cases.
adding throwable exception mapper. Now we return json error objects in all cases.
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/e2924233
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/e2924233
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/e2924233
Branch: refs/heads/master
Commit: e2924233deee2fc0bc866514a44a4b891f8ad905
Parents: 6badbbe
Author: Pradeep Fernando <pr...@gmail.com>
Authored: Tue Apr 22 12:49:53 2014 +0530
Committer: Pradeep Fernando <pr...@gmail.com>
Committed: Tue Apr 22 12:49:53 2014 +0530
----------------------------------------------------------------------
.../CustomThrowableExceptionMapper.java | 39 ++++++++++++++++++++
.../handlers/GenericExceptionMapper.java | 4 +-
.../webapp/stratos/WEB-INF/schemas/schema.xsd | 34 +++++++++++++++++
3 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e2924233/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java
new file mode 100644
index 0000000..0f08728
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java
@@ -0,0 +1,39 @@
+package org.apache.stratos.rest.endpoint.handlers;/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.rest.endpoint.Utils;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+public class CustomThrowableExceptionMapper implements ExceptionMapper<Throwable> {
+ private static Log log = LogFactory.getLog(CustomThrowableExceptionMapper.class);
+
+ public Response toResponse(Throwable throwable) {
+ if(log.isDebugEnabled()){
+ log.debug("Internal server error", throwable);
+ }
+
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON).
+ entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Internal server error")).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e2924233/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/GenericExceptionMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/GenericExceptionMapper.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/GenericExceptionMapper.java
index 65d2ed1..684bd2e 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/GenericExceptionMapper.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/GenericExceptionMapper.java
@@ -35,11 +35,11 @@ public class GenericExceptionMapper implements ExceptionMapper<WebApplicationExc
public Response toResponse(WebApplicationException webApplicationException) {
if(log.isDebugEnabled()){
- log.debug("internal server error", webApplicationException);
+ log.debug("Internal erver error", webApplicationException);
}
// if no specific error message specified, spitting out a generaic error message
String errorMessage = (webApplicationException.getMessage() != null)?
- webApplicationException.getMessage():"internal server error";
+ webApplicationException.getMessage():"Internal server error";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON).
entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), errorMessage)).build();
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e2924233/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
index b003664..cfd814a 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
+++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
@@ -18,4 +18,38 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+
+ <xs:element name="autoscalePolicy">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="deploymentPolicy">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="cartridgeDefinitionBean">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ <xs:any processContents="lax"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
\ No newline at end of file