diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index b10a692a936..633e8b8ccbe 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -159,7 +159,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } } - sql += " LIMIT ? OFFSET ? ORDER BY " + filter.getSortBy() + " APP_ID;"; + String defaultSortOrder = "ASC"; + if (filter.getSortBy() != null && !filter.getSortBy().isEmpty()) { + defaultSortOrder = filter.getSortBy(); + } + sql += " ORDER BY APP_ID " + defaultSortOrder +" LIMIT ? OFFSET ? "; pagination.setLimit(filter.getLimit()); pagination.setOffset(filter.getOffset()); @@ -167,7 +171,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try { conn = this.getDBConnection(); stmt = conn.prepareStatement(sql); - stmt.setInt(paramIndex, tenantId); + stmt.setInt(paramIndex++, tenantId); stmt.setString(paramIndex++, AppLifecycleState.REMOVED.toString()); if (filter.getAppType() != null) { @@ -181,7 +185,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } } - stmt.setInt(paramIndex++, filter.getLimit()); + if (filter.getLimit() == 0) { + stmt.setInt(paramIndex++, 100); + } else { + stmt.setInt(paramIndex++, filter.getLimit()); + } stmt.setInt(paramIndex, filter.getOffset()); rs = stmt.executeQuery(); applicationList.setApplications(Util.loadApplications(rs)); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index c2080fbcda1..e6d034ee94d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -201,11 +201,11 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager "application UUID " + applicationRelease.getUuid()); } - if (DeviceType.ANDROID.toString().equals(deviceType)) { + if (DeviceType.ANDROID.toString().equalsIgnoreCase(deviceType)) { ApkMeta apkMeta = ArtifactsParser.readAndroidManifestFile(binaryFile); applicationRelease.setVersion(apkMeta.getVersionName()); applicationRelease.setPackageName(apkMeta.getPackageName()); - } else if (DeviceType.IOS.toString().equals(deviceType)) { + } else if (DeviceType.IOS.toString().equalsIgnoreCase(deviceType)) { NSDictionary plistInfo = ArtifactsParser.readiOSManifestFile(binaryFile); applicationRelease .setVersion(plistInfo.objectForKey(ArtifactsParser.IPA_BUNDLE_VERSION_KEY).toString()); 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/ApplicationManagementAPI.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/ApplicationManagementAPI.java index 6c1d633f518..1dec91b98b8 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/ApplicationManagementAPI.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/ApplicationManagementAPI.java @@ -226,7 +226,7 @@ public interface ApplicationManagementAPI { @POST @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) + @Consumes("multipart/mixed") @ApiOperation( consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, @@ -260,7 +260,7 @@ public interface ApplicationManagementAPI { name = "application", value = "The application that need to be created.", required = true) - @Valid Application application, + @Multipart("application") Application application, @ApiParam( name = "binaryFile", value = "Binary file of uploading application", @@ -277,10 +277,20 @@ public interface ApplicationManagementAPI { required = true) @Multipart(value = "banner") Attachment bannerFile, @ApiParam( - name = "screenshot", + name = "screenshot1", value = "Screen Shots of the uploading application", required = true) - @Multipart(value = "screenshot") List attachmentList + @Multipart(value = "screenshot1") Attachment screenshot1, + @ApiParam( + name = "screenshot2", + value = "Screen Shots of the uploading application", + required = false) + @Multipart(value = "screenshot2") Attachment screenshot2, + @ApiParam( + name = "screenshot3", + value = "Screen Shots of the uploading application", + required = false) + @Multipart(value = "screenshot3") Attachment screenshot3 ); @DELETE 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/ApplicationManagementAPIImpl.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/ApplicationManagementAPIImpl.java index 15cfb1e9954..2b4c758e193 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/ApplicationManagementAPIImpl.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/ApplicationManagementAPIImpl.java @@ -48,6 +48,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** @@ -106,13 +107,15 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { } @POST - @Consumes("application/json") + @Consumes("multipart/mixed") public Response createApplication( - @Valid Application application, + @Multipart("application") Application application, @Multipart("binaryFile") Attachment binaryFile, @Multipart("icon") Attachment iconFile, @Multipart("banner") Attachment bannerFile, - @Multipart("screenshot") List attachmentList) { + @Multipart("screenshot1") Attachment screenshot1, + @Multipart("screenshot2") Attachment screenshot2, + @Multipart("screenshot3") Attachment screenshot3) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); InputStream iconFileStream; @@ -120,6 +123,15 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { List attachments = new ArrayList<>(); List applicationReleases = new ArrayList<>(); ApplicationRelease applicationRelease; + List attachmentList = new ArrayList<>(); + attachmentList.add(screenshot1); + if(screenshot2 != null) { + attachmentList.add(screenshot2); + } + if(screenshot3 != null) { + attachmentList.add(screenshot3); + } + try { if (!isValidAppCreatingRequest(binaryFile, iconFile, bannerFile, attachmentList, application)) { return Response.status(Response.Status.BAD_REQUEST).build();