diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ApiOriginFilter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ApiOriginFilter.java index 7b34c432328..25446e95135 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ApiOriginFilter.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ApiOriginFilter.java @@ -1,17 +1,16 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, + * 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/FileStreamingOutput.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/FileStreamingOutput.java index ee89b209ed1..a1ad912d196 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/FileStreamingOutput.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/FileStreamingOutput.java @@ -1,19 +1,18 @@ -/* * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) 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 + * 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. + * 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.addons; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/JSONMessageHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/JSONMessageHandler.java index 3b6a778a942..6951e02b2ea 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/JSONMessageHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/JSONMessageHandler.java @@ -1,12 +1,11 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, + * 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 + * 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 diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/MultipartCustomProvider.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/MultipartCustomProvider.java index 5e0bd801903..b1370f18138 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/MultipartCustomProvider.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/MultipartCustomProvider.java @@ -1,20 +1,20 @@ package org.wso2.carbon.device.application.mgt.addons;/* -* 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. -* -*/ +/* 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. + */ import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ValidationInterceptor.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ValidationInterceptor.java index a05ecd82e1c..d36e9986b1e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ValidationInterceptor.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/ValidationInterceptor.java @@ -1,17 +1,16 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, + * 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java index 1bb39f70875..d2a92c4c27c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java @@ -1,20 +1,18 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) 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 + * 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. + * 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.addons.jaxrs; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/Exclude.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/Exclude.java index fc53d16a8b4..e185ececcbd 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/Exclude.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/src/main/java/org/wso2/carbon/device/application/mgt/addons/jaxrs/Exclude.java @@ -1,20 +1,18 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) 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 + * 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. + * 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.addons.jaxrs; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java index 12f64c65866..5daff08cf7c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java @@ -33,7 +33,6 @@ import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseW import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWrapper; import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper; -import java.io.InputStream; import java.util.List; /** @@ -89,7 +88,7 @@ public interface ApplicationManager { ApplicationList getApplications(Filter filter) throws ApplicationManagementException; /** - * To get the ApplicationDTO for given Id. + * To get the Application for given Id. * * @param id id of the ApplicationDTO * @param state state of the ApplicationDTO @@ -98,6 +97,15 @@ public interface ApplicationManager { */ Application getApplicationById(int id, String state) throws ApplicationManagementException; + /** + * To get the Application Release for given uuid. + * + * @param uuid uuid of the ApplicationDTO + * @return the Application Release identified by the UUID + * @throws ApplicationManagementException Application Management Exception. + */ + ApplicationRelease getApplicationReleaseByUUID(String uuid) throws ApplicationManagementException; + /** * To get the ApplicationDTO for given application relase UUID. * diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilityDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilityDAO.java index 9ee48dc2507..4a4b1f30ed7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilityDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilityDAO.java @@ -40,6 +40,8 @@ public interface VisibilityDAO { List getUnrestrictedRoles(int applicationId, int tenantId) throws VisibilityManagementDAOException; + List getUnrestrictedRolesByUUID(String uuid, int tenantId) throws VisibilityManagementDAOException; + void deleteUnrestrictedRoles(List unrestrictedRoles, int applicationId, int tenantId) throws VisibilityManagementDAOException; 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 ad5f520570b..f7c9c634c9c 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 @@ -244,7 +244,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements + "AR.CURRENT_STATE AS RELEASE_CURRENT_STATE, " + "AR.RATED_USERS AS RATED_USER_COUNT " + "FROM AP_APP_RELEASE AS AR " - + "WHERE AR.UUID = ? AND AR.TENAT_ID = ?"; + + "WHERE AR.UUID = ? AND AR.TENANT_ID = ?"; try { connection = this.getDBConnection(); 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/visibility/GenericVisibilityDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java index 51360b4a47b..26f88165b05 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java @@ -104,6 +104,42 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil } } + + @Override + public List getUnrestrictedRolesByUUID(String uuid, int tenantId) throws VisibilityManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get unrestricted roles for UUID: " + uuid); + } + Connection conn; + List unrestrictedRoles = new ArrayList<>(); + String sql = "SELECT ROLE FROM AP_UNRESTRICTED_ROLE " + + "WHERE " + + "AP_APP_ID = (SELECT AR.AP_APP_ID FROM AP_APP_RELEASE AR WHERE AR.UUID = ? AND AR.TENANT_ID = ? ) " + + "AND TENANT_ID = ?"; + try { + conn = this.getDBConnection(); + conn.setAutoCommit(false); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, uuid); + stmt.setInt(2, tenantId); + stmt.setInt(3, tenantId); + try (ResultSet rs = stmt.executeQuery();) { + while (rs.next()) { + unrestrictedRoles.add(rs.getString("ROLE")); + } + return unrestrictedRoles; + } + } + } catch (DBConnectionException e) { + throw new VisibilityManagementDAOException( + "Error occurred while obtaining the DB connection when getting unrestricted roles for UUID: " + + uuid, e); + } catch (SQLException e) { + throw new VisibilityManagementDAOException( + "Error occurred while getting unrestricted roles for UUID: " + uuid, e); + } + } + @Override public void deleteUnrestrictedRoles(List unrestrictedRoles, int applicationId, int tenantId) throws VisibilityManagementDAOException { if (log.isDebugEnabled()) { 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 c9629d8d068..75afd8132cb 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 @@ -874,6 +874,53 @@ public class ApplicationManagerImpl implements ApplicationManager { } } + @Override + public ApplicationRelease getApplicationReleaseByUUID(String uuid) throws ApplicationManagementException{ + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + boolean isVisibleAppRelease = false; + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for the UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + if (applicationReleaseDTO.getCurrentState().equals(lifecycleStateManager.getEndState())) { + return null; + } + + List unrestrictedRoles = this.visibilityDAO.getUnrestrictedRolesByUUID(uuid, tenantId); + if (!unrestrictedRoles.isEmpty()) { + if (hasUserRole(unrestrictedRoles, userName)) { + isVisibleAppRelease = true; + } + } else { + isVisibleAppRelease = true; + } + + if (!isVisibleAppRelease) { + String msg = "You are trying to access release of visibility restricted application. You don't have " + + "required roles to view this application,"; + log.error(msg); + throw new ForbiddenException(msg); + } + return releaseDtoToRelease(applicationReleaseDTO); + } catch (LifecycleManagementException e) { + String msg = "Error occurred when getting the end state of the application lifecycle flow"; + log.error(msg); + throw new ApplicationManagementException(msg, e); + } catch (UserStoreException e) { + String msg = "User-store exception while getting application with the application release UUID: " + uuid; + log.error(msg); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override public ApplicationDTO getApplicationByUuid(String uuid, String state) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); 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 ec80a874d80..47f2f64c1a4 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 @@ -180,6 +180,48 @@ public interface ApplicationManagementPublisherAPI { @QueryParam("state") String state ); + @GET + @Path("/release/{uuid}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "get the application release of requesting application UUID and state", + notes = "This will get the application release identified by the application release uuid and state.", + tags = "ApplicationDTO Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved relevant application release.", + response = ApplicationDTO.class), + @ApiResponse( + code = 403, + message = "Don't have permission to access the application release"), + @ApiResponse( + code = 404, + message = "Application release not found"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting relevant application release.", + response = ErrorResponse.class) + }) + Response getApplicationRelease( + @ApiParam( + name = "uuid", + value = "application release uuid", + required = true) + @PathParam("uuid") String uuid + ); + @PUT @Path("/{appId}") @Produces(MediaType.APPLICATION_JSON) 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 fb53b354ed2..a38e0880ba7 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 @@ -125,6 +125,37 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem } } + @GET + @Consumes("application/json") + @Path("/release/{uuid}") + public Response getApplicationRelease( + @PathParam("uuid") String uuid) { + ApplicationManager applicationManager = APIUtil.getApplicationManager(); + try { + ApplicationRelease applicationRelease = applicationManager.getApplicationReleaseByUUID(uuid); + if (applicationRelease == null){ + String msg = "Application release is in the end state of the application lifecycle flow."; + log.error(msg); + return Response.status(Response.Status.OK).entity(msg).build(); + } + return Response.status(Response.Status.OK).entity(applicationRelease).build(); + } catch (NotFoundException e) { + String msg = "Application Release with UUID: " + uuid + " is not found"; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch(ForbiddenException e){ + String msg = "You don't have permission to access the application release. application release UUID: : " + + uuid; + log.error(msg); + return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); + } + catch (ApplicationManagementException e) { + String msg = "Error occurred while getting application release for UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + @POST @Consumes("multipart/mixed") public Response createApplication(