Search in sources :

Example 11 with KapuaId

use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.

the class Accounts method deleteAccount.

/**
 * Deletes an account based on the information provided in Account parameter.
 *
 * @param accountId Provides the information to update the account.
 * @return The updated created Account object.
 */
@DELETE
@Path("{accountId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteAccount(@PathParam("accountId") String accountId) {
    try {
        KapuaId accountKapuaId = KapuaEid.parseShortId(accountId);
        KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
        accountService.delete(scopeId, accountKapuaId);
    } catch (Throwable t) {
        handleException(t);
    }
    return Response.ok().build();
}
Also used : KapuaId(org.eclipse.kapua.model.id.KapuaId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 12 with KapuaId

use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.

the class Accounts method getAccount.

/**
 * Returns the Account specified by the "id" path parameter.
 *
 * @param accountId The id of the Account requested.
 * @return The requested Account object.
 */
@GET
@Path("{accountId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Account getAccount(@PathParam("accountId") String accountId) {
    Account account = null;
    try {
        KapuaId id = KapuaEid.parseShortId(accountId);
        account = accountService.find(id);
    } catch (Throwable t) {
        handleException(t);
    }
    return returnNotNullEntity(account);
}
Also used : Account(org.eclipse.kapua.service.account.Account) KapuaId(org.eclipse.kapua.model.id.KapuaId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 13 with KapuaId

use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.

the class Devices method getSnapshots.

/**
 * Returns the list of all the Snapshots available on the device.
 *
 * @return The list of Snapshot Ids.
 */
@GET
@Path("{deviceId}/snapshots")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DeviceSnapshots getSnapshots(@PathParam("deviceId") String deviceId) {
    DeviceSnapshots deviceSnapshots = snapshotFactory.newDeviceSnapshots();
    try {
        KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
        KapuaId id = KapuaEid.parseShortId(deviceId);
        deviceSnapshots = snapshotService.get(scopeId, id, null);
    } catch (Throwable t) {
        handleException(t);
    }
    return returnNotNullEntity(deviceSnapshots);
}
Also used : KapuaId(org.eclipse.kapua.model.id.KapuaId) DeviceSnapshots(org.eclipse.kapua.service.device.management.snapshot.DeviceSnapshots)

Example 14 with KapuaId

use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.

the class Devices method uninstallPackage.

/**
 * Uninstalls a package deployed on a device.
 *
 * @param deviceId
 *            The device ID of the Device requested.
 * @param request
 *            Mandatory object with all the informations
 *            needed to uninstall a package.
 * @return The list of the installed packages.
 */
@DELETE
@Path("{deviceId}/packages")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response uninstallPackage(@PathParam("deviceId") String deviceId, DevicePackageUninstallRequest request) {
    try {
        KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
        KapuaId id = KapuaEid.parseShortId(deviceId);
        packageService.uninstallExec(scopeId, id, request, null);
    } catch (Throwable t) {
        handleException(t);
    }
    return Response.ok().build();
}
Also used : KapuaId(org.eclipse.kapua.model.id.KapuaId)

Example 15 with KapuaId

use of org.eclipse.kapua.model.id.KapuaId in project kapua by eclipse.

the class Devices method installPackage.

/**
 * Install a new deployment package on a device.
 *
 * @param deviceId
 *            The client ID of the Device requested.
 * @param request
 *            Mandatory object with all the informations
 *            needed to download a package.
 * @return The list of the installed packages.
 */
@POST
@Path("{deviceId}/packages")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response installPackage(@PathParam("deviceId") String deviceId, DevicePackageDownloadRequest request) {
    try {
        KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
        KapuaId id = KapuaEid.parseShortId(deviceId);
        packageService.downloadExec(scopeId, id, request, null);
    } catch (Throwable t) {
        handleException(t);
    }
    return Response.ok().build();
}
Also used : KapuaId(org.eclipse.kapua.model.id.KapuaId)

Aggregations

KapuaId (org.eclipse.kapua.model.id.KapuaId)75 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)54 Account (org.eclipse.kapua.service.account.Account)14 AccountService (org.eclipse.kapua.service.account.AccountService)14 ArrayList (java.util.ArrayList)13 Date (java.util.Date)11 Device (org.eclipse.kapua.service.device.registry.Device)11 Test (org.junit.Test)11 DeviceRegistryService (org.eclipse.kapua.service.device.registry.DeviceRegistryService)10 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)9 DeviceEventFactory (org.eclipse.kapua.service.device.registry.event.DeviceEventFactory)9 DeviceEventService (org.eclipse.kapua.service.device.registry.event.DeviceEventService)9 PermissionFactory (org.eclipse.kapua.service.authorization.permission.PermissionFactory)8 IdGeneratorService (org.eclipse.kapua.service.generator.id.IdGeneratorService)8 GwtAccount (org.eclipse.kapua.app.console.shared.model.GwtAccount)7 GwtAccountService (org.eclipse.kapua.app.console.shared.service.GwtAccountService)7 KapuaEid (org.eclipse.kapua.commons.model.id.KapuaEid)7 DeviceEventCreator (org.eclipse.kapua.service.device.registry.event.DeviceEventCreator)7 User (org.eclipse.kapua.service.user.User)7 GwtDevice (org.eclipse.kapua.app.console.shared.model.GwtDevice)6