|
|
|
@ -34,6 +34,7 @@ import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorag
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -81,10 +82,12 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
|
|
|
|
|
ApplicationList applications = applicationManager.getApplications(filter);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(applications).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while getting the application list";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -100,6 +103,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
.entity("Application with UUID " + uuid + " not found").build();
|
|
|
|
|
}
|
|
|
|
|
return Response.status(Response.Status.OK).entity(application).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
log.error("Error occurred while getting application with the uuid " + uuid, e);
|
|
|
|
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
|
|
@ -122,13 +127,15 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
applicationManager.changeLifecycle(applicationUUID, state);
|
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
|
.entity("Successfully changed the lifecycle state of the application: " + applicationUUID).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while changing the lifecycle of application: " + applicationUUID;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
return APIUtil.getResponse(e, Response.Status.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
|
.entity("Successfully changed the lifecycle state of the application: " + applicationUUID).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@ -151,6 +158,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
}
|
|
|
|
|
return Response.status(Response.Status.OK).entity(applicationManager.getLifeCycleStates(applicationUUID))
|
|
|
|
|
.build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
log.error("Application Management Exception while trying to get next states for the applications with "
|
|
|
|
|
+ "the application ID", e);
|
|
|
|
@ -176,7 +185,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
@POST
|
|
|
|
|
@Path("upload-image-artifacts/{uuid}")
|
|
|
|
|
public Response uploadApplicationArtifacts(@PathParam("uuid") String applicationUUID,
|
|
|
|
|
@Multipart("icon")Attachment iconFile, @Multipart("banner") Attachment bannerFile, @Multipart
|
|
|
|
|
@Multipart("icon") Attachment iconFile, @Multipart("banner") Attachment bannerFile, @Multipart
|
|
|
|
|
("screenshot") List<Attachment> attachmentList) {
|
|
|
|
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
|
|
|
try {
|
|
|
|
@ -208,6 +217,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
.uploadImageArtifacts(applicationUUID, iconFileStream, bannerFileStream, attachments);
|
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
|
.entity("Successfully uploaded artifacts for the application " + applicationUUID).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating the application";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
@ -224,7 +235,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
@PUT
|
|
|
|
|
@Path("upload-image-artifacts/{uuid}")
|
|
|
|
|
public Response updateApplicationArtifacts(@PathParam("uuid") String applicationUUID,
|
|
|
|
|
@Multipart("icon")Attachment iconFile, @Multipart("banner") Attachment bannerFile, @Multipart
|
|
|
|
|
@Multipart("icon") Attachment iconFile, @Multipart("banner") Attachment bannerFile, @Multipart
|
|
|
|
|
("screenshot") List<Attachment> attachmentList) {
|
|
|
|
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
|
|
|
try {
|
|
|
|
@ -262,11 +273,11 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
@PUT
|
|
|
|
|
@Consumes("application/json")
|
|
|
|
|
public Response editApplication(@Valid Application application) {
|
|
|
|
|
|
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
|
try {
|
|
|
|
|
application = applicationManager.editApplication(application);
|
|
|
|
|
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating the application";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
@ -287,6 +298,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
applicationManager.deleteApplication(uuid);
|
|
|
|
|
String responseMsg = "Successfully deleted the application: " + uuid;
|
|
|
|
|
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while deleting the application: " + uuid;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
@ -347,6 +360,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
.uploadReleaseArtifacts(applicationUUID, version, binaryFile.getDataHandler().getInputStream());
|
|
|
|
|
}
|
|
|
|
|
return Response.status(Response.Status.OK).entity(applicationRelease).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
log.error("Error while updating the application release of the application with UUID " + applicationUUID);
|
|
|
|
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
|
|
@ -396,6 +411,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
ApplicationRelease applicationRelease = applicationReleaseManager.getRelease(applicationUUID, version);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(applicationRelease).build();
|
|
|
|
|
}
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
log.error("Error while getting all the application releases for the application with the UUID "
|
|
|
|
|
+ applicationUUID, e);
|
|
|
|
@ -424,6 +441,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
.entity("Successfully deleted Application releases for the " + "application with UUID "
|
|
|
|
|
+ applicationUUID).build();
|
|
|
|
|
}
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
log.error("Error while deleting application release with the application UUID " + applicationUUID, e);
|
|
|
|
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
|
|
@ -466,6 +485,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
|
.entity("Successfully changed the default version for the " + "release channel " + channel
|
|
|
|
|
+ " for the application UUID " + applicationUUID).build();
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
log.error("Application Release Management Exception while changing the default release for the release "
|
|
|
|
|
+ "channel " + channel + " for the application with UUID " + applicationUUID + " for the version "
|
|
|
|
|