From 16d9338dce5e6da9e2af7ec504ebb1c1fe9f65bf Mon Sep 17 00:00:00 2001 From: harshanl Date: Thu, 25 Aug 2016 16:28:03 +0530 Subject: [PATCH] Refactored windows APIs --- .../beans/Device.java | 6 +- .../beans/OperationRequest.java | 7 +- .../ConfigurationMgtService.java | 6 +- .../DeviceManagementAdminService.java | 56 +++++++++ .../DeviceManagementService.java | 12 +- .../services/PolicyManagementService.java | 46 +++++++ .../services/adminoperations/Operations.java | 57 --------- .../adminoperations/util/OperationStore.java | 112 ------------------ .../ConfigurationMgtServiceImpl.java | 9 +- .../DeviceManagementAdminServiceImpl.java} | 12 +- .../impl/DeviceManagementServiceImpl.java | 18 +-- .../PolicyManagementServiceImpl.java} | 25 ++-- .../wstep/CertificateEnrollmentService.java | 2 +- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 32 ++--- 14 files changed, 167 insertions(+), 233 deletions(-) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/{services/adminoperations => common}/beans/Device.java (80%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/{services/adminoperations => common}/beans/OperationRequest.java (83%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/{configurationmgtservice => }/ConfigurationMgtService.java (93%) create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementAdminService.java rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/{devicemgtservice => }/DeviceManagementService.java (87%) create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/PolicyManagementService.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/{configurationmgtservice => impl}/ConfigurationMgtServiceImpl.java (96%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/{adminoperations/impl/OperationsImpl.java => impl/DeviceManagementAdminServiceImpl.java} (96%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/{devicemgtservice => }/impl/DeviceManagementServiceImpl.java (91%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/{policymgtservice/PolicyMgtService.java => impl/PolicyManagementServiceImpl.java} (75%) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/Device.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Device.java similarity index 80% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/Device.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Device.java index 79a4af79c..c511961e6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/Device.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Device.java @@ -1,10 +1,10 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans; +package org.wso2.carbon.mdm.mobileservices.windows.common.beans; /** * Class for get device IDS. diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/OperationRequest.java similarity index 83% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/OperationRequest.java index 0745aa53a..2793b3680 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/OperationRequest.java @@ -1,10 +1,10 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,8 +16,9 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans; +package org.wso2.carbon.mdm.mobileservices.windows.common.beans; +import org.wso2.carbon.mdm.mobileservices.windows.common.beans.Device; import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.BasicOperation; import java.util.List; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/ConfigurationMgtService.java similarity index 93% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/ConfigurationMgtService.java index 320b75ad8..944b0f363 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/ConfigurationMgtService.java @@ -1,10 +1,10 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice; +package org.wso2.carbon.mdm.mobileservices.windows.services; import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.Scope; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementAdminService.java new file mode 100644 index 000000000..8fca8e9fe --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementAdminService.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, 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 org.wso2.carbon.mdm.mobileservices.windows.services; + +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; + +/** + * Interface for Admin operations persisting. This interface accepts operations added via UI. + */ +@Path("/admin/devices") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface DeviceManagementAdminService { + + @POST + @Path("/lock-devices") + Response lock(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/disenroll-devices") + Response disenroll(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/wipe-devices") + Response wipe(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/ring-devices") + Response ring(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/lockreset-devices") + Response lockReset(@HeaderParam("Accept") String acceptHeader, List deviceIds) + throws WindowsDeviceEnrolmentException; +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementService.java similarity index 87% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementService.java index db2ce7fc3..bab11c334 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/DeviceManagementService.java @@ -4,7 +4,7 @@ * 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice; +package org.wso2.carbon.mdm.mobileservices.windows.services; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.license.mgt.License; @@ -50,25 +50,25 @@ public interface DeviceManagementService { /** * Fetch Windows device details of a given device Id. * - * @param id Device Id + * @param deviceId Device Id * @return Returns retrieved device. * @throws WindowsConfigurationException occurred while getting device from DB. */ @GET @Path("{id}") - Device getDevice(@PathParam("id") String id) throws WindowsConfigurationException; + Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException; /** * Update Windows device details of given device id. * - * @param id Device Id. + * @param deviceId Device Id. * @param device Device details to be updated. * @return Returns the message whether device update or not. * @throws WindowsConfigurationException occurred while updating the Device Info. */ @PUT @Path("{id}") - Message updateDevice(@PathParam("id") String id, Device device) throws WindowsConfigurationException; + Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException; /** * Fetch the Licence agreement for specific windows platform. * diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/PolicyManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/PolicyManagementService.java new file mode 100644 index 000000000..6d894277c --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/PolicyManagementService.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, 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 org.wso2.carbon.mdm.mobileservices.windows.services; + +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; + +/** + * Endpoint for Enforce Effective Policy. + */ +@WebService +@Produces({ "application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public interface PolicyManagementService { + + /** + * Get the applicable effective policy for an enrolled windows device. + * + * @param deviceId Device Id + * @return Returns retrieved devices. + * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. + */ + @GET + @Path("{deviceId}") + Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, + @PathParam("deviceId") String deviceId) throws WindowsConfigurationException; +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java deleted file mode 100644 index b96831f4b..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2015, 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 org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations; - -import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Interface for Admin operations persisting. This interface accepts operations added via UI. - */ -@Path("/operation") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) - -public interface Operations { - - @POST - @Path("/devicelock") - Response lock(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; - - @POST - @Path("/devicedisenroll") - Response disenroll(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; - - @POST - @Path("/devicewipe") - Response wipe(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; - - @POST - @Path("/devicering") - Response ring(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; - - @POST - @Path("/lockreset") - Response lockReset(@HeaderParam("Accept") String acceptHeader, List deviceids) - throws WindowsDeviceEnrolmentException; -} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java deleted file mode 100644 index d41230425..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.util; -// -//import com.google.gson.Gson; -//import org.apache.commons.logging.Log; -//import org.apache.commons.logging.LogFactory; -//import org.wso2.carbon.context.PrivilegedCarbonContext; -//import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -//import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -//import org.wso2.carbon.device.mgt.common.DeviceManagementException; -//import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -//import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -//import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; -//import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -//import org.wso2.carbon.mdm.mobileservices.windows.common.SyncmlCommandType; -//import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; -//import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans.Device; -//import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans.OperationRequest; -//import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Wifi; -// -//import java.util.ArrayList; -//import java.util.List; -// -//public class OperationStore { -// -// private static Log log = LogFactory.getLog(OperationStore.class); -// -// public static boolean storeOperation(OperationRequest operationRequest, Operation.Type type, -// String commandType) throws -// WindowsDeviceEnrolmentException { -// -// List devices = operationRequest.getDeviceList(); -// List deviceIdentifiers = new ArrayList(); -// DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); -// -// Operation operation = transformBasicOperation(operationRequest, type, commandType); -// -// for (int i = 0; i < devices.size(); i++) { -// try { -// deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); -// deviceIdentifier.setId(devices.get(i).getID()); -// deviceIdentifiers.add(deviceIdentifier); -// getDeviceManagementServiceProvider().getDevice(deviceIdentifier); -// -// } catch (DeviceManagementException e) { -// log.error("Cannot validate device ID: " + devices.get(i).getID()); -// deviceIdentifiers.remove(i); -// } -// } -// try { -// getDeviceManagementServiceProvider().addOperation(operation, deviceIdentifiers); -// } catch (OperationManagementException e) { -// String msg = "Failure occurred while storing command operation."; -// log.error(msg); -// return false; -// } -// return true; -// } -// -// private static DeviceManagementProviderService getDeviceManagementServiceProvider() { -// DeviceManagementProviderService deviceManager; -// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); -// deviceManager = -// (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); -// -// if (deviceManager == null) { -// String msg = "Device management service is not initialized."; -// log.error(msg); -// } -// return deviceManager; -// } -// -// private static Operation transformBasicOperation(OperationRequest operationRequest, Operation.Type type, -// String commandType) throws WindowsDeviceEnrolmentException { -// -// Operation operation = new Operation(); -// operation.setCode(commandType); -// operation.setType(type); -// Gson gson = new Gson(); -// -// if (commandType == SyncmlCommandType.WIFI.getValue()) { -// -// operation = new ConfigOperation(); -// operation.setCode(commandType); -// operation.setType(type); -// -// Wifi wifiObject = (Wifi) operationRequest.getBasicOperation(); -// operation.setPayLoad(gson.toJson(wifiObject)); -// } else { -// // no operation..... -// } -// -// return operation; -// } -//} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/ConfigurationMgtServiceImpl.java similarity index 96% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtServiceImpl.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/ConfigurationMgtServiceImpl.java index c6b94383b..857b74402 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/ConfigurationMgtServiceImpl.java @@ -1,10 +1,10 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice; +package org.wso2.carbon.mdm.mobileservices.windows.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,6 +29,7 @@ import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +import org.wso2.carbon.mdm.mobileservices.windows.services.ConfigurationMgtService; import javax.jws.WebService; import javax.ws.rs.*; @@ -40,7 +41,7 @@ import java.util.List; @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) @Path("/") -public class ConfigurationMgtServiceImpl implements ConfigurationMgtService{ +public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/DeviceManagementAdminServiceImpl.java similarity index 96% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/DeviceManagementAdminServiceImpl.java index afffe53c2..2cb39d626 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/DeviceManagementAdminServiceImpl.java @@ -1,10 +1,10 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.impl; +package org.wso2.carbon.mdm.mobileservices.windows.services.impl; import com.ibm.wsdl.OperationImpl; import org.apache.commons.logging.Log; @@ -30,7 +30,7 @@ import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDevic import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsOperationsException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; -import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.Operations; +import org.wso2.carbon.mdm.mobileservices.windows.services.DeviceManagementAdminService; import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; @@ -43,7 +43,7 @@ import java.util.List; * Implementation class of operations interface. Each method in this class receives the operations comes via UI * and persists those in the correct format. */ -public class OperationsImpl implements Operations { +public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminService { private static Log log = LogFactory.getLog(OperationImpl.class); @@ -56,7 +56,7 @@ public class OperationsImpl implements Operations { * @throws WindowsDeviceEnrolmentException */ @POST - @Path("/lock") + @Path("/lock-devices") public Response lock(@HeaderParam("Accept") String acceptHeader, List deviceIDs) throws WindowsDeviceEnrolmentException { if (log.isDebugEnabled()) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/DeviceManagementServiceImpl.java similarity index 91% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/DeviceManagementServiceImpl.java index 0c348b4ec..d7b84b9bd 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/DeviceManagementServiceImpl.java @@ -4,7 +4,7 @@ * 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice.impl; +package org.wso2.carbon.mdm.mobileservices.windows.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,7 +28,7 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; -import org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice.DeviceManagementService; +import org.wso2.carbon.mdm.mobileservices.windows.services.DeviceManagementService; import javax.jws.WebService; import javax.ws.rs.*; @@ -72,17 +72,17 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { /** * Fetch Windows device details of a given device Id. * - * @param id Device Id + * @param deviceId Device Id * @return Returns retrieved device. * @throws WindowsConfigurationException occurred while getting device from DB. */ @GET @Path("{id}") - public Device getDevice(@PathParam("id") String id) throws WindowsConfigurationException { + public Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException { String msg; Device device; try { - DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id); + DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId); device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); if (device == null) { Response.status(Response.Status.NOT_FOUND); @@ -98,18 +98,18 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { /** * Update Windows device details of given device id. * - * @param id Device Id. + * @param deviceId Device Id. * @param device Device details to be updated. * @return Returns the message whether device update or not. * @throws WindowsConfigurationException occurred while updating the Device Info. */ @PUT @Path("{id}") - public Message updateDevice(@PathParam("id") String id, Device device) throws WindowsConfigurationException { + public Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException { String msg; Message responseMessage = new Message(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); + deviceIdentifier.setId(deviceId); deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); boolean isUpdated; try { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/PolicyManagementServiceImpl.java similarity index 75% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/PolicyManagementServiceImpl.java index cf013845f..ac0819a5e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/impl/PolicyManagementServiceImpl.java @@ -1,10 +1,10 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, 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 + * you may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice; +package org.wso2.carbon.mdm.mobileservices.windows.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -24,29 +24,28 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +import org.wso2.carbon.mdm.mobileservices.windows.services.PolicyManagementService; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import javax.jws.WebService; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -/** - * Endpoint for Enforce Effective Policy. - */ @WebService -@Produces({"application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public class PolicyMgtService { - private static Log log = LogFactory.getLog(PolicyMgtService.class); +@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +public class PolicyManagementServiceImpl implements PolicyManagementService { + private static Log log = LogFactory.getLog(PolicyManagementServiceImpl.class); @GET - @Path("{id}") + @Path("{deviceId}") public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, - @PathParam("id") String id) throws WindowsConfigurationException { + @PathParam("deviceId") String deviceId) throws WindowsConfigurationException { - DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id); + DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId); Message responseMessage = new Message(); Policy policy; try { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java index e517672db..e5f817fd0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java @@ -44,7 +44,7 @@ public interface CertificateEnrollmentService { @WebMethod(operationName = "RequestSecurityToken") @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) - public void requestSecurityToken( + void requestSecurityToken( @WebParam(name = "TokenType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) String tokenType, @WebParam(name = "RequestType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml index e756b20fe..97953a950 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -32,7 +32,7 @@ - + @@ -114,14 +114,14 @@ - + - + @@ -131,7 +131,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -153,7 +153,7 @@ - + @@ -161,11 +161,11 @@ - - - + @@ -196,12 +196,12 @@ - - + + - +