From 9876d8685cc65786e387d653f812b9140a4f4807 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Tue, 26 Mar 2019 18:25:24 +0530 Subject: [PATCH] Refactor the source --- .../mgt/api/services/AppMgtAPI.java | 84 ---------- .../mgt/api/services/impl/AppMgtAPIImpl.java | 60 -------- .../api/services/AppArtifactRetrievalAPI.java | 19 +++ .../impl/AppArtifactRetrivaalAPIImpl.java | 19 +++ .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 +- .../mgt/common/ApplicationRelease.java | 8 +- .../wrappers/ApplicationReleaseWrapper.java | 107 +++++++++++++ .../common/wrappers/ApplicationWrapper.java | 132 ++++++++++++++++ .../application/mgt/core/dao/common/Util.java | 2 +- .../GenericApplicationReleaseDAOImpl.java | 64 +++++--- .../mgt/core/impl/ApplicationManagerImpl.java | 143 ++++++++++-------- .../impl/ApplicationStorageManagerImpl.java | 46 +++--- .../impl/ApplicationManagementAPIImpl.java | 17 +-- .../pom.xml | 3 + .../dbscripts/cdm/application-mgt/h2.sql | 24 ++- .../dbscripts/cdm/application-mgt/mysql.sql | 23 +-- 16 files changed, 450 insertions(+), 303 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/AppMgtAPI.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/AppMgtAPIImpl.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationReleaseWrapper.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationWrapper.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/AppMgtAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/AppMgtAPI.java deleted file mode 100644 index ee5dd06a415..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/AppMgtAPI.java +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.application.mgt.api.services; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import org.wso2.carbon.device.application.mgt.common.*; -import org.wso2.carbon.device.application.mgt.common.ErrorResponse; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * APIs to handle application management related tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Application Management Common Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ApplicationManagementCommonService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/app-mgt"), - }) - } - ) -) -@Path("/app-mgt") -@Api(value = "Application Management Common Service", description = "This API carries all application management common services") -@Produces(MediaType.APPLICATION_JSON) -public interface AppMgtAPI { - - @GET - @Path("/ui-config") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get application management UI configuration", - notes = "This will get all UI configuration of application management" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got UI config.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an defined UI config." + - "query."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the UI config.", - response = ErrorResponse.class) - }) - Response getUiConfig(); - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/AppMgtAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/AppMgtAPIImpl.java deleted file mode 100644 index 9af367c6920..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/AppMgtAPIImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.application.mgt.api.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.api.services.AppMgtAPI; -import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration; -import org.wso2.carbon.device.application.mgt.common.services.ConfigManager; -import org.wso2.carbon.device.application.mgt.core.util.APIUtil; -import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; - -/** - * Implementation of Application Management related APIs. - */ -@Produces({"application/json"}) -@Path("/app-mgt") -public class AppMgtAPIImpl implements AppMgtAPI { - - private static Log log = LogFactory.getLog(AppMgtAPIImpl.class); - - @GET - @Override - @Consumes("application/json") - @Path("/ui-config") - public Response getUiConfig() { - ConfigManager configManager = APIUtil.getConfigManager(); - try { - UIConfiguration uiConfiguration = configManager.getUIConfiguration(); - return Response.status(Response.Status.OK).entity(uiConfiguration).build(); - - }catch (ApplicationManagementException e) { - String msg = "Error occurred while getting the application list for publisher "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java new file mode 100644 index 00000000000..f1299968038 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java @@ -0,0 +1,19 @@ +package org.wso2.carbon.device.application.mgt.artifact.retrieve.api.services;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public interface AppArtifactRetrievalAPI { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java new file mode 100644 index 00000000000..8189ecdd185 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java @@ -0,0 +1,19 @@ +package org.wso2.carbon.device.application.mgt.artifact.retrieve.api.services.impl;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class AppArtifactRetrivaalAPIImpl { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml index abc22c4919d..8cfd529adf5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -52,7 +52,7 @@ - + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java index b1b0ab8f14f..44e88b7927b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java @@ -85,7 +85,7 @@ public class ApplicationRelease { @ApiModelProperty(name = "isSharedWithAllTenants", value = "If application release is shared with all tenants it is eqal to 1 otherwise 0", required = true) - private int isSharedWithAllTenants; + private boolean isSharedWithAllTenants; @ApiModelProperty(name = "metaData", value = "Meta data of the application release", @@ -168,7 +168,7 @@ public class ApplicationRelease { this.appHashValue = appHashValue; } - public void setIsSharedWithAllTenants(int isSharedWithAllTenants) { + public void setIsSharedWithAllTenants(boolean isSharedWithAllTenants) { this.isSharedWithAllTenants = isSharedWithAllTenants; } @@ -196,9 +196,7 @@ public class ApplicationRelease { return appHashValue; } - public int getIsSharedWithAllTenants() { - return isSharedWithAllTenants; - } + public boolean getIsSharedWithAllTenants() { return isSharedWithAllTenants; } public String getMetaData() { return metaData; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationReleaseWrapper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationReleaseWrapper.java new file mode 100644 index 00000000000..0c6e85f65b0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationReleaseWrapper.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.wso2.carbon.device.application.mgt.common.wrappers; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(value = "ApplicationRelease", description = "This class holds the details when releasing an Application to application store") +public class ApplicationReleaseWrapper { + + @ApiModelProperty(name = "description", + value = "Description of the application release") + private String description; + + @ApiModelProperty(name = "releaseType", + value = "Release type of the application release", + required = true, + example = "alpha, beta etc") + private String releaseType; + + @ApiModelProperty(name = "price", + value = "Price of the application release", + required = true) + private Double price; + + @ApiModelProperty(name = "isSharedWithAllTenants", + value = "If application release is shared with all tenants it is eqal to 1 otherwise 0", + required = true) + private boolean isSharedWithAllTenants; + + @ApiModelProperty(name = "metaData", + value = "Meta data of the application release", + required = true) + private String metaData; + + @ApiModelProperty(name = "url", + value = "URL which is used for WEB-CLIP") + private String url; + + @ApiModelProperty(name = "supportedOsVersions", + value = "Application release supported OS versions") + private String supportedOsVersions; + + public String getReleaseType() { + return releaseType; + } + + public void setReleaseType(String releaseType) { + this.releaseType = releaseType; + } + + public void setIsSharedWithAllTenants(boolean isSharedWithAllTenants) { + this.isSharedWithAllTenants = isSharedWithAllTenants; + } + + public void setMetaData(String metaData) { + this.metaData = metaData; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public boolean getIsSharedWithAllTenants() { + return isSharedWithAllTenants; + } + + public String getMetaData() { + return metaData; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { return description; } + + public void setDescription(String description) { this.description = description; } + + public String getSupportedOsVersions() { return supportedOsVersions; } + + public void setSupportedOsVersions(String supportedOsVersions) { this.supportedOsVersions = supportedOsVersions; } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationWrapper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationWrapper.java new file mode 100644 index 00000000000..8d64248985a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrappers/ApplicationWrapper.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.wso2.carbon.device.application.mgt.common.wrappers; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; + +import java.util.List; + +@ApiModel(value = "Application", description = "Application represents the an Application in Application Store") +public class ApplicationWrapper { + + + @ApiModelProperty(name = "name", + value = "Name of the application", + required = true) + private String name; + + @ApiModelProperty(name = "description", + value = "Description of the application", + required = true) + private String description; + + @ApiModelProperty(name = "appCategory", + value = "Category of the application", + required = true, + example = "Educational, Gaming, Travel, Entertainment etc") + private String appCategory; + + @ApiModelProperty(name = "type", + value = "Type of the application", + required = true, + example = "ENTERPRISE, PUBLIC, WEB, WEB_CLIP etc") + private String type; + + @ApiModelProperty(name = "subType", + value = "Subscription type of the application", + required = true, + example = "PAID, FREE") + private String subType; + + @ApiModelProperty(name = "paymentCurrency", + value = "Payment currency of the application", + required = true, + example = "$") + private String paymentCurrency; + + @ApiModelProperty(name = "tags", + value = "List of application tags") + private List tags; + + @ApiModelProperty(name = "unrestrictedRoles", + value = "List of roles that users should have to access the application") + private List unrestrictedRoles; + + @ApiModelProperty(name = "deviceType", + value = "Related device type of the application", + required = true, + example = "IoS, Android, Arduino, RaspberryPi etc") + private String deviceType; + + + @ApiModelProperty(name = "applicationReleases", + value = "List of application releases", + required = true) + private List applicationReleases; + + + public String getName() { + return name; + } + + public void setName(String name) { this.name = name; } + + public String getAppCategory() { + return appCategory; + } + + public void setAppCategory(String appCategory) { + this.appCategory = appCategory; + } + + public List getTags() { return tags; } + + public void setTags(List tags) { this.tags = tags; } + + public String getType() { return type; } + + public void setType(String type) { this.type = type; } + + public String getSubType() { return subType; } + + public void setSubType(String subType) { this.subType = subType; } + + public String getPaymentCurrency() { return paymentCurrency; } + + public void setPaymentCurrency(String paymentCurrency) { this.paymentCurrency = paymentCurrency; } + + public List getApplicationReleases() { return applicationReleases; } + + public void setApplicationReleases(List applicationReleases) { + this.applicationReleases = applicationReleases; } + + public List getUnrestrictedRoles() { return unrestrictedRoles; } + + public void setUnrestrictedRoles(List unrestrictedRoles) { this.unrestrictedRoles = unrestrictedRoles; } + + public String getDeviceType() { return deviceType; } + + public void setDeviceType(String deviceType) { this.deviceType = deviceType; } + + public String getDescription() { return description; } + + public void setDescription(String description) { this.description = description; } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index 0fab3d6c7cd..ca08987c901 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -238,7 +238,7 @@ public class Util { applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2")); applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3")); applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE")); - applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED")); + applicationRelease.setIsSharedWithAllTenants(resultSet.getBoolean("SHARED")); applicationRelease.setMetaData(resultSet.getString("APP_META_INFO")); applicationRelease.setRating(resultSet.getDouble("RATING")); return applicationRelease; 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/release/GenericApplicationReleaseDAOImpl.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/release/GenericApplicationReleaseDAOImpl.java index 3081fbba23e..eef560b179c 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/release/GenericApplicationReleaseDAOImpl.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/release/GenericApplicationReleaseDAOImpl.java @@ -57,33 +57,51 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements PreparedStatement statement = null; ResultSet resultSet = null; - String sql = "INSERT INTO AP_APP_RELEASE (VERSION,TENANT_ID,UUID,RELEASE_TYPE, PACKAGE_NAME, APP_PRICE, " - + "STORED_LOCATION, ICON_LOCATION, BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION," - + "APP_HASH_VALUE, SHARED_WITH_ALL_TENANTS, APP_META_INFO,AP_APP_ID) " - + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; + String sql = "INSERT INTO AP_APP_RELEASE " + + "(DESCRIPTION," + + "VERSION," + + "TENANT_ID," + + "UUID," + + "RELEASE_TYPE," + + "PACKAGE_NAME," + + "APP_PRICE, " + + "STORED_LOCATION," + + "ICON_LOCATION," + + "BANNER_LOCATION," + + "SC_1_LOCATION," + + "SC_2_LOCATION," + + "SC_3_LOCATION," + + "APP_HASH_VALUE," + + "SHARED_WITH_ALL_TENANTS," + + "APP_META_INFO," + + "SUPPORTED_OS_VERSIONS," + + "CURRENT_STATE," + + "AP_APP_ID) " + + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; - // TODO : make this readable - int index = 0; String generatedColumns[] = { "ID" }; try { connection = this.getDBConnection(); statement = connection.prepareStatement(sql, generatedColumns); - statement.setString(++index, applicationRelease.getVersion()); - statement.setInt(++index, tenantId); - statement.setString(++index, applicationRelease.getUuid()); - statement.setString(++index, String.valueOf(applicationRelease.getReleaseType())); - statement.setString(++index, String.valueOf(applicationRelease.getPackageName())); - statement.setDouble(++index, applicationRelease.getPrice()); - statement.setString(++index, applicationRelease.getAppStoredLoc()); - statement.setString(++index, applicationRelease.getIconLoc()); - statement.setString(++index, applicationRelease.getBannerLoc()); - statement.setString(++index, applicationRelease.getScreenshotLoc1()); - statement.setString(++index, applicationRelease.getScreenshotLoc2()); - statement.setString(++index, applicationRelease.getScreenshotLoc3()); - statement.setString(++index, applicationRelease.getAppHashValue()); - statement.setInt(++index, applicationRelease.getIsSharedWithAllTenants()); - statement.setString(++index, applicationRelease.getMetaData()); - statement.setInt(++index, appId); + statement.setString(1, applicationRelease.getDescription()); + statement.setString(2, applicationRelease.getVersion()); + statement.setInt(3, tenantId); + statement.setString(4, applicationRelease.getUuid()); + statement.setString(5, String.valueOf(applicationRelease.getReleaseType())); + statement.setString(6, String.valueOf(applicationRelease.getPackageName())); + statement.setDouble(7, applicationRelease.getPrice()); + statement.setString(8, applicationRelease.getAppStoredLoc()); + statement.setString(9, applicationRelease.getIconLoc()); + statement.setString(10, applicationRelease.getBannerLoc()); + statement.setString(11, applicationRelease.getScreenshotLoc1()); + statement.setString(12, applicationRelease.getScreenshotLoc2()); + statement.setString(13, applicationRelease.getScreenshotLoc3()); + statement.setString(14, applicationRelease.getAppHashValue()); + statement.setBoolean(15, applicationRelease.getIsSharedWithAllTenants()); + statement.setString(16, applicationRelease.getMetaData()); + statement.setString(17, applicationRelease.getSupportedOsVersions()); + statement.setString(18, applicationRelease.getCurrentState()); + statement.setInt(19, appId); statement.executeUpdate(); resultSet = statement.getGeneratedKeys(); if (resultSet.next()) { @@ -386,7 +404,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements statement.setString(10, applicationRelease.getScreenshotLoc2()); statement.setString(11, applicationRelease.getScreenshotLoc3()); statement.setString(12, applicationRelease.getAppHashValue()); - statement.setInt(13, applicationRelease.getIsSharedWithAllTenants()); + statement.setBoolean(13, applicationRelease.getIsSharedWithAllTenants()); statement.setString(14, applicationRelease.getMetaData()); statement.setInt(15, applicationId); statement.setInt(16, tenantId); 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 5fac1bc4e7c..a5ff6cd8c2e 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 @@ -76,6 +76,7 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Queue; import java.util.Set; import java.util.UUID; @@ -120,19 +121,16 @@ public class ApplicationManagerImpl implements ApplicationManager { String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); application.setUser(new User(userName, tenantId)); - if (log.isDebugEnabled()) { - log.debug("Create Application received for the tenant : " + tenantId + " From" + " the user : " + userName); - } DeviceType deviceType = null; List deviceTypes; ApplicationRelease applicationRelease; List applicationReleases = new ArrayList<>(); + if (log.isDebugEnabled()) { + log.debug("Create Application received for the tenant : " + tenantId + " From" + " the user : " + userName); + } try { validateAppCreatingRequest(application, binaryFile, iconFile, bannerFile, attachmentList); - // Getting the device type details to get device type ID for internal mappings - // deviceType = Util.getDeviceManagementService().getDeviceType(application.getDeviceType()); - deviceTypes = Util.getDeviceManagementService().getDeviceTypes(); for (DeviceType dt : deviceTypes) { if (dt.getName().equals(application.getDeviceType())) { @@ -141,11 +139,11 @@ public class ApplicationManagerImpl implements ApplicationManager { break; } } - if (deviceType == null) { - log.error("Invalid device type is found with the request. Requested Device Type is: " + application - .getDeviceType()); - return null; + String msg = "Invalid device type is found with the request. Requested Device Type is: " + application + .getDeviceType(); + log.error(msg); + throw new RequestValidatingException(msg); } applicationRelease = application.getApplicationReleases().get(0); @@ -167,10 +165,12 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationReleases.add(applicationRelease); application.setApplicationReleases(applicationReleases); } catch (ResourceManagementException e) { - throw new ApplicationManagementException(""); + String msg = "Error Occured when uploading artifacts of the application.: " + application.getName(); + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (DeviceManagementException e) { - throw new ApplicationManagementException( - "Error occurred while getting device type id of " + application.getType(), e); + String msg = "Error occurred while getting device type id of " + application.getType(); + throw new ApplicationManagementException(msg, e); } try { @@ -185,14 +185,15 @@ public class ApplicationManagerImpl implements ApplicationManager { ApplicationList applicationList = applicationDAO.getApplications(filter, tenantId); if (!applicationList.getApplications().isEmpty()) { - throw new RequestValidatingException( + String msg = "Already an application registered with same name - " + applicationList.getApplications().get(0) - .getName()); + .getName(); + log.error(msg); + throw new RequestValidatingException(msg); } // Insert to application table int appId = this.applicationDAO.createApplication(application, tenantId); - if (appId == -1) { log.error("Application creation is Failed"); ConnectionManagerUtil.rollbackDBTransaction(); @@ -201,15 +202,15 @@ public class ApplicationManagerImpl implements ApplicationManager { if (log.isDebugEnabled()) { log.debug("New Application entry added to AP_APP table. App Id:" + appId); } - //adding application unrestricted roles - if (!application.getUnrestrictedRoles().isEmpty()) { - if (!isValidRestrictedRole(application.getUnrestrictedRoles())) { + List unrestrictedRoles = application.getUnrestrictedRoles(); + if (!unrestrictedRoles.isEmpty()) { + if (!isValidRestrictedRole(unrestrictedRoles)) { String msg = "Unrestricted role list contain role/roles which are not in the user store."; log.error(msg); throw new ApplicationManagementException(msg); } - this.visibilityDAO.addUnrestrictedRoles(application.getUnrestrictedRoles(), appId, tenantId); + this.visibilityDAO.addUnrestrictedRoles(unrestrictedRoles, appId, tenantId); if (log.isDebugEnabled()) { log.debug("New restricted roles to app ID mapping added to AP_UNRESTRICTED_ROLE table." + " App Id:" + appId); @@ -217,34 +218,36 @@ public class ApplicationManagerImpl implements ApplicationManager { } List registeredCatehgories = this.applicationDAO.getAllCategories(tenantId); + String categoryName = application.getAppCategory(); + Optional category = registeredCatehgories.stream().filter(obj -> obj.getCategoryName().equals(categoryName)).findAny(); - if (registeredCatehgories.isEmpty() || !registeredCatehgories.contains(application.getAppCategory())) { + if (registeredCatehgories.isEmpty()) { ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Registered application category set is empty."; + String msg = "Registered application category set is empty category: " + categoryName; log.error(msg); throw new ApplicationManagementException(msg); } + if (!category.isPresent()){ + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Request contains invalid category: " + categoryName; + log.error(msg); + throw new ApplicationManagementException(msg); - boolean isValidAppCategory = false; - - for (Category category : registeredCatehgories) { - if (category.getCategoryName().equals(application.getAppCategory())) { - isValidAppCategory = true; - break; - } } - // if (!isValidAppCategory){ - // ConnectionManagerUtil.rollbackDBTransaction(); - // String msg = "Invalid category type is found. Category: " + application. getAppCategory(); - // log.error(msg); - // throw new RequestValidatingException(msg); - // } + /* + In current flow, allow to add one category for an application. If it is required to add multiple + categories DAO layer is implemented to match with that requirement. Hence logic is also implemented + this way. + */ + List categoryIds = new ArrayList<>(); + categoryIds.add(category.get().getId()); + this.applicationDAO.addCategoryMapping(categoryIds,appId,tenantId); - // todo add categories //adding application tags - if (!application.getTags().isEmpty()) { + List tags = application.getTags(); + if (!tags.isEmpty()) { List allRegisteredTags = applicationDAO.getAllTags(tenantId); List allRegisteredTagNames = new ArrayList<>(); List tagIds = new ArrayList<>(); @@ -252,17 +255,17 @@ public class ApplicationManagerImpl implements ApplicationManager { for (Tag tag : allRegisteredTags) { allRegisteredTagNames.add(tag.getTagName()); } - List newTags = getDifference(application.getTags(), allRegisteredTagNames); + List newTags = getDifference(tags, allRegisteredTagNames); if (!newTags.isEmpty()) { this.applicationDAO.addTags(newTags, tenantId); if (log.isDebugEnabled()) { log.debug("New tags entry added to AP_APP_TAG table. App Id:" + appId); } - tagIds = this.applicationDAO.getTagIdsForTagNames(application.getTags(), tenantId); + tagIds = this.applicationDAO.getTagIdsForTagNames(tags, tenantId); } else { for (Tag tag : allRegisteredTags) { - for (String tagName : application.getTags()) { + for (String tagName : tags) { if (tagName.equals(tag.getTagName())) { tagIds.add(tag.getId()); break; @@ -295,25 +298,36 @@ public class ApplicationManagerImpl implements ApplicationManager { return application; } catch (LifeCycleManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException( - "Error occured while adding lifecycle state. application name: " + application.getName() - + " application type: is " + application.getType(), e); + String msg = "Error occured while adding lifecycle state. application name: " + application.getName() + + " application type: is " + application.getType(); + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException( + String msg = "Error occured while adding application or application release. application name: " + application - .getName() + " application type: " + application.getType(), e); + .getName() + " application type: " + application.getType(); + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (DBConnectionException e) { - throw new ApplicationManagementException("Error occured while getting database connection. ", e); + String msg = "Error occured while getting database connection."; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (VisibilityManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException( - "Error occured while adding unrestricted roles. application name: " + application.getName() - + " application type: " + application.getType(), e); + String msg = "Error occured while adding unrestricted roles. application name: " + application.getName() + + " application type: " + application.getType(); + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (TransactionManagementException e) { - throw new ApplicationManagementException("Error occured while disabling AutoCommit. ", e); + String msg = "Error occured while disabling AutoCommit."; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (UserStoreException e) { - throw new ApplicationManagementException("Error occured while disabling AutoCommit. ", e); + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Error occured when validating the unrestricted roles given for the application"; + log.error(msg); + throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -1363,7 +1377,6 @@ public class ApplicationManagerImpl implements ApplicationManager { String releaseType = updateRelease.getReleaseType(); Double price = updateRelease.getPrice(); - int isSharedWithTenants = updateRelease.getIsSharedWithAllTenants(); String metaData = updateRelease.getMetaData(); if (price < 0.0 || (price == 0.0 && ApplicationSubscriptionType.PAID.toString().equals(app.getSubType())) @@ -1379,10 +1392,6 @@ public class ApplicationManagerImpl implements ApplicationManager { if (releaseType != null) { release.setReleaseType(releaseType); } - //todo change this when isShared with field change to boolean - if (isSharedWithTenants == 0 || isSharedWithTenants == 1) { - release.setIsSharedWithAllTenants(isSharedWithTenants); - } if (metaData != null) { release.setMetaData(metaData); } @@ -1467,24 +1476,31 @@ public class ApplicationManagerImpl implements ApplicationManager { String applicationType = application.getType(); if (StringUtils.isEmpty(application.getName())) { - String msg = ""; + String msg = "Application name cannot be empty"; log.error(msg); - throw new RequestValidatingException("Application name cannot be empty"); + throw new RequestValidatingException(msg); } if (StringUtils.isEmpty(application.getAppCategory())) { - throw new RequestValidatingException("Application category can't be empty"); + String msg = "Application category can't be empty"; + log.error(msg); + throw new RequestValidatingException(msg); } if (StringUtils.isEmpty(applicationType)) { - throw new RequestValidatingException("Application type can't be empty"); + String msg = "Application type can't be empty"; + log.error(msg); + throw new RequestValidatingException(msg); } if (StringUtils.isEmpty(application.getDeviceType())) { - throw new RequestValidatingException("Device type can't be empty for the application"); + String msg = "Device type can't be empty for the application"; + log.error(msg); + throw new RequestValidatingException(msg); } isValidApplicationType = isValidAppType(application.getType()); if (!isValidApplicationType) { - throw new RequestValidatingException( - "App Type contains in the application creating payload doesn't match with supported app types"); + String msg = "App Type contains in the application creating payload doesn't match with supported app types"; + log.error(msg); + throw new RequestValidatingException(msg); } List appReleases; @@ -1495,6 +1511,7 @@ public class ApplicationManagerImpl implements ApplicationManager { "Invalid application creating request. Application creating request must have single application " + "release. Application name:" + application.getName() + " and type: " + application .getType(); + log.error(msg); throw new RequestValidatingException(msg); } validateReleaseCreatingRequest(appReleases.get(0), applicationType, binaryFile, iconFile, bannerFile, 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 64cbee410cb..082908a8481 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 @@ -39,11 +39,13 @@ import org.wso2.carbon.device.application.mgt.common.exception.RequestValidating import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.core.exception.ParsingException; +import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; import org.wso2.carbon.device.application.mgt.core.util.ArtifactsParser; import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; import org.xml.sax.SAXException; +import javax.activation.DataHandler; import javax.xml.parsers.ParserConfigurationException; import java.io.*; import java.text.ParseException; @@ -140,35 +142,35 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager InputStream bannerFileStream; List screenshotStreams = new ArrayList<>(); List scFileExtensions = new ArrayList<>(); - String iconFileExtension; - String bannerFileExtension; - - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + DataHandler iconFileDataHandler; + DataHandler bannerFileDataHandler; String artifactDirectoryPath; String iconStoredLocation; String bannerStoredLocation; String scStoredLocation; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { + iconFileDataHandler = iconFile.getDataHandler(); + bannerFileDataHandler = bannerFile.getDataHandler(); - iconFileStream = iconFile.getDataHandler().getInputStream(); - iconFileExtension = iconFile.getDataHandler().getContentType(); - bannerFileExtension = bannerFile.getDataHandler().getContentType(); - bannerFileStream = bannerFile.getDataHandler().getInputStream(); + iconFileStream = iconFileDataHandler.getInputStream(); + bannerFileStream = bannerFileDataHandler.getInputStream(); for (Attachment screenshot : screenshots) { - screenshotStreams.add(screenshot.getDataHandler().getInputStream()); - scFileExtensions.add(screenshot.getDataHandler().getContentType()); + DataHandler scDataHandler = screenshot.getDataHandler(); + screenshotStreams.add(scDataHandler.getInputStream()); + scFileExtensions.add(scDataHandler.getName()); } artifactDirectoryPath = storagePath + applicationRelease.getAppHashValue(); StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); - iconStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[0] + iconFileExtension; - bannerStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[1] + bannerFileExtension; if (iconFileStream != null) { + iconStoredLocation = artifactDirectoryPath + File.separator + iconFileDataHandler.getName(); saveFile(iconFileStream, iconStoredLocation); applicationRelease.setIconLoc(iconStoredLocation); } if (bannerFileStream != null) { + bannerStoredLocation = artifactDirectoryPath + File.separator + bannerFileDataHandler.getName(); saveFile(bannerFileStream, bannerStoredLocation); applicationRelease.setBannerLoc(bannerStoredLocation); } @@ -178,8 +180,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } int count = 0; for (InputStream screenshotStream : screenshotStreams) { - scStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[2] + count - + scFileExtensions.get(count); + scStoredLocation = artifactDirectoryPath + File.separator + scFileExtensions.get(count); count ++; if (count == 1) { applicationRelease.setScreenshotLoc1(scStoredLocation); @@ -202,7 +203,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager + "update the screen-shot count for the application " + applicationRelease.getUuid() + " for the tenant id " + tenantId, e); } - } @Override @@ -298,9 +298,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager throw new ApplicationStorageManagementException(msg); } - - - if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the application release related artifacts related with " + "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath); @@ -329,8 +326,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager Attachment binaryFileAttachment) throws ResourceManagementException, RequestValidatingException{ try { - InputStream binaryFile = binaryFileAttachment.getDataHandler().getInputStream(); - String installerExtension = binaryFileAttachment.getDataHandler().getContentType(); if (ApplicationType.WEB_CLIP.toString().equals(appType)) { applicationRelease.setVersion(Constants.DEFAULT_VERSION); UrlValidator urlValidator = new UrlValidator(); @@ -346,6 +341,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager String artifactDirectoryPath; String md5OfApp; String artifactPath; + DataHandler binaryDataHandler = binaryFileAttachment.getDataHandler(); + String fileName = binaryDataHandler.getName(); + InputStream binaryFile = binaryDataHandler.getInputStream(); InputStream[] cloneInputStream = cloneInputStream(binaryFile); md5OfApp = getMD5(binaryFile); if (md5OfApp == null) { @@ -375,12 +373,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager throw new ApplicationStorageManagementException(msg); } - artifactPath = artifactDirectoryPath + File.separator + Constants.RELEASE_ARTIFACT - + installerExtension; - - - - + artifactPath = artifactDirectoryPath + File.separator + fileName; if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the application release related artifacts related with " + "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath); @@ -403,7 +396,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager throw new ApplicationStorageManagementException(msg, e); } return applicationRelease; - } private InputStream[] cloneInputStream(InputStream inputStream) throws ApplicationStorageManagementException { 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 5865ad94a29..72b5723701d 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 @@ -133,7 +133,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { @Multipart("screenshot3") Attachment screenshot3) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); List attachmentList = new ArrayList<>(); - if (screenshot1 != null){ + if (screenshot1 != null) { attachmentList.add(screenshot1); } if (screenshot2 != null) { @@ -158,20 +158,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { 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 " + application.getName(); -// 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 " -// + application.getName(); -// log.error(msg, e); -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); -// } - catch (RequestValidatingException e) { + } 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(); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml index 5509b86ee34..f6a13ac5eb9 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml @@ -145,6 +145,9 @@ commons-validator:commons-validator:${commons-validator.version} + + + 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 2600e21f7f9..43e7e26f476 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 @@ -35,25 +35,23 @@ CREATE TABLE IF NOT EXISTS APP_MANAGER.AP_APP_RELEASE( TENANT_ID varchar(45) NOT NULL, UUID varchar(200) NOT NULL, RELEASE_TYPE varchar(45) NOT NULL, + PACKAGE_NAME varchar(45) NOT NULL, APP_PRICE decimal(6, 2) NULL DEFAULT NULL, - STORED_LOCATION varchar(45) NOT NULL, - BANNER_LOCATION varchar(45) NOT NULL, - SC_1_LOCATION varchar(45) NOT NULL, - SC_2_LOCATION varchar(45) NULL DEFAULT NULL, - SC_3_LOCATION varchar(45) NULL DEFAULT NULL, + STORED_LOCATION varchar(100) NOT NULL, + ICON_LOCATION varchar(100) NOT NULL, + BANNER_LOCATION varchar(100) NOT NULL, + SC_1_LOCATION varchar(100) NOT NULL, + SC_2_LOCATION varchar(100) NULL DEFAULT NULL, + SC_3_LOCATION varchar(100) NULL DEFAULT NULL, APP_HASH_VALUE varchar(1000) NOT NULL, - SHARED_WITH_ALL_TENANTS tinyint NULL DEFAULT NULL, + SHARED_WITH_ALL_TENANTS tinyint NOT NULL, APP_META_INFO clob NULL DEFAULT NULL, - PACKAGE_NAME varchar(45) NOT NULL, - SUPPORTED_OS_VERSIONS varchar(45) NULL, + SUPPORTED_OS_VERSIONS varchar(45) NOT NULL, RATING double NULL DEFAULT NULL, - CURRENT_STATE varchar(45) NULL, + CURRENT_STATE varchar(45) NOT NULL, RATED_USERS int NULL, AP_APP_ID int NOT NULL, - PRIMARY KEY ( - ID, - AP_APP_ID - ), + PRIMARY KEY (ID), CONSTRAINT fk_AP_APP_RELEASE_AP_APP1 FOREIGN KEY (AP_APP_ID) REFERENCES APP_MANAGER.AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index dc28252bb65..6b6e4883215 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -49,22 +49,23 @@ CREATE TABLE IF NOT EXISTS `APP_MANAGER`.`AP_APP_RELEASE` ( `TENANT_ID` VARCHAR(45) NOT NULL, `UUID` VARCHAR(200) NOT NULL, `RELEASE_TYPE` VARCHAR(45) NOT NULL, + `PACKAGE_NAME` VARCHAR(45) NOT NULL, `APP_PRICE` DECIMAL(6,2) NULL DEFAULT NULL, - `STORED_LOCATION` VARCHAR(45) NOT NULL, - `BANNER_LOCATION` VARCHAR(45) NOT NULL, - `SC_1_LOCATION` VARCHAR(45) NOT NULL, - `SC_2_LOCATION` VARCHAR(45) NULL DEFAULT NULL, - `SC_3_LOCATION` VARCHAR(45) NULL DEFAULT NULL, + `STORED_LOCATION` VARCHAR(100) NOT NULL, + `ICON_LOCATION` VARCHAR(100) NOT NULL, + `BANNER_LOCATION` VARCHAR(100) NOT NULL, + `SC_1_LOCATION` VARCHAR(100) NOT NULL, + `SC_2_LOCATION` VARCHAR(100) NULL DEFAULT NULL, + `SC_3_LOCATION` VARCHAR(100) NULL DEFAULT NULL, `APP_HASH_VALUE` VARCHAR(1000) NOT NULL, - `SHARED_WITH_ALL_TENANTS` TINYINT(1) NULL DEFAULT NULL, + `SHARED_WITH_ALL_TENANTS` TINYINT(1) NOT NULL, `APP_META_INFO` TEXT NULL DEFAULT NULL, - `PACKAGE_NAME` VARCHAR(45) NOT NULL, - `SUPPORTED_OS_VERSIONS` VARCHAR(45) NULL, + `SUPPORTED_OS_VERSIONS` VARCHAR(45) NOT NULL, `RATING` DOUBLE NULL DEFAULT NULL, - `CURRENT_STATE` VARCHAR(45) NULL, + `CURRENT_STATE` VARCHAR(45) NOT NULL, `RATED_USERS` INT(11) NULL, `AP_APP_ID` INT(11) NOT NULL, - PRIMARY KEY (`ID`, `AP_APP_ID`), + PRIMARY KEY (`ID`), INDEX `fk_AP_APP_RELEASE_AP_APP1_idx` (`AP_APP_ID` ASC), CONSTRAINT `fk_AP_APP_RELEASE_AP_APP1` FOREIGN KEY (`AP_APP_ID`) @@ -73,7 +74,7 @@ CREATE TABLE IF NOT EXISTS `APP_MANAGER`.`AP_APP_RELEASE` ( ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 -COMMENT = ' '; +COMMENT = ' '; -- -----------------------------------------------------