From e67feefee587ca55a703d595d490dd54148180e3 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Tue, 18 Jun 2019 13:15:41 +0530 Subject: [PATCH] Make banner uploading as optional. --- .../mgt/core/impl/ApplicationManagerImpl.java | 6 ------ .../application/mgt/core/util/APIUtil.java | 5 ++++- .../ApplicationManagementPublisherAPI.java | 18 ++++++----------- ...ApplicationManagementPublisherAPIImpl.java | 20 ++++++++----------- .../impl/ApplicationManagementAPIImpl.java | 4 ---- .../dbscripts/cdm/application-mgt/h2.sql | 2 +- 6 files changed, 19 insertions(+), 36 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 3bd1708a74..77190def2f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -2559,12 +2559,6 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new RequestValidatingException(msg); } - //todo remove this check, because banner is not mandatory to have - if (bannerFile == null) { - String msg = "Banner file is not found with the application release creating request."; - log.error(msg); - throw new RequestValidatingException(msg); - } if (attachmentList == null || attachmentList.isEmpty()) { String msg = "Screenshots are not found with the application release creating request."; log.error(msg); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java index d53fb5d2d8..2458db3a30 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java @@ -355,7 +355,10 @@ public class APIUtil { applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); applicationRelease.setRating(applicationReleaseDTO.getRating()); applicationRelease.setIconPath(basePath + applicationReleaseDTO.getIconName()); - applicationRelease.setBannerPath(basePath + applicationReleaseDTO.getBannerName()); + + if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())){ + applicationRelease.setBannerPath(basePath + applicationReleaseDTO.getBannerName()); + } if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())){ applicationRelease diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java index 5efd2bec44..e2b50661e2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java @@ -320,8 +320,7 @@ public interface ApplicationManagementPublisherAPI { @Multipart(value = "icon") Attachment iconFile, @ApiParam( name = "banner", - value = "Banner of the uploading application", - required = true) + value = "Banner of the uploading application") @Multipart(value = "banner") Attachment bannerFile, @ApiParam( name = "screenshot1", @@ -385,8 +384,7 @@ public interface ApplicationManagementPublisherAPI { @Multipart(value = "icon") Attachment iconFile, @ApiParam( name = "banner", - value = "Banner of the uploading web app", - required = true) + value = "Banner of the uploading web app") @Multipart(value = "banner") Attachment bannerFile, @ApiParam( name = "screenshot1", @@ -450,8 +448,7 @@ public interface ApplicationManagementPublisherAPI { @Multipart(value = "icon") Attachment iconFile, @ApiParam( name = "banner", - value = "Banner of the uploading public app", - required = true) + value = "Banner of the uploading public app") @Multipart(value = "banner") Attachment bannerFile, @ApiParam( name = "screenshot1", @@ -523,8 +520,7 @@ public interface ApplicationManagementPublisherAPI { @Multipart(value = "icon") Attachment iconFile, @ApiParam( name = "banner", - value = "Banner of the uploading application", - required = true) + value = "Banner of the uploading application") @Multipart(value = "banner") Attachment bannerFile, @ApiParam( name = "screenshot1", @@ -635,8 +631,7 @@ public interface ApplicationManagementPublisherAPI { @Multipart(value = "icon") Attachment iconFile, @ApiParam( name = "banner", - value = "Banner of the uploading application", - required = true) + value = "Banner of the uploading application") @Multipart(value = "banner") Attachment bannerFile, @ApiParam( name = "screenshot1", @@ -776,8 +771,7 @@ public interface ApplicationManagementPublisherAPI { @Multipart(value = "icon") Attachment iconFile, @ApiParam( name = "banner", - value = "banner file of the application release.", - required = true) + value = "banner file of the application release.") @Multipart(value = "banner") Attachment bannerFile, @ApiParam( name = "screenshot1", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java index a9c639b2ad..e5e6745dff 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java @@ -46,9 +46,9 @@ import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import javax.activation.DataHandler; import javax.validation.Valid; import javax.ws.rs.Consumes; @@ -85,10 +85,6 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } ApplicationList applications = applicationManager.getApplications(filter); - if (applications.getApplications().isEmpty()) { - return Response.status(Response.Status.OK) - .entity("Couldn't find any application for the requested query.").build(); - } return Response.status(Response.Status.OK).entity(applications).build(); } catch (BadRequestException e) { String msg = "Incompatible request payload is found. Please try with valid request payload."; @@ -175,7 +171,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem @Multipart("application") ApplicationWrapper applicationWrapper, @Multipart("binaryFile") Attachment binaryFile, @Multipart("icon") Attachment iconFile, - @Multipart("banner") Attachment bannerFile, + @Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot2") Attachment screenshot2, @Multipart("screenshot3") Attachment screenshot3) { @@ -214,7 +210,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem public Response createWebApp( @Multipart("webapp") WebAppWrapper webAppWrapper, @Multipart("icon") Attachment iconFile, - @Multipart("banner") Attachment bannerFile, + @Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot2") Attachment screenshot2, @Multipart("screenshot3") Attachment screenshot3) { @@ -252,7 +248,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem public Response createPubApp( @Multipart("public-app") PublicAppWrapper publicAppWrapper, @Multipart("icon") Attachment iconFile, - @Multipart("banner") Attachment bannerFile, + @Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot2") Attachment screenshot2, @Multipart("screenshot3") Attachment screenshot3) { @@ -292,7 +288,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem @Multipart("applicationRelease") ApplicationReleaseWrapper applicationReleaseWrapper, @Multipart("binaryFile") Attachment binaryFile, @Multipart("icon") Attachment iconFile, - @Multipart("banner") Attachment bannerFile, + @Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot2") Attachment screenshot2, @Multipart("screenshot3") Attachment screenshot3) { @@ -331,7 +327,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem public Response updateApplicationImageArtifacts( @PathParam("uuid") String applicationReleaseUuid, @Multipart("icon") Attachment iconFile, - @Multipart("banner") Attachment bannerFile, + @Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot2") Attachment screenshot2, @Multipart("screenshot3") Attachment screenshot3) { @@ -436,7 +432,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem @Multipart("applicationRelease") ApplicationReleaseWrapper applicationReleaseWrapper, @Multipart("binaryFile") Attachment binaryFile, @Multipart("icon") Attachment iconFile, - @Multipart("banner") Attachment bannerFile, + @Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot2") Attachment screenshot2, @Multipart("screenshot3") Attachment screenshot3) { @@ -825,7 +821,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem } if (attachmentList != null) { - Map scrrenshotData = new HashMap<>(); + Map scrrenshotData = new TreeMap<>(); for (Attachment sc : attachmentList) { dataHandler = sc.getDataHandler(); String screenshotrFileName = dataHandler.getName(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java index accda96f57..754bd7a352 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java @@ -60,10 +60,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { } filter.setAppReleaseState(applicationManager.getInstallableLifecycleState()); ApplicationList applications = applicationManager.getApplications(filter); - if (applications.getApplications().isEmpty()) { - return Response.status(Response.Status.OK) - .entity("Couldn't find any application for the requested query.").build(); - } return Response.status(Response.Status.OK).entity(applications).build(); } catch (BadRequestException e) { String msg = e.getMessage(); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index 180aa9fcd9..c2d8157505 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS AP_APP_RELEASE( APP_PRICE DECIMAL(6, 2) NULL DEFAULT NULL, INSTALLER_LOCATION VARCHAR(100) NOT NULL, ICON_LOCATION VARCHAR(100) NOT NULL, - BANNER_LOCATION VARCHAR(100) NOT NULL, + BANNER_LOCATION VARCHAR(100) NULL DEFAULT NULL, SC_1_LOCATION VARCHAR(100) NOT NULL, SC_2_LOCATION VARCHAR(100) NULL DEFAULT NULL, SC_3_LOCATION VARCHAR(100) NULL DEFAULT NULL,