# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
revert-70aa11f8
Asok 10 years ago
commit 8d67673198

@ -20,10 +20,19 @@ package org.wso2.carbon.policy.mgt.common;
public class Feature { public class Feature {
private int id;
private String code; private String code;
private String name; private String name;
private Object attribute; private Object attribute;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() { public String getCode() {
return code; return code;
} }

@ -63,4 +63,19 @@ public class PolicyManagement implements PolicyManagerService {
public Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException { public Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException {
return null; return null;
} }
@Override
public boolean isPolicyAvailableForDevice(String deviceId, String deviceType) throws PolicyManagementException {
return false;
}
@Override
public boolean isPolicyUsed(String deviceId, String deviceType) throws PolicyManagementException {
return false;
}
@Override
public void setPolicyUsed(String deviceId, String deviceType, Policy policy) throws PolicyManagementException {
}
} }

@ -0,0 +1,38 @@
/*
* 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.policy.mgt.common.spi;
import org.wso2.carbon.policy.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
import java.util.List;
public interface FeatureManagerService {
void addFeature(Feature feature) throws FeatureManagementException;
void editFeature(Feature feature) throws FeatureManagementException;
void removeFeature(int featureId) throws FeatureManagementException;
List<Feature> getFeatures() throws FeatureManagementException;
List<Feature> getFeaturesOfPolicy(int policyId) throws FeatureManagementException;
}

@ -30,6 +30,7 @@ public interface PolicyManagerService {
/** /**
* This method adds a policy to the platform * This method adds a policy to the platform
*
* @param policy * @param policy
* @return primary key (generated key) * @return primary key (generated key)
*/ */
@ -38,6 +39,7 @@ public interface PolicyManagerService {
/** /**
* This method adds a policy per device which should be implemented by the related plugins. * This method adds a policy per device which should be implemented by the related plugins.
*
* @param deviceId * @param deviceId
* @param deviceType * @param deviceType
* @param policy * @param policy
@ -48,15 +50,17 @@ public interface PolicyManagerService {
/** /**
* This method adds a policy to device type by the related device type plugins. * This method adds a policy to device type by the related device type plugins.
*
* @param deviceType * @param deviceType
* @param policy * @param policy
* @return primary key (generated key) * @return primary key (generated key)
*/ */
int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToDeviceType(String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException;
/** /**
* This method adds the policy to specific role. * This method adds the policy to specific role.
*
* @param roleName * @param roleName
* @param policy * @param policy
* @return primary key (generated key) * @return primary key (generated key)
@ -65,30 +69,34 @@ public interface PolicyManagerService {
/** /**
* This method returns the policy of whole platform * This method returns the policy of whole platform
*
* @return * @return
*/ */
Policy getPolicy(); Policy getPolicy();
/** /**
* This method gives the device specific policy. * This method gives the device specific policy.
*
* @param deviceId * @param deviceId
* @param deviceType * @param deviceType
* @return Policy * @return Policy
*/ */
Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException; Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException;
/** /**
* This method returns the device type specific policy. * This method returns the device type specific policy.
*
* @param deviceType * @param deviceType
* @return Policy * @return Policy
*/ */
Policy getPolicyOfDeviceType(String deviceType) throws FeatureManagementException, PolicyManagementException; Policy getPolicyOfDeviceType(String deviceType) throws FeatureManagementException, PolicyManagementException;
/** /**
* This method returns the role specific policy. * This method returns the role specific policy.
*
* @param roleName * @param roleName
* @return * @return
*/ */
@ -96,4 +104,11 @@ public interface PolicyManagerService {
Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException; Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException;
boolean isPolicyAvailableForDevice(String deviceId, String deviceType) throws PolicyManagementException;
boolean isPolicyUsed(String deviceId, String deviceType) throws PolicyManagementException;
void setPolicyUsed(String deviceId, String deviceType, Policy policy) throws PolicyManagementException;
} }

@ -16,7 +16,6 @@
package cdm.api.android; package cdm.api.android;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import javax.ws.rs.POST; import javax.ws.rs.POST;
@ -31,9 +30,10 @@ public class Authentication {
@POST @POST
@Path("/device/") @Path("/device/")
@Produces("application/json") @Produces("application/json")
public String authenticateDevice(@FormParam("username") String username, @FormParam("password") String password) { public String authenticateDevice(@FormParam("username") String username,
@FormParam("password") String password) {
JsonObject result = new JsonObject(); JsonObject result = new JsonObject();
result.addProperty("senderId","jwwfowrjwqporqwrpqworpq"); result.addProperty("senderId", "jwwfowrjwqporqwrpqworpq");
return result.toString(); return result.toString();
} }
@ -42,10 +42,4 @@ public class Authentication {
public String getLicense() { public String getLicense() {
return "License Agreement"; return "License Agreement";
} }
@POST
@Path("/device/enroll")
public Response enrollDevice() {
return Response.status(201).entity("Registration Successful").build();
}
} }

@ -17,8 +17,9 @@
package cdm.api.android; package cdm.api.android;
import cdm.api.android.util.AndroidAPIUtils; import cdm.api.android.util.AndroidAPIUtils;
import cdm.api.android.util.AndroidConstants;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
@ -26,7 +27,6 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -46,22 +46,18 @@ public class Device {
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
try { try {
if(dmService!=null){ if (dmService != null) {
result = dmService.getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); result = dmService.getAllDevices(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
@ -71,12 +67,14 @@ public class Device {
} }
switch (status) { switch (status) {
case 1: case 1:
String response = new Gson().toJson(result); if(result!=null){
return Response.status(200).entity(response).build(); String response = new Gson().toJson(result);
return Response.status(HttpStatus.SC_OK).entity(response).build();
}
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(400).entity("Unable to fetch device list").build(); return Response.status(HttpStatus.SC_NOT_FOUND).entity("Unable to fetch device list").build();
} }
@GET @GET
@ -85,25 +83,21 @@ public class Device {
int status = 0; int status = 0;
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
org.wso2.carbon.device.mgt.common.Device device = new org.wso2.carbon.device.mgt.common.Device(); org.wso2.carbon.device.mgt.common.Device device =
new org.wso2.carbon.device.mgt.common.Device();
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try { try {
if(dmService!=null){ if (dmService != null) {
device = dmService.getDevice(deviceIdentifier); device = dmService.getDevice(deviceIdentifier);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
@ -113,12 +107,15 @@ public class Device {
} }
switch (status) { switch (status) {
case 1: case 1:
String response = new Gson().toJson(device); if(device!=null) {
return Response.status(200).entity(response).build(); String response = new Gson().toJson(device);
return Response.status(HttpStatus.SC_OK).entity(response).build();
}
break;
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(400).entity("Unable to fetch device information").build(); return Response.status(HttpStatus.SC_NOT_FOUND).entity("Unable to fetch device information").build();
} }
@PUT @PUT
@ -129,23 +126,19 @@ public class Device {
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
org.wso2.carbon.device.mgt.common.Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload); org.wso2.carbon.device.mgt.common.Device device =
AndroidAPIUtils.convertToDeviceObject(jsonPayload);
try { try {
if(dmService!=null){ if (dmService != null) {
result = dmService.updateDeviceInfo(device); result = dmService.updateDeviceInfo(device);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while modifying the device information"; msg = "Error occurred while modifying the device information";
@ -155,12 +148,12 @@ public class Device {
switch (status) { switch (status) {
case 1: case 1:
if (result) { if (result) {
return Response.status(200).entity("Device has modified").build(); return Response.status(HttpStatus.SC_OK).entity("Device has modified").build();
} }
break; break;
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(400).entity("Update device has failed").build(); return Response.status(HttpStatus.SC_NOT_MODIFIED).entity("Update device has failed").build();
} }
} }

@ -17,14 +17,15 @@
package cdm.api.android; package cdm.api.android;
import cdm.api.android.util.AndroidAPIUtils; import cdm.api.android.util.AndroidAPIUtils;
import cdm.api.android.util.AndroidConstants;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.httpclient.HttpStatus;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -43,25 +44,19 @@ public class Enrollment {
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload); Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload);
try { try {
if(dmService!=null){ if (dmService != null) {
result = dmService.enrollDevice(device); result = dmService.enrollDevice(device);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while enrolling the device"; msg = "Error occurred while enrolling the device";
log.error(msg, e); log.error(msg, e);
@ -70,13 +65,13 @@ public class Enrollment {
switch (status) { switch (status) {
case 1: case 1:
if (result) { if (result) {
return Response.status(201).entity("Registration Successful").build(); return Response.status(HttpStatus.SC_CREATED).entity("Device enrollment has succeeded").build();
} }
break; break;
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(400).entity("Registration Failed").build(); return Response.status(HttpStatus.SC_BAD_REQUEST).entity("Device enrollment has Failed").build();
} }
@GET @GET
@ -87,23 +82,18 @@ public class Enrollment {
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try { try {
if(dmService!=null){ if (dmService != null) {
result = dmService.isEnrolled(deviceIdentifier); result = dmService.isEnrolled(deviceIdentifier);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while checking enrollment of the device"; msg = "Error occurred while checking enrollment of the device";
@ -113,40 +103,35 @@ public class Enrollment {
switch (status) { switch (status) {
case 1: case 1:
if (result) { if (result) {
return Response.status(200).entity(result).build(); return Response.status(HttpStatus.SC_OK).entity(result).build();
} }
break; break;
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(404).entity(result).build(); return Response.status(HttpStatus.SC_NOT_FOUND).entity(result).build();
} }
@PUT @PUT
@Path("{id}") @Path("{id}")
public Response modifyEnrollment(@PathParam("id") String id,String jsonPayload) { public Response modifyEnrollment(@PathParam("id") String id, String jsonPayload) {
boolean result = false; boolean result = false;
int status = 0; int status = 0;
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload); Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload);
try { try {
if(dmService!=null){ if (dmService != null) {
result = dmService.modifyEnrollment(device); result = dmService.modifyEnrollment(device);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while modifying enrollment of the device"; msg = "Error occurred while modifying enrollment of the device";
@ -156,13 +141,13 @@ public class Enrollment {
switch (status) { switch (status) {
case 1: case 1:
if (result) { if (result) {
return Response.status(200).entity("Device information modified").build(); return Response.status(HttpStatus.SC_OK).entity("Enrollment information has modified").build();
} }
break; break;
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(400).entity("Update enrollment failed").build(); return Response.status(HttpStatus.SC_NOT_MODIFIED).entity("Update enrollment has failed").build();
} }
@DELETE @DELETE
@ -173,23 +158,18 @@ public class Enrollment {
String msg = ""; String msg = "";
DeviceManagementService dmService; DeviceManagementService dmService;
try { try {
PrivilegedCarbonContext.startTenantFlow(); dmService = AndroidAPIUtils.getDeviceManagementService();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try { try {
if(dmService!=null){ if (dmService != null) {
result = dmService.disenrollDevice(deviceIdentifier); result = dmService.disenrollDevice(deviceIdentifier);
status = 1; status = 1;
}else{ } else {
status = -1; status = -1;
msg = "Device Manager service not available"; msg = AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE;
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
msg = "Error occurred while disenrolling the device"; msg = "Error occurred while disenrolling the device";
@ -199,12 +179,12 @@ public class Enrollment {
switch (status) { switch (status) {
case 1: case 1:
if (result) { if (result) {
return Response.status(200).entity(result).build(); return Response.status(HttpStatus.SC_OK).entity(result).build();
} }
break; break;
case -1: case -1:
return Response.status(500).entity(msg).build(); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build();
} }
return Response.status(404).entity("Device not found").build(); return Response.status(HttpStatus.SC_NOT_FOUND).entity("Device not found").build();
} }
} }

@ -19,7 +19,10 @@ package cdm.api.android.util;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.util.*; import java.util.*;
@ -112,4 +115,16 @@ public class AndroidAPIUtils {
identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
return identifier; return identifier;
} }
public static DeviceManagementService getDeviceManagementService() {
DeviceManagementService dmService;
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
dmService = (DeviceManagementService) ctx
.getOSGiService(DeviceManagementService.class, null);
return dmService;
}
} }

@ -45,4 +45,12 @@ public final class AndroidConstants {
public static final String DEVICE_PROPERTIES_KEY = "properties"; public static final String DEVICE_PROPERTIES_KEY = "properties";
public static final String DEVICE_FEATURES_KEY = "features"; public static final String DEVICE_FEATURES_KEY = "features";
} }
public final class Messages{
private Messages(){
throw new AssertionError();
}
public static final String DEVICE_MANAGER_SERVICE_NOT_AVAILABLE =
"Device Manager service not available";
}
} }

@ -105,6 +105,8 @@
<mkdir dir="${tempdir}"/> <mkdir dir="${tempdir}"/>
<mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/components"/> <mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/components"/>
<mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/deployment/server"/>
<mkdir dir="${tempdir}/wso2cdm-${project.version}/repository/deployment/server/webapps"/>
<unzip dest="${tempdir}"> <unzip dest="${tempdir}">
<fileset dir="target"> <fileset dir="target">
<include name="wso2cdm-${project.version}.zip"/> <include name="wso2cdm-${project.version}.zip"/>
@ -137,7 +139,7 @@
og4j.logger.net.sf.ehcache=ERROR og4j.logger.net.sf.ehcache=ERROR
</concat> </concat>
<!--<delete file="target/wso2cdm-${project.version}.zip"/>--> <delete file="target/wso2cdm-${project.version}.zip"/>
<delete dir="${tempdir}"/> <delete dir="${tempdir}"/>
</tasks> </tasks>
</configuration> </configuration>
@ -147,6 +149,8 @@
<phase>package</phase> <phase>package</phase>
<configuration> <configuration>
<tasks> <tasks>
<mkdir dir="target/wso2carbon-core-${project.version}/repository/deployment/server/webapps"/>
<!--<copy todir="target/wso2carbon-core-${carbon.kernel.version}/modules" <!--<copy todir="target/wso2carbon-core-${carbon.kernel.version}/modules"
overwrite="true"> overwrite="true">
<fileset dir="src/repository/modules"></fileset> <fileset dir="src/repository/modules"></fileset>

@ -40,15 +40,6 @@
</includes> </includes>
<fileMode>755</fileMode> <fileMode>755</fileMode>
</fileSet> </fileSet>
<!-- <fileSet>
<directory>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/identity/
</directory>
<outputDirectory>wso2cdm-${project.version}/dbscripts/identity</outputDirectory>
<includes>
<include>**/**.sql</include>
</includes>
</fileSet>-->
<!--Multitenancy related file --> <!--Multitenancy related file -->
<fileSet> <fileSet>
@ -98,11 +89,11 @@
<fileMode>755</fileMode> <fileMode>755</fileMode>
</fileSet> </fileSet>
<!-- copy the landing page webapp --> <!-- copy the landing page webapp -->
<fileSet> <!-- <fileSet>
<directory>src/repository/resources/stratos_root</directory> <directory>src/repository/resources/stratos_root</directory>
<outputDirectory>wso2cdm-${project.version}/repository/deployment/server/webapps/STRATOS_ROOT</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/deployment/server/webapps/STRATOS_ROOT</outputDirectory>
<fileMode>755</fileMode> <fileMode>755</fileMode>
</fileSet> </fileSet>-->
<fileSet> <fileSet>
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/modules</directory> <directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/modules</directory>
<outputDirectory>${pom.artifactId}-${project.version}/modules/</outputDirectory> <outputDirectory>${pom.artifactId}-${project.version}/modules/</outputDirectory>
@ -110,50 +101,14 @@
<include>*/**</include> <include>*/**</include>
</includes> </includes>
</fileSet> </fileSet>
<!-- <fileSet>
<directory>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/jaggeryapps
</directory>
<outputDirectory>${pom.artifactId}-${project.version}/repository/deployment/server/jaggeryapps/
</outputDirectory>
<includes>
<include>*/**</include>
</includes>
<excludes>
<exclude>**/social/</exclude>
<exclude>**/fakepublisher/</exclude>
<exclude>**/fakestore/</exclude>
</excludes>
</fileSet>-->
<!--copy jaxrs web app for OAuth feature-->
<!-- <fileSet>
<directory>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps
</directory>
<outputDirectory>${pom.artifactId}-${project.version}/repository/deployment/server/webapps</outputDirectory>
<includes>
<include>oauth2.war</include>
</includes>
</fileSet>
&lt;!&ndash;copy web app for application authentication feature &ndash;&gt;
<fileSet>
<directory>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps
</directory>
<outputDirectory>${pom.artifactId}-${project.version}/repository/deployment/server/webapps</outputDirectory>
<includes>
<include>authenticationendpoint.war</include>
</includes>
</fileSet>-->
<fileSet> <fileSet>
<directory>src/repository/conf</directory> <directory>src/repository/conf</directory>
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
<includes> <includes>
<include>**/api-manager.xml</include> <include>**/api-manager.xml</include>
<include>**/sso-idp-config.xml</include> <include>**/sso-idp-config.xml</include>
<!-- <include>**/emm-config.xml</include>--> <!-- <include>**/emm-config.xml</include>-->
</includes> </includes>
</fileSet> </fileSet>
<fileSet> <fileSet>
@ -239,35 +194,42 @@
</dependencySets> </dependencySets>
<files> <files>
<!-- <file>
<source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml
</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<file> <file>
<source> <source>../agents/android/jax-rs/target/cdm-android-api.war</source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading-environments.xml <outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps</outputDirectory>
</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>755</fileMode>
</file>--> </file>
<!-- <file>
<source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml
</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<file>
<source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading-environments.xml
</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>-->
<file> <file>
<source>src/repository/conf/tomcat/context.xml</source> <source>src/repository/conf/tomcat/context.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file> </file>
<!-- <file> <!-- <file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/event-broker.xml <source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/event-broker.xml
</source> </source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/conf/</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file>--> </file>-->
<file> <file>
<source>INSTALL.txt</source> <source>INSTALL.txt</source>
@ -307,18 +269,14 @@
</file> </file>
<!--copy default xacml policy to repository/resources/security --> <!--copy default xacml policy to repository/resources/security -->
<!-- <file> <!-- <file>
<source>src/repository/resources/policies/xacml/default/admin.xml</source> <source>src/repository/resources/policies/xacml/default/admin.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/resources/security/policies/xacml/default <outputDirectory>wso2cdm-${project.version}/repository/resources/security/policies/xacml/default
</outputDirectory> </outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
</file>--> </file>-->
<file>
<source>target/wso2carbon-core-${carbon.kernel.version}/repository/conf/log4j.properties</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/</outputDirectory>
<filtered>true</filtered>
</file>
<file> <file>
<source>src/repository/conf/multitenancy/cloud-services-desc.xml</source> <source>src/repository/conf/multitenancy/cloud-services-desc.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/multitenancy/</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/conf/multitenancy/</outputDirectory>
@ -354,15 +312,18 @@
</file> </file>
<file> <file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml</source> <source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml
</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/tomcat</outputDirectory> <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file> </file>
<!--cdm config file--> <!--cdm config file-->
<file> <file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/cdm-config.xml</source> <source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/cdm-config.xml
</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf</outputDirectory> <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>644</fileMode>
@ -370,19 +331,21 @@
<file> <file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading-environments.xml</source> <source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading-environments.xml
</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/tomcat</outputDirectory> <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/tomcat</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file> </file>
<!-- nTask Component --> <!-- nTask Component -->
<!-- <file> <!-- <file>
<source> <source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/tasks-config.xml ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/tasks-config.xml
</source> </source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/etc</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/conf/etc</outputDirectory>
</file>--> </file>-->
<!-- End - nTask Component --> <!-- End - nTask Component -->
</files> </files>

Loading…
Cancel
Save