diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java index 816b96c62b3..f6f149ea62b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java @@ -57,7 +57,7 @@ import javax.ws.rs.core.Response; public interface ArtifactDownloadAPI { @GET - @Path("/{uuid}/{folderName}/{fileName}") + @Path("/{tenantId}/{uuid}/{folderName}/{fileName}") @Produces(MediaType.APPLICATION_OCTET_STREAM) @ApiOperation( produces = MediaType.APPLICATION_OCTET_STREAM, @@ -81,6 +81,11 @@ public interface ArtifactDownloadAPI { response = ErrorResponse.class) }) Response getArtifact( + @ApiParam( + name = "tenantId", + value = "Tenant Id of the application artifact belongs.", + required = true) + @PathParam("tenantId") int tenantId, @ApiParam( name = "uuid", value = "UUID of the application release.", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java index c603b85161f..d442de1b968 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java @@ -47,14 +47,15 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI { @GET @Override @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Path("/{uuid}/{folderName}/{fileName}") + @Path("/{tenantId}/{uuid}/{folderName}/{fileName}") public Response getArtifact( + @PathParam("tenantId") int tenantId, @PathParam("uuid") String uuid, @PathParam("folderName") String folderName, @PathParam("fileName") String fileName) { AppmDataHandler dataHandler = APIUtil.getDataHandler(); try { - InputStream fileInputStream = dataHandler.getArtifactStream(uuid, folderName, fileName); + InputStream fileInputStream = dataHandler.getArtifactStream(tenantId, uuid, folderName, fileName); Response.ResponseBuilder response = Response .ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM); response.status(Response.Status.OK); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java index 7e4cb13a826..7385688db58 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java @@ -35,6 +35,6 @@ public interface AppmDataHandler { Map getLifecycleConfiguration() throws LifecycleManagementException; - InputStream getArtifactStream(String uuid, String folderName, String artifactName) + InputStream getArtifactStream(int tenantId, String uuid, String folderName, String artifactName) throws ApplicationManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java index d1a3f056cfc..d1c941e0453 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java @@ -60,9 +60,8 @@ public class AppmDataHandlerImpl implements AppmDataHandler { return lifecycleStateManager.getLifecycleConfig(); } - @Override public InputStream getArtifactStream(String uuid, String folderName, String artifactName) + @Override public InputStream getArtifactStream(int tenantId, String uuid, String folderName, String artifactName) throws ApplicationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); String appReleaseHashValue; @@ -83,9 +82,8 @@ public class AppmDataHandlerImpl implements AppmDataHandler { } return inputStream; } catch (ApplicationManagementDAOException e) { - String msg = - "Error occurred when retrieving application release hash value for given application release UUID: " - + uuid; + String msg = "Error occurred when retrieving application release hash value for given application release " + + "UUID: " + uuid; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (ApplicationStorageManagementException e) { 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 0829079e669..f3b325caa26 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 @@ -353,8 +353,7 @@ public class APIUtil { application.setRating(applicationDTO.getAppRating()); List applicationReleases = new ArrayList<>(); for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) { - ApplicationRelease applicationRelease = releaseDtoToRelease(applicationReleaseDTO); - applicationReleases.add(applicationRelease); + applicationReleases.add(releaseDtoToRelease(applicationReleaseDTO)); } application.setApplicationReleases(applicationReleases); return application; @@ -362,8 +361,10 @@ public class APIUtil { public static ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO) throws ApplicationManagementException { - String basePath = getArtifactDownloadBaseURL() + applicationReleaseDTO.getUuid() - + Constants.FORWARD_SLASH; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String basePath = + getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + + Constants.FORWARD_SLASH; List screenshotPaths = new ArrayList<>(); ApplicationRelease applicationRelease = new ApplicationRelease(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js index 841e9215cb8..eb047468f1e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer/AppDetailsDrawer.js @@ -92,7 +92,6 @@ class AppDetailsDrawer extends React.Component { componentDidMount() { this.getCategories(); - this.getTags(); } componentDidUpdate(prevProps, prevState, snapshot) { @@ -117,7 +116,7 @@ class AppDetailsDrawer extends React.Component { ).then(res => { if (res.status === 200) { const categories = JSON.parse(res.data.data); - + this.getTags(); const globalCategories = categories.map(category => { return (