License Management

revert-dabc3590
manoj 10 years ago
parent b702a72b2f
commit 4974d49320

@ -17,15 +17,13 @@
*/
package org.wso2.cdmserver.mobileservices.android;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.cdmserver.mobileservices.android.common.AndroidAgentException;
import org.wso2.cdmserver.mobileservices.android.util.AndroidAPIUtils;
import org.wso2.cdmserver.mobileservices.android.util.Message;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.DeviceManagementServiceException;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.util.List;
@ -132,12 +130,24 @@ public class Device {
}
}
@POST
@GET
@Path("/device/license")
@Produces("text/plain")
public String getLicense() {
//TODO: need to implement fetch license from core
// AndroidAPIUtils.getDeviceManagementService().updateDeviceInfo(device);
return "License Agreement";
License license = null;
try {
try {
license = AndroidAPIUtils.getLicenseManagerService().getLicense(DeviceManagementConstants
.MobileDeviceTypes
.MOBILE_DEVICE_TYPE_ANDROID, DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
} catch (LicenseManagementException e) {
e.printStackTrace();
}
}catch(DeviceManagementServiceException deviceMgtEx){
deviceMgtEx.printStackTrace();
}
return license.getLicenseText();
}
}

@ -20,7 +20,7 @@ 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.*;
import org.wso2.carbon.device.mgt.core.LicenseManager;
import org.wso2.carbon.device.mgt.core.service.LicenseManagementService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@ -58,4 +58,23 @@ public class AndroidAPIUtils {
return dmService;
}
public static LicenseManagementService getLicenseManagerService() throws DeviceManagementServiceException{
//TODO: complete login change super tenent context
LicenseManagementService licenseManagementService;
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
licenseManagementService = (LicenseManagementService) ctx.getOSGiService(LicenseManagementService.class, null);
if (licenseManagementService == null){
String msg = "License management service not initialized";
log.error(msg);
throw new DeviceManagementServiceException(msg);
}
PrivilegedCarbonContext.endTenantFlow();
return licenseManagementService;
}
}

Loading…
Cancel
Save