From f50cdef0b18c31a45648653f7f100e6f240392ec Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 22 Dec 2014 20:47:58 +0530 Subject: [PATCH] JAX-RS Refractor --- .../src/main/java/cdm/api/android/Test.java | 34 +++++++++++ .../android/common/AndroidAgentException.java | 60 +++++++++++++++++++ .../cdm/api/android/common/ErrorMessage.java | 42 +++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java create mode 100644 product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java create mode 100644 product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java new file mode 100644 index 00000000000..5af6c8f3d71 --- /dev/null +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Test.java @@ -0,0 +1,34 @@ +package cdm.api.android; + +import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.Device; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + + +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public class Test { + + @GET + public List getAllDevices() throws DeviceManagementException{ + + Device dev = new Device(); + dev.setName("test1"); + dev.setDateOfEnrolment(11111111L); + dev.setDateOfLastUpdate(992093209L); + dev.setDescription("sassasaas"); + + ArrayList listdevices = new ArrayList(); + listdevices.add(dev); + throw new DeviceManagementException("test ex"); + + } + +} diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java new file mode 100644 index 00000000000..84523d396a4 --- /dev/null +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/AndroidAgentException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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. + */ + +package cdm.api.android.common; + + +public class AndroidAgentException extends Exception{ + + private static final long serialVersionUID = 7950151650447893900L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public AndroidAgentException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public AndroidAgentException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public AndroidAgentException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public AndroidAgentException() { + super(); + } + + public AndroidAgentException(Throwable cause) { + super(cause); + } + + + +} diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java new file mode 100644 index 00000000000..7f526900d60 --- /dev/null +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorMessage.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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. + */ + +package cdm.api.android.common; + + +public class ErrorMessage { + + private String errorMessage; + private String errorCode; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } +}