diff --git a/product/modules/agents/android/jax-rs/pom.xml b/product/modules/agents/android/jax-rs/pom.xml index 45fbb86f0..6ee8f104b 100644 --- a/product/modules/agents/android/jax-rs/pom.xml +++ b/product/modules/agents/android/jax-rs/pom.xml @@ -1,18 +1,20 @@ + ~ 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. +--> 2.6.1 4.8.2 - diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java index e1d3c7d20..f1cdfc64f 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java @@ -1,19 +1,20 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * 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 + * 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. + * 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; import cdm.api.android.common.AndroidAgentException; @@ -38,7 +39,7 @@ import java.util.List; @Consumes({ "application/json", "application/xml" }) public class Device { - private static Log log = LogFactory.getLog(Device.class); + private static Log LOG = LogFactory.getLog(Device.class); @GET public List getAllDevices() throws AndroidAgentException { @@ -52,28 +53,27 @@ public class Device { } catch (DeviceManagementServiceException deviceMgtServiceEx) { String errorMsg = "Device management service error"; - log.error(errorMsg, deviceMgtServiceEx); - throw new AndroidAgentException(); + LOG.error(errorMsg, deviceMgtServiceEx); + throw new AndroidAgentException(errorMsg, deviceMgtServiceEx); } try { - devices = dmService.getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); Response.status(HttpStatus.SC_OK); + return devices; } catch (DeviceManagementException e) { msg = "Error occurred while fetching the device list."; - log.error(msg, e); + LOG.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); - } - return devices; } @GET @Path("{id}") public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id) throws AndroidAgentException { + String msg; DeviceManagementService dmService; org.wso2.carbon.device.mgt.common.Device device; @@ -83,21 +83,23 @@ public class Device { } catch (DeviceManagementServiceException deviceMgtServiceEx) { String errorMsg = "Device management service error"; - log.error(errorMsg, deviceMgtServiceEx); + LOG.error(errorMsg, deviceMgtServiceEx); throw new AndroidAgentException(errorMsg, deviceMgtServiceEx); } + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); try { device = dmService.getDevice(deviceIdentifier); if (device == null) { Response.status(HttpStatus.SC_NOT_FOUND); } + return device; + } catch (DeviceManagementException deviceMgtEx) { msg = "Error occurred while fetching the device information."; - log.error(msg, deviceMgtEx); + LOG.error(msg, deviceMgtEx); throw new AndroidAgentException(msg, deviceMgtEx); } - return device; } @PUT @@ -115,7 +117,7 @@ public class Device { } catch (DeviceManagementServiceException deviceManagementServiceException) { String errorMsg = "Device management service error"; - log.error(errorMsg, deviceManagementServiceException); + LOG.error(errorMsg, deviceManagementServiceException); } try { @@ -133,9 +135,16 @@ public class Device { } catch (DeviceManagementException deviceMgtEx) { String msg = "Error occurred while modifying the device information."; - log.error(msg, deviceMgtEx); + LOG.error(msg, deviceMgtEx); throw new AndroidAgentException(msg, deviceMgtEx); } + } + @POST + @Path("/device/license") + @Produces ("text/plain") + public String getLicense() { + //TODO: need to implement fetch license from core + return "License Agreement"; } } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java index 3dff018c5..5c93765f5 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java @@ -1,17 +1,19 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * 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 + * 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. + * 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; @@ -40,14 +42,6 @@ public class Enrollment { private static Log log = LogFactory.getLog(Enrollment.class); - /* - * Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD", - * "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"}, - * {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"}, - * {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"}, - * {"name":"osVersion","value":"5.0.0"}]} - * - **/ @POST public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException { @@ -75,7 +69,6 @@ public class Enrollment { log.error(errorMsg, deviceMgtEx); throw new AndroidAgentException(errorMsg, deviceMgtEx); } - } @GET @@ -106,25 +99,14 @@ public class Enrollment { Response.status(HttpStatus.SC_NOT_FOUND); responseMsg.setResponseMessage("Device not found"); } - return responseMsg; - } catch (DeviceManagementException deviceMgtEx) { String errormsg = "Error occurred while enrollment of the device."; log.error(errormsg, deviceMgtEx); throw new AndroidAgentException(errormsg, deviceMgtEx); } - } - /* - * Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD", - * "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"}, - * {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"}, - * {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"}, - * {"name":"osVersion","value":"5.0.0"}]} - * - **/ @PUT @Path("{id}") public Message modifyEnrollment(@PathParam("id") String id, org.wso2.carbon.device.mgt.common.Device device) @@ -157,19 +139,17 @@ public class Enrollment { return responseMsg; - } catch (DeviceManagementException e) { + } catch (DeviceManagementException deviceMgtEx) { String errorMsg = "Error occurred while modifying enrollment of the device"; - log.error(errorMsg, e); - Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); - responseMsg.setResponseMessage(errorMsg); - return responseMsg; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); } } @DELETE @Path("{id}") - public Message disenrollDevice(@PathParam("id") String id) throws AndroidAgentException { + public Message disEnrollDevice(@PathParam("id") String id) throws AndroidAgentException { DeviceManagementService dmService; Message responseMsg = new Message(); @@ -195,14 +175,12 @@ public class Enrollment { responseMsg.setResponseMessage("Device not found"); Response.status(HttpStatus.SC_NOT_FOUND); } - return responseMsg; + } catch (DeviceManagementException deviceMgtEx) { String errorMsg = "Error occurred while dis enrolling the device"; log.error(errorMsg, deviceMgtEx); - Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); - responseMsg.setResponseMessage(errorMsg); - return responseMsg; + throw new AndroidAgentException(errorMsg, deviceMgtEx); } } } 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 index 5af6c8f3d..caf7cf538 100644 --- 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 @@ -11,7 +11,9 @@ import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; - +/** + * This is a Test class + */ @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) public class Test { 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 index 84523d396..138a3fa95 100644 --- 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 @@ -1,24 +1,22 @@ /* * 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 + * 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 + * 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. + * 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; diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java index 698ce3ffe..de3d0c523 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/common/ErrorHandler.java @@ -1,21 +1,20 @@ /* * 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 + * 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 + * 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. + * 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; import org.wso2.carbon.device.mgt.common.DeviceManagementException; 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 index 7f526900d..d166f105d 100644 --- 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 @@ -1,21 +1,20 @@ /* * 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 + * 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 + * 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. + * 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; diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java index e2ae093a0..e0e418b8a 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java @@ -1,19 +1,20 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * 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 + * 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. - */ - + * 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.util; import org.apache.commons.logging.Log; @@ -31,6 +32,7 @@ public class AndroidAPIUtils { private static Log log = LogFactory.getLog(AndroidAPIUtils.class); public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) { + DeviceIdentifier identifier = new DeviceIdentifier(); identifier.setId(deviceId); identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); @@ -41,7 +43,6 @@ public class AndroidAPIUtils { public static DeviceManagementService getDeviceManagementService() throws DeviceManagementServiceException{ // until complete login this is use to load super tenant context - DeviceManagementService dmService; PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java index 0dcb9e59d..f3880536c 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidConstants.java @@ -1,19 +1,20 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * 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 + * 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. - */ - + * 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.util; /** diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java index f5e34cf7e..5361ff0d4 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/Message.java @@ -1,21 +1,20 @@ /* * 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 + * 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 + * 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. - */ - + * 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.util; import javax.xml.bind.annotation.XmlElement; diff --git a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index 693d44557..7f7e753d1 100644 --- a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,21 +1,21 @@ - - + ~ 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. +--> - + @@ -60,8 +60,6 @@ - - diff --git a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml index b12b2cf4e..1a5ca4fed 100644 --- a/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml +++ b/product/modules/agents/android/jax-rs/src/main/webapp/WEB-INF/web.xml @@ -1,19 +1,21 @@ + ~ 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. +--> CDM-Android-API