use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.
the class Devices method getPackages.
/**
* Returns the list of packages deployed on a device.
*
* @param deviceId
* The client ID of the Device requested.
* @return The list of the installed packages.
*/
@GET
@Path("{deviceId}/packages")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DevicePackages getPackages(@PathParam("deviceId") String deviceId) {
DevicePackages result = packageFactory.newDeviceDeploymentPackages();
try {
KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
KapuaId id = KapuaEid.parseShortId(deviceId);
result = packageService.getInstalled(scopeId, id, null);
} catch (Throwable t) {
handleException(t);
}
return returnNotNullEntity(result);
}
use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.
the class Devices method rollbackSnapshot.
/**
* Creates a new Device based on the information provided in DeviceCreator parameter.
*
* @param deviceId
* The id of the device
* @param snapshotId
* The id of the snapshot to be rolled bac
* @return The newly created Device object.
*/
@POST
@Path("{deviceId}/rollback/{snapshotId}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response rollbackSnapshot(@PathParam("deviceId") String deviceId, @PathParam("snapshotId") String snapshotId) {
try {
KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
KapuaId id = KapuaEid.parseShortId(deviceId);
snapshotService.rollback(scopeId, id, snapshotId, null);
} catch (Throwable t) {
handleException(t);
}
return Response.ok().build();
}
use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.
the class Devices method deleteDevice.
/**
* Deletes a device based on the id provided in deviceId parameter.
*
* @param deviceId
* Provides the id of the device to delete.
*/
@DELETE
@Path("{deviceId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteDevice(@PathParam("deviceId") String deviceId) {
try {
KapuaId deviceKapuaId = KapuaEid.parseShortId(deviceId);
KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
deviceRegistryService.delete(scopeId, deviceKapuaId);
} catch (Throwable t) {
handleException(t);
}
return Response.ok().build();
}
use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.
the class Users method getAccount.
/**
* Returns the User specified by the "userId" path parameter.
*
* @param userId
* The id of the User requested.
* @return The requested User object.
*/
@GET
@Path("{userId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public User getAccount(@PathParam("userId") String userId) {
User user = null;
try {
KapuaId id = KapuaEid.parseShortId(userId);
user = userService.find(KapuaSecurityUtils.getSession().getScopeId(), id);
} catch (Throwable t) {
handleException(t);
}
return returnNotNullEntity(user);
}
use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.
the class DeviceLifeCycleServiceImpl method death.
@Override
public void death(KapuaId connectionId, KapuaDisconnectMessage message) throws KapuaException {
KapuaPayload payload = message.getPayload();
KapuaId scopeId = message.getScopeId();
KapuaId deviceId = message.getDeviceId();
//
// Device update
KapuaLocator locator = KapuaLocator.getInstance();
DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
Device device = deviceRegistryService.find(scopeId, deviceId);
//
// Event create
DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, deviceId, message.getReceivedOn(), "DEATH");
deviceEventCreator.setReceivedOn(message.getReceivedOn());
// TODO check this change
deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
deviceEventCreator.setSentOn(message.getSentOn());
KapuaPosition position = message.getPosition();
if (position != null) {
deviceEventCreator.setPosition(position);
}
deviceEventService.create(deviceEventCreator);
}
Aggregations