|
|
@ -29,6 +29,8 @@ import org.wso2.carbon.device.application.mgt.common.dto.LifecycleStateDTO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.response.ApplicationRelease;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
|
|
|
@ -103,13 +105,24 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
@DefaultValue("PUBLISHED") @QueryParam("state") String state) {
|
|
|
|
@DefaultValue("PUBLISHED") @QueryParam("state") String state) {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ApplicationDTO application = applicationManager.getApplicationById(appId, state);
|
|
|
|
Application application = applicationManager.getApplicationById(appId, state);
|
|
|
|
|
|
|
|
if (application == null){
|
|
|
|
|
|
|
|
String msg = "Couldn't found an application release which is in " + state + " state for application id "
|
|
|
|
|
|
|
|
+ appId;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
return Response.status(Response.Status.OK).entity(application).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(application).build();
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
String msg = "ApplicationDTO with application id: " + appId + " not found";
|
|
|
|
String msg = "ApplicationDTO with application id: " + appId + " not found";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch(ForbiddenException e){
|
|
|
|
|
|
|
|
String msg = "You don't have permission to access the application. application id: " + appId;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (ApplicationManagementException e) {
|
|
|
|
String msg = "Error occurred while getting application with the id " + appId;
|
|
|
|
String msg = "Error occurred while getting application with the id " + appId;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
@ -143,8 +156,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
applicationManager.validateAppCreatingRequest(applicationWrapper);
|
|
|
|
applicationManager.validateAppCreatingRequest(applicationWrapper);
|
|
|
|
applicationManager.validateReleaseCreatingRequest(applicationWrapper.getApplicationReleaseWrappers().get(0),
|
|
|
|
applicationManager.validateReleaseCreatingRequest(applicationWrapper.getApplicationReleaseWrappers().get(0),
|
|
|
|
applicationWrapper.getType());
|
|
|
|
applicationWrapper.getType());
|
|
|
|
applicationManager.isValidAttachmentSet(binaryFile, iconFile, bannerFile, attachmentList,
|
|
|
|
applicationManager.validateBinaryArtifact(binaryFile, applicationWrapper.getType());
|
|
|
|
applicationWrapper.getType());
|
|
|
|
applicationManager.validateImageArtifacts(iconFile, bannerFile, attachmentList);
|
|
|
|
|
|
|
|
|
|
|
|
// Created new application entry
|
|
|
|
// Created new application entry
|
|
|
|
Application application = applicationManager.createApplication(applicationWrapper,
|
|
|
|
Application application = applicationManager.createApplication(applicationWrapper,
|
|
|
@ -167,99 +180,63 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @POST
|
|
|
|
@POST
|
|
|
|
// @Consumes("multipart/mixed")
|
|
|
|
@Consumes("multipart/mixed")
|
|
|
|
// @Path("/{deviceType}/{appType}/{appId}")
|
|
|
|
@Path("/{appType}/{appId}")
|
|
|
|
// public Response createRelease(
|
|
|
|
public Response createRelease(
|
|
|
|
// @PathParam("deviceType") String deviceType,
|
|
|
|
@PathParam("appType") String appType,
|
|
|
|
// @PathParam("appType") String appType,
|
|
|
|
@PathParam("appId") int appId,
|
|
|
|
// @PathParam("appId") int appId,
|
|
|
|
@Multipart("applicationRelease") ApplicationReleaseWrapper applicationReleaseWrapper,
|
|
|
|
// @Multipart("applicationRelease") ApplicationReleaseDTO applicationRelease,
|
|
|
|
@Multipart("binaryFile") Attachment binaryFile,
|
|
|
|
// @Multipart("binaryFile") Attachment binaryFile,
|
|
|
|
@Multipart("icon") Attachment iconFile,
|
|
|
|
// @Multipart("icon") Attachment iconFile,
|
|
|
|
@Multipart("banner") Attachment bannerFile,
|
|
|
|
// @Multipart("banner") Attachment bannerFile,
|
|
|
|
@Multipart("screenshot1") Attachment screenshot1,
|
|
|
|
// @Multipart("screenshot1") Attachment screenshot1,
|
|
|
|
@Multipart("screenshot2") Attachment screenshot2,
|
|
|
|
// @Multipart("screenshot2") Attachment screenshot2,
|
|
|
|
@Multipart("screenshot3") Attachment screenshot3) {
|
|
|
|
// @Multipart("screenshot3") Attachment screenshot3) {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
// ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
List<Attachment> attachmentList = new ArrayList<>();
|
|
|
|
// ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
|
|
|
|
|
|
// InputStream iconFileStream;
|
|
|
|
if (screenshot1 != null) {
|
|
|
|
// InputStream bannerFileStream;
|
|
|
|
attachmentList.add(screenshot1);
|
|
|
|
// List<InputStream> attachments = new ArrayList<>();
|
|
|
|
}
|
|
|
|
// List<Attachment> attachmentList = new ArrayList<>();
|
|
|
|
if (screenshot2 != null) {
|
|
|
|
// attachmentList.add(screenshot1);
|
|
|
|
attachmentList.add(screenshot2);
|
|
|
|
// if (screenshot2 != null) {
|
|
|
|
}
|
|
|
|
// attachmentList.add(screenshot2);
|
|
|
|
if (screenshot3 != null) {
|
|
|
|
// }
|
|
|
|
attachmentList.add(screenshot3);
|
|
|
|
// if (screenshot3 != null) {
|
|
|
|
}
|
|
|
|
// attachmentList.add(screenshot3);
|
|
|
|
|
|
|
|
// }
|
|
|
|
try {
|
|
|
|
//
|
|
|
|
applicationManager.validateReleaseCreatingRequest(applicationReleaseWrapper, appType);
|
|
|
|
// try {
|
|
|
|
applicationManager.validateBinaryArtifact(binaryFile, appType);
|
|
|
|
// applicationManager
|
|
|
|
applicationManager.validateImageArtifacts(iconFile, bannerFile, attachmentList);
|
|
|
|
// .validateReleaseCreatingRequest(applicationRelease, appType, binaryFile, iconFile, bannerFile,
|
|
|
|
|
|
|
|
// attachmentList);
|
|
|
|
// Created new application release
|
|
|
|
//
|
|
|
|
ApplicationRelease release = applicationManager.createRelease(appId, applicationReleaseWrapper,
|
|
|
|
// // The application executable artifacts such as apks are uploaded.
|
|
|
|
constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList));
|
|
|
|
// if (!ApplicationType.ENTERPRISE.toString().equals(appType)) {
|
|
|
|
if (release != null) {
|
|
|
|
// applicationRelease = applicationStorageManager
|
|
|
|
return Response.status(Response.Status.CREATED).entity(release).build();
|
|
|
|
// .uploadReleaseArtifact(applicationRelease, appType, deviceType, null);
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
log.error("ApplicationDTO Creation Failed");
|
|
|
|
// applicationRelease = applicationStorageManager
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
|
|
|
// .uploadReleaseArtifact(applicationRelease, appType, deviceType,
|
|
|
|
}
|
|
|
|
// binaryFile.getDataHandler().getInputStream());
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
// if (applicationRelease.getInstallerName() == null || applicationRelease.getAppHashValue() == null) {
|
|
|
|
String msg = "Error occurred while creating the application";
|
|
|
|
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
|
|
|
log.error(msg, e);
|
|
|
|
// }
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
// }
|
|
|
|
} catch (RequestValidatingException e) {
|
|
|
|
//
|
|
|
|
String msg = "Error occurred while handling the application creating request";
|
|
|
|
// iconFileStream = iconFile.getDataHandler().getInputStream();
|
|
|
|
log.error(msg, e);
|
|
|
|
// bannerFileStream = bannerFile.getDataHandler().getInputStream();
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// for (Attachment screenshot : attachmentList) {
|
|
|
|
}
|
|
|
|
// attachments.add(screenshot.getDataHandler().getInputStream());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // Upload images
|
|
|
|
|
|
|
|
// applicationRelease = applicationStorageManager
|
|
|
|
|
|
|
|
// .uploadImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments);
|
|
|
|
|
|
|
|
// applicationRelease.setUuid(UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // Created new application release entry
|
|
|
|
|
|
|
|
// ApplicationReleaseDTO release = applicationManager.createRelease(appId, applicationRelease);
|
|
|
|
|
|
|
|
// if (release != null) {
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.CREATED).entity(release).build();
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// log.error("ApplicationDTO Creation Failed");
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (ApplicationManagementException e) {
|
|
|
|
|
|
|
|
// String msg = "Error occurred while creating the application";
|
|
|
|
|
|
|
|
// log.error(msg, e);
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
|
|
|
|
// } catch (ResourceManagementException e) {
|
|
|
|
|
|
|
|
// String msg = "Error occurred while uploading the releases artifacts of the application ID: " + appId;
|
|
|
|
|
|
|
|
// log.error(msg, e);
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
|
|
|
// String msg = "Error while uploading binary file and resources for the application release of the "
|
|
|
|
|
|
|
|
// + "application ID: " + appId;
|
|
|
|
|
|
|
|
// log.error(msg, e);
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
|
|
|
|
// } catch (RequestValidatingException e) {
|
|
|
|
|
|
|
|
// String msg = "Error occurred while handling the application creating request";
|
|
|
|
|
|
|
|
// log.error(msg, e);
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@PUT
|
|
|
|
@PUT
|
|
|
|
@Consumes("multipart/mixed")
|
|
|
|
@Consumes("multipart/mixed")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
@Path("/image-artifacts/{appId}/{uuid}")
|
|
|
|
@Path("/image-artifacts/{uuid}")
|
|
|
|
public Response updateApplicationImageArtifacts(
|
|
|
|
public Response updateApplicationImageArtifacts(
|
|
|
|
@PathParam("appId") int appId,
|
|
|
|
|
|
|
|
@PathParam("uuid") String applicationReleaseUuid,
|
|
|
|
@PathParam("uuid") String applicationReleaseUuid,
|
|
|
|
@Multipart("icon") Attachment iconFile,
|
|
|
|
@Multipart("icon") Attachment iconFile,
|
|
|
|
@Multipart("banner") Attachment bannerFile,
|
|
|
|
@Multipart("banner") Attachment bannerFile,
|
|
|
@ -267,89 +244,72 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
@Multipart("screenshot2") Attachment screenshot2,
|
|
|
|
@Multipart("screenshot2") Attachment screenshot2,
|
|
|
|
@Multipart("screenshot3") Attachment screenshot3) {
|
|
|
|
@Multipart("screenshot3") Attachment screenshot3) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
InputStream iconFileStream = null;
|
|
|
|
List<Attachment> attachments = new ArrayList<>();
|
|
|
|
InputStream bannerFileStream = null;
|
|
|
|
|
|
|
|
List<InputStream> attachments = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iconFile != null) {
|
|
|
|
if (screenshot1 != null) {
|
|
|
|
iconFileStream = iconFile.getDataHandler().getInputStream();
|
|
|
|
attachments.add(screenshot1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bannerFile != null) {
|
|
|
|
|
|
|
|
bannerFileStream = bannerFile.getDataHandler().getInputStream();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attachments.add(screenshot1.getDataHandler().getInputStream());
|
|
|
|
|
|
|
|
if (screenshot2 != null) {
|
|
|
|
if (screenshot2 != null) {
|
|
|
|
attachments.add(screenshot2.getDataHandler().getInputStream());
|
|
|
|
attachments.add(screenshot2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (screenshot3 != null) {
|
|
|
|
if (screenshot3 != null) {
|
|
|
|
attachments.add(screenshot3.getDataHandler().getInputStream());
|
|
|
|
attachments.add(screenshot3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
applicationManager
|
|
|
|
applicationManager.validateImageArtifacts(iconFile, bannerFile, attachments);
|
|
|
|
.updateApplicationImageArtifact(appId, applicationReleaseUuid, iconFileStream, bannerFileStream,
|
|
|
|
applicationManager.updateApplicationImageArtifact(applicationReleaseUuid,
|
|
|
|
attachments);
|
|
|
|
constructApplicationArtifact(null, iconFile, bannerFile, attachments));
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
.entity("Successfully uploaded artifacts for the application " + applicationReleaseUuid).build();
|
|
|
|
.entity("Successfully uploaded artifacts for the application " + applicationReleaseUuid).build();
|
|
|
|
|
|
|
|
} catch (RequestValidatingException e) {
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
|
|
|
} catch (ValidationException e) {
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
|
|
|
|
|
|
|
} catch (ForbiddenException e) {
|
|
|
|
} catch (ForbiddenException e) {
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
return Response.status(Response.Status.FORBIDDEN).entity(e.getMessage()).build();
|
|
|
|
return Response.status(Response.Status.FORBIDDEN).entity(e.getMessage()).build();
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
String msg = "Error occurred while updating the application image artifacts for app id: " + appId
|
|
|
|
String msg = "Error occurred while updating the application image artifacts for application release uuid: "
|
|
|
|
+ " application release uuid: " + applicationReleaseUuid;
|
|
|
|
+ applicationReleaseUuid;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
String msg =
|
|
|
|
|
|
|
|
"Exception while trying to read icon, banner files for the application " + applicationReleaseUuid;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@PUT
|
|
|
|
@PUT
|
|
|
|
@Consumes("multipart/mixed")
|
|
|
|
@Consumes("multipart/mixed")
|
|
|
|
@Path("/app-artifacts/{deviceType}/{appType}/{appId}/{uuid}")
|
|
|
|
@Path("/app-artifact/{deviceType}/{appType}/{uuid}")
|
|
|
|
public Response updateApplicationArtifact(
|
|
|
|
public Response updateApplicationArtifact(
|
|
|
|
@PathParam("deviceType") String deviceType,
|
|
|
|
@PathParam("deviceType") String deviceType,
|
|
|
|
@PathParam("appType") String appType,
|
|
|
|
@PathParam("appType") String appType,
|
|
|
|
@PathParam("appId") int applicationId,
|
|
|
|
|
|
|
|
@PathParam("uuid") String applicationReleaseUuid,
|
|
|
|
@PathParam("uuid") String applicationReleaseUuid,
|
|
|
|
@Multipart("binaryFile") Attachment binaryFile) {
|
|
|
|
@Multipart("binaryFile") Attachment binaryFile) {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (binaryFile == null) {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST)
|
|
|
|
|
|
|
|
.entity("binary file is NULL, hence invalid request to update application release artifact for application release UUID: "
|
|
|
|
|
|
|
|
+ applicationReleaseUuid).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ApplicationType.ENTERPRISE.toString().equals(appType)) {
|
|
|
|
if (!ApplicationType.ENTERPRISE.toString().equals(appType)) {
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity("If ApplicationDTO type is " + appType
|
|
|
|
String msg = "If ApplicationDTO type is " + appType
|
|
|
|
+ ", therefore you don't have application release artifact to update for application release UUID: "
|
|
|
|
+ ", therefore you don't have application release artifact to update for application release UUID: "
|
|
|
|
+ applicationReleaseUuid).build();
|
|
|
|
+ applicationReleaseUuid;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
APIUtil.getApplicationManager().updateApplicationArtifact(applicationId, deviceType, applicationReleaseUuid,
|
|
|
|
applicationManager.validateBinaryArtifact(binaryFile, appType);
|
|
|
|
binaryFile.getDataHandler().getInputStream());
|
|
|
|
applicationManager.updateApplicationArtifact(deviceType, appType, applicationReleaseUuid,
|
|
|
|
|
|
|
|
constructApplicationArtifact(binaryFile, null, null, null));
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
.entity("Successfully uploaded artifacts for the application release. UUID is "
|
|
|
|
.entity("Successfully uploaded artifacts for the application release. UUID is "
|
|
|
|
+ applicationReleaseUuid).build();
|
|
|
|
+ applicationReleaseUuid).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (RequestValidatingException e) {
|
|
|
|
String msg = "Error occurred while trying to read icon, banner files for the application release"
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
+ applicationReleaseUuid;
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
|
|
|
} catch (ValidationException e) {
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
|
|
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
log.error("Error occurred while updating the image artifacts of the application with the uuid "
|
|
|
|
log.error("Error occurred while updating the image artifacts of the application with the uuid "
|
|
|
|
+ applicationReleaseUuid, e);
|
|
|
|
+ applicationReleaseUuid, e);
|
|
|
@ -363,10 +323,13 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
@Path("/{appId}")
|
|
|
|
@Path("/{appId}")
|
|
|
|
public Response updateApplication(
|
|
|
|
public Response updateApplication(
|
|
|
|
@PathParam("appId") int applicationId,
|
|
|
|
@PathParam("appId") int applicationId,
|
|
|
|
@Valid ApplicationDTO application) {
|
|
|
|
@Valid ApplicationWrapper applicationWrapper) {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
application = applicationManager.updateApplication(applicationId, application);
|
|
|
|
//todo wrong
|
|
|
|
|
|
|
|
applicationManager.updateApplication(applicationId, applicationWrapper);
|
|
|
|
|
|
|
|
return Response.status(Response.Status.OK)
|
|
|
|
|
|
|
|
.entity("Application was updated successfully. ApplicationID " + applicationId).build();
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
log.error(e.getMessage());
|
|
|
|
log.error(e.getMessage());
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
|
|
@ -378,7 +341,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Response.status(Response.Status.OK).entity(application).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -610,65 +572,71 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|
|
|
applicationArtifact.setInstallerStream(installerStream);
|
|
|
|
applicationArtifact.setInstallerStream(installerStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dataHandler = iconFile.getDataHandler();
|
|
|
|
if (iconFile != null) {
|
|
|
|
String iconFileName = dataHandler.getName();
|
|
|
|
dataHandler = iconFile.getDataHandler();
|
|
|
|
InputStream iconStream = dataHandler.getInputStream();
|
|
|
|
String iconFileName = dataHandler.getName();
|
|
|
|
|
|
|
|
InputStream iconStream = dataHandler.getInputStream();
|
|
|
|
|
|
|
|
|
|
|
|
if (iconStream == null) {
|
|
|
|
if (iconStream == null) {
|
|
|
|
String msg = "Stream of the application release icon is null. Hence can't proceed. Please "
|
|
|
|
String msg = "Stream of the application release icon is null. Hence can't proceed. Please "
|
|
|
|
+ "verify the uploaded icon file.";
|
|
|
|
+ "verify the uploaded icon file.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iconFileName == null) {
|
|
|
|
if (iconFileName == null) {
|
|
|
|
String msg =
|
|
|
|
String msg = "Icon file name retrieving is failed.. Hence can't proceed. Please verify the "
|
|
|
|
"Icon file name retrieving is failed.. Hence can't proceed. Please verify the " + "icon file.";
|
|
|
|
+ "icon file.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationArtifact.setIconName(iconFileName);
|
|
|
|
applicationArtifact.setIconName(iconFileName);
|
|
|
|
applicationArtifact.setIconStream(iconStream);
|
|
|
|
applicationArtifact.setIconStream(iconStream);
|
|
|
|
|
|
|
|
|
|
|
|
dataHandler = bannerFile.getDataHandler();
|
|
|
|
|
|
|
|
String bannerFileName = dataHandler.getName();
|
|
|
|
|
|
|
|
InputStream bannerStream = dataHandler.getInputStream();
|
|
|
|
|
|
|
|
if (bannerStream == null) {
|
|
|
|
|
|
|
|
String msg = "Stream of the application release banner is null. Hence can't proceed. Please "
|
|
|
|
|
|
|
|
+ "verify the uploaded banner file.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bannerFileName == null) {
|
|
|
|
|
|
|
|
String msg = "Banner file name retrieving is failed.. Hence can't proceed. Please verify the "
|
|
|
|
|
|
|
|
+ "banner file.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationArtifact.setBannerName(bannerFileName);
|
|
|
|
|
|
|
|
applicationArtifact.setBannerStream(bannerStream);
|
|
|
|
if (bannerFile != null) {
|
|
|
|
|
|
|
|
dataHandler = bannerFile.getDataHandler();
|
|
|
|
Map<String, InputStream> scrrenshotData = new HashMap<>();
|
|
|
|
String bannerFileName = dataHandler.getName();
|
|
|
|
for (Attachment sc : attachmentList) {
|
|
|
|
InputStream bannerStream = dataHandler.getInputStream();
|
|
|
|
dataHandler = sc.getDataHandler();
|
|
|
|
if (bannerStream == null) {
|
|
|
|
String screenshotrFileName = dataHandler.getName();
|
|
|
|
String msg = "Stream of the application release banner is null. Hence can't proceed. Please "
|
|
|
|
InputStream screenshotStream = dataHandler.getInputStream();
|
|
|
|
+ "verify the uploaded banner file.";
|
|
|
|
if (screenshotStream == null) {
|
|
|
|
|
|
|
|
String msg =
|
|
|
|
|
|
|
|
"Stream of one of the application release screenshot is null. Hence can't proceed. Please "
|
|
|
|
|
|
|
|
+ "verify the uploaded screenshots.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (screenshotrFileName == null) {
|
|
|
|
if (bannerFileName == null) {
|
|
|
|
String msg =
|
|
|
|
String msg = "Banner file name retrieving is failed.. Hence can't proceed. Please verify the "
|
|
|
|
"Screenshot file name retrieving is failed for one screenshot. Hence can't proceed. Please verify the "
|
|
|
|
+ "banner file.";
|
|
|
|
+ "screenshots.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scrrenshotData.put(screenshotrFileName, screenshotStream);
|
|
|
|
applicationArtifact.setBannerName(bannerFileName);
|
|
|
|
|
|
|
|
applicationArtifact.setBannerStream(bannerStream);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (attachmentList != null) {
|
|
|
|
|
|
|
|
Map<String, InputStream> scrrenshotData = new HashMap<>();
|
|
|
|
|
|
|
|
for (Attachment sc : attachmentList) {
|
|
|
|
|
|
|
|
dataHandler = sc.getDataHandler();
|
|
|
|
|
|
|
|
String screenshotrFileName = dataHandler.getName();
|
|
|
|
|
|
|
|
InputStream screenshotStream = dataHandler.getInputStream();
|
|
|
|
|
|
|
|
if (screenshotStream == null) {
|
|
|
|
|
|
|
|
String msg =
|
|
|
|
|
|
|
|
"Stream of one of the application release screenshot is null. Hence can't proceed. Please "
|
|
|
|
|
|
|
|
+ "verify the uploaded screenshots.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (screenshotrFileName == null) {
|
|
|
|
|
|
|
|
String msg =
|
|
|
|
|
|
|
|
"Screenshot file name retrieving is failed for one screenshot. Hence can't proceed. "
|
|
|
|
|
|
|
|
+ "Please verify the screenshots.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
scrrenshotData.put(screenshotrFileName, screenshotStream);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
applicationArtifact.setScreenshots(scrrenshotData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationArtifact.setScreenshots(scrrenshotData);
|
|
|
|
|
|
|
|
return applicationArtifact;
|
|
|
|
return applicationArtifact;
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
String msg = "Error occurred when reading attachment data.";
|
|
|
|
String msg = "Error occurred when reading attachment data.";
|
|
|
|