Fixing conflicts issue

revert-70aa11f8
Geeth Munasinghe 10 years ago
commit 1deb634f92

@ -65,7 +65,7 @@ public interface DeviceManagerService {
* @return Status of enrollment * @return Status of enrollment
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
*/ */
boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException; boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException;
/** /**
* Method to retrieve the status of a particular device. * Method to retrieve the status of a particular device.

@ -84,10 +84,10 @@ public class DeviceManager implements DeviceManagerService {
} }
@Override @Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManagerService dms = DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
return dms.isRegistered(deviceId); return dms.isEnrolled(deviceId);
} }
@Override @Override

@ -46,8 +46,8 @@ public class DeviceManagementService implements DeviceManagerService {
} }
@Override @Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManager().isRegistered(deviceId); return DeviceManagementDataHolder.getInstance().getDeviceManager().isEnrolled(deviceId);
} }
@Override @Override

@ -50,7 +50,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
} }
@Override @Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return true; return true;
} }

@ -50,7 +50,7 @@ public class IOSDeviceManagerService implements DeviceManagerService {
} }
@Override @Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return true; return true;
} }

@ -50,7 +50,7 @@ public class WindowsDeviceManagerService implements DeviceManagerService {
} }
@Override @Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return true; return true;
} }

@ -22,7 +22,7 @@
<groupId>org.wso2.cdmserver</groupId> <groupId>org.wso2.cdmserver</groupId>
<artifactId>wso2cdmserver-product</artifactId> <artifactId>wso2cdmserver-product</artifactId>
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../../../../pom.xml</relativePath> <relativePath>../../../../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -72,7 +72,8 @@
</goals> </goals>
<configuration> <configuration>
<tasks> <tasks>
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true"> <copy todir="${basedir}/../../../repository/deployment/server/webapps"
overwrite="true">
<fileset dir="${basedir}/target"> <fileset dir="${basedir}/target">
<include name="${project.artifactId}.war"/> <include name="${project.artifactId}.war"/>
</fileset> </fileset>
@ -109,62 +110,68 @@
</profile> </profile>
</profiles> </profiles>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version> <version>${cxf.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version> <version>${cxf.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId> <artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version> <version>${cxf.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
<version>${junit.version}</version> <version>${junit.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-httpclient</groupId> <groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>
<version>3.1</version> <version>3.1</version>
</dependency> <scope>provided</scope>
<dependency> </dependency>
<groupId>javax.ws.rs</groupId> <dependency>
<artifactId>jsr311-api</artifactId> <groupId>javax.ws.rs</groupId>
<version>1.1.1</version> <artifactId>jsr311-api</artifactId>
</dependency> <version>1.1.1</version>
<dependency> <scope>provided</scope>
<groupId>com.google.code.gson</groupId> </dependency>
<artifactId>gson</artifactId> <dependency>
<version>2.2.4</version> <groupId>com.google.code.gson</groupId>
</dependency> <artifactId>gson</artifactId>
<dependency> <version>2.2.4</version>
<groupId>org.wso2.carbon</groupId> </dependency>
<artifactId>org.wso2.carbon.utils</artifactId> <dependency>
</dependency> <groupId>org.wso2.carbon</groupId>
<dependency> <artifactId>org.wso2.carbon.utils</artifactId>
<groupId>org.wso2.carbon</groupId> <scope>provided</scope>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> </dependency>
<version>2.0.0-SNAPSHOT</version> <dependency>
</dependency> <groupId>org.wso2.carbon</groupId>
<dependency> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<groupId>org.wso2.carbon</groupId> <version>2.0.0-SNAPSHOT</version>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId> <scope>provided</scope>
<version>2.0.0-SNAPSHOT</version> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.wso2.carbon</groupId>
<groupId>org.wso2.carbon</groupId> <artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<artifactId>org.wso2.carbon.logging</artifactId> <version>2.0.0-SNAPSHOT</version>
</dependency> <scope>provided</scope>
</dependencies> </dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<properties> <properties>
<cxf.version>2.6.1</cxf.version> <cxf.version>2.6.1</cxf.version>
<junit.version>4.8.2</junit.version> <junit.version>4.8.2</junit.version>

@ -36,62 +36,124 @@ import javax.ws.rs.core.Response;
public class Enrollment { public class Enrollment {
private static Log log = LogFactory.getLog(Enrollment.class); private static Log log = LogFactory.getLog(Enrollment.class);
@POST @POST
public Response enrollDevice() { public Response enrollDevice() {
JsonObject result = new JsonObject(); boolean result = false;
result.addProperty("senderId","jwwfowrjwqporqwrpqworpq"); int status = 0;
String msg = "";
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); DeviceManagementService dmService = (DeviceManagementService) context
Device device = AndroidAPIUtil.convertToDeviceObject(result); .getOSGiService(DeviceManagementService.class, null);
Device device = AndroidAPIUtil.convertToDeviceObject(null);
try { try {
dmService.enrollDevice(device); result = dmService.enrollDevice(device);
status = 1;
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while enrolling the device"; msg = "Error occurred while enrolling the device";
log.error(msg, e); log.error(msg, e);
status = -1;
}
switch (status) {
case 1:
if (result) {
return Response.status(201).entity("Registration Successful").build();
}
break;
case -1:
return Response.status(500).entity(msg).build();
} }
return Response.status(201).entity("Registration Successful").build(); return Response.status(400).entity("Registration Failed").build();
} }
@GET @GET
@Path("{id}") @Path("{id}")
public Response isEnrolled(@PathParam("id") String id) { public Response isEnrolled(@PathParam("id") String id) {
boolean status = false; boolean result = false;
int status = 0;
String msg = "";
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); DeviceManagementService dmService = (DeviceManagementService) context
.getOSGiService(DeviceManagementService.class, null);
try { try {
DeviceIdentifier deviceIdentifier = AndroidAPIUtil.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtil.convertToDeviceIdentifierObject(id);
status = dmService.isRegistered(deviceIdentifier); result = dmService.isEnrolled(deviceIdentifier);
status = 1;
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while checking enrollment of the device"; msg = "Error occurred while checking enrollment of the device";
log.error(msg, e); log.error(msg, e);
status = -1;
} }
return Response.status(200).entity(status).build(); switch (status) {
case 1:
if (result) {
return Response.status(200).entity(result).build();
}
break;
case -1:
return Response.status(500).entity(msg).build();
}
return Response.status(404).entity(result).build();
} }
@PUT @PUT
@Consumes("application/json") @Consumes("application/json")
@Path("{id}") @Path("{id}")
public Response modifyEnrollment(@PathParam("id") String id) { public Response modifyEnrollment(@PathParam("id") String id) {
boolean result = false;
int status = 0;
String msg = "";
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); DeviceManagementService dmService = (DeviceManagementService) context
.getOSGiService(DeviceManagementService.class, null);
Device device = AndroidAPIUtil.convertToDeviceObject(null);
try { try {
dmService.isRegistered(null); result = dmService.modifyEnrollment(device);
status = 1;
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
e.printStackTrace(); msg = "Error occurred while modifying enrollment of the device";
log.error(msg, e);
status = -1;
} }
return Response.status(201).entity("Registration Successful").build(); switch (status) {
case 1:
if (result) {
return Response.status(200).entity("Device information modified").build();
}
break;
case -1:
return Response.status(500).entity(msg).build();
}
return Response.status(400).entity("Update enrollment failed").build();
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
public Response disenrollDevice(@PathParam("id") String id) { public Response disenrollDevice(@PathParam("id") String id) {
boolean result = false;
int status = 0;
String msg = "";
CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null); DeviceManagementService dmService = (DeviceManagementService) context
.getOSGiService(DeviceManagementService.class, null);
try { try {
dmService.isRegistered(null); DeviceIdentifier deviceIdentifier = AndroidAPIUtil.convertToDeviceIdentifierObject(id);
result = dmService.disenrollDevice(deviceIdentifier);
status = 1;
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
e.printStackTrace(); msg = "Error occurred while disenrolling the device";
log.error(msg, e);
status = -1;
}
switch (status) {
case 1:
if (result) {
return Response.status(200).entity(result).build();
}
break;
case -1:
return Response.status(500).entity(msg).build();
} }
return Response.status(201).entity("Registration Successful").build(); return Response.status(404).entity("Device not found").build();
} }
} }

Loading…
Cancel
Save