From 460394c9da5e6c3815012e3f02c993981bfd2b4d Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 26 Apr 2019 09:49:19 +0530 Subject: [PATCH] Improve application edit functionality --- .../impl/ArtifactDownloadAPIImpl.java | 1 - .../mgt/common/dto/ApplicationDTO.java | 12 -- .../common/response/ApplicationRelease.java | 10 ++ .../common/services/ApplicationManager.java | 3 +- .../mgt/core/dao/ApplicationDAO.java | 4 +- .../GenericApplicationDAOImpl.java | 31 ++++ .../mgt/core/impl/ApplicationManagerImpl.java | 153 ++++++++++++------ .../services/ApplicationManagementAPI.java | 3 +- .../impl/ApplicationManagementAPIImpl.java | 10 +- 9 files changed, 155 insertions(+), 72 deletions(-) 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 61b9be5f47..98ae97ed80 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 @@ -55,7 +55,6 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI { Response.ResponseBuilder response = Response .ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM); response.status(Response.Status.OK); -// response.type("application/html"); response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); return response.build(); } catch (NotFoundException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java index 83813c3af3..a058e430eb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java @@ -79,12 +79,6 @@ public class ApplicationDTO { example = "1, 2, 3") private int deviceTypeId; - @ApiModelProperty(name = "deviceTypeName", - value = "Related device type of the application", - required = true, - example = "IoS, Android, Arduino, RaspberryPi etc") - private String deviceTypeName; - @ApiModelProperty(name = "appRating", value = "Rating of the aplication") private int appRating; @@ -168,12 +162,6 @@ public class ApplicationDTO { this.unrestrictedRoles = unrestrictedRoles; } - public String getDeviceTypeName() { - return deviceTypeName; - } - - public void setDeviceTypeName(String deviceTypeName) { this.deviceTypeName = deviceTypeName; } - public int getDeviceTypeId() { return deviceTypeId; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java index f442afc38c..15903198a2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java @@ -66,6 +66,12 @@ public class ApplicationRelease { example = "alpha, beta etc") private String releaseType; + @ApiModelProperty(name = "currentStatus", + value = "CurrentStatus of the Application Release.", + required = true, + example = "CREATED, IN-REVIEW, PUBLISHED etc") + private String currentStatus; + @ApiModelProperty(name = "price", value = "Price of the application release", required = true) @@ -172,4 +178,8 @@ public class ApplicationRelease { public String getSupportedOsVersions() { return supportedOsVersions; } public void setSupportedOsVersions(String supportedOsVersions) { this.supportedOsVersions = supportedOsVersions; } + + public String getCurrentStatus() { return currentStatus; } + + public void setCurrentStatus(String currentStatus) { this.currentStatus = currentStatus; } } 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 b364512ffe..35d4cdb07b 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 @@ -58,7 +58,8 @@ public interface ApplicationManager { * @return Updated Application * @throws ApplicationManagementException ApplicationDTO Management Exception */ - void updateApplication(int applicationId, ApplicationWrapper applicationWrapper) throws ApplicationManagementException; + void updateApplication(int applicationId, ApplicationWrapper applicationWrapper) + throws ApplicationManagementException; /** * Delete an application identified by the unique ID. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java index 2d63e01310..3bd7a484dd 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java @@ -57,9 +57,9 @@ public interface ApplicationDAO { List getAppTags(int appId, int tenantId) throws ApplicationManagementDAOException; - List getAppCategories (int appId, int tenantId) throws ApplicationManagementDAOException; - + void deleteTagMapping (List tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException; + List getAppCategories (int appId, int tenantId) throws ApplicationManagementDAOException; List getAllCategories(int tenantId) throws ApplicationManagementDAOException; 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 eb71671971..e0d06c2346 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 @@ -934,6 +934,37 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } } + @Override + public void deleteTagMapping (List tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException{ + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to delete Tag mappings."); + } + Connection conn; + String sql = "DELETE FROM " + + "AP_APP_TAG_MAPPING tm " + + "WHERE " + + "tm.AP_APP_TAG_ID = ? AND " + + "tm.AP_APP_ID = ? AND " + + "tm.TENANT_ID = ?"; + try { + conn = this.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)){ + for (Integer tagId : tagIds){ + stmt.setInt(1, tagId); + stmt.setInt(2, applicationId); + stmt.setInt(3, tenantId); + stmt.addBatch(); + } + stmt.executeBatch(); + } + } catch (DBConnectionException e) { + throw new ApplicationManagementDAOException( + "Error occurred while obtaining the DB connection when deleting tag mapppig", e); + } catch (SQLException e) { + throw new ApplicationManagementDAOException("Error occurred when deleting tag mapping", e); + } + } + @Override public List getAppCategories(int appId, int tenantId) throws ApplicationManagementDAOException { 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 bbd8489d9f..370c770af1 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 @@ -145,8 +145,8 @@ public class ApplicationManagerImpl implements ApplicationManager { ApplicationReleaseDTO initialApplicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0); applicationDTO.getApplicationReleaseDTOs().clear(); - ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(), applicationDTO.getDeviceTypeName(), - initialApplicationReleaseDTO, applicationArtifact); + ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(), + applicationWrapper.getDeviceType(), initialApplicationReleaseDTO, applicationArtifact); applicationDTO.getApplicationReleaseDTOs().add(addImageArtifacts(applicationReleaseDTO, applicationArtifact)); } catch (UnexpectedServerErrorException e) { String msg = "Error occurred when getting Device Type data."; @@ -550,7 +550,7 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!haveAllUserRoles(filteringUnrestrictedRoles, userName)) { String msg = "At least one filtering role is not assigned for the user: " + userName + ". Hence user " + userName - + " Can't filter applications by giving these unrestriced role list"; + + " Can't filter applications by giving these unrestricted role list"; log.error(msg); throw new BadRequestException(msg); } @@ -582,8 +582,9 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new NotFoundException(msg); } + DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId()); ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(), - applicationDTO.getDeviceTypeName(), releaseWrapperToReleaseDTO(applicationReleaseWrapper), + deviceType.getName(), releaseWrapperToReleaseDTO(applicationReleaseWrapper), applicationArtifact); applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact); @@ -630,18 +631,23 @@ public class ApplicationManagerImpl implements ApplicationManager { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); ApplicationDTO applicationDTO; - List filteredApplicationReleaseDTOs; boolean isVisibleApp = false; try { ConnectionManagerUtil.openDBConnection(); applicationDTO = this.applicationDAO.getApplicationById(appId, tenantId); if (applicationDTO == null) { - throw new NotFoundException("Couldn't find an application for application Id: " + appId); + String msg = "Couldn't find an application for application Id: " + appId; + log.error(msg); + throw new NotFoundException(msg); } - filteredApplicationReleaseDTOs = applicationDTO.getApplicationReleaseDTOs().stream() - .filter(applicationReleaseDTO -> applicationReleaseDTO.getCurrentState().equals(state)) - .collect(Collectors.toList()); + List filteredApplicationReleaseDTOs = new ArrayList<>(); + for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) { + if (!applicationReleaseDTO.getCurrentState().equals(lifecycleStateManager.getEndState()) && ( + state == null || applicationReleaseDTO.getCurrentState().equals(state))) { + filteredApplicationReleaseDTOs.add(applicationReleaseDTO); + } + } applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs); if (applicationDTO.getApplicationReleaseDTOs().isEmpty()){ return null; @@ -674,9 +680,14 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new ForbiddenException(msg); } return appDtoToAppResponse(applicationDTO); - } catch (UserStoreException e) { - throw new ApplicationManagementException( - "User-store exception while getting application with the application id " + appId); + } catch (LifecycleManagementException e){ + String msg = "Error occurred when getting the last 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 id " + appId; + log.error(msg); + throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -1438,14 +1449,36 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new BadRequestException(msg); } - if (!StringUtils.isEmpty(applicationWrapper.getDeviceType()) && !applicationDTO.getDeviceTypeName() - .equals(applicationWrapper.getDeviceType())) { - String msg = "You are trying to change the compatible device type of the application type and it is not " - + "possible after you create an application for device type. " + - applicationWrapper.getDeviceType() + "Therefore please remove this application and publish " - + "new application with device type: " + applicationWrapper.getDeviceType(); - log.error(msg); - throw new BadRequestException(msg); + + String deviceTypeName = applicationWrapper.getDeviceType(); + if (!StringUtils.isEmpty(deviceTypeName)) { + DeviceType deviceType = getDeviceTypeData(deviceTypeName); + if (!deviceType.getName().equals(deviceTypeName)){ + String msg = "You are trying to change the compatible device type of the application type and it is " + + "not possible after you create an application for device type. " + deviceTypeName + + "Therefore please remove this application and publish new application with device type: " + + deviceTypeName; + log.error(msg); + throw new BadRequestException(msg); + } + } + if (!StringUtils.isEmpty(applicationWrapper.getName())){ + Filter filter = new Filter(); + filter.setFullMatch(true); + filter.setAppName(applicationWrapper.getName().trim()); + filter.setOffset(0); + filter.setLimit(1); + + List applicationList = applicationDAO + .getApplications(filter, applicationDTO.getDeviceTypeId(), tenantId); + if (!applicationList.isEmpty()) { + String msg = "Already an application registered with same name " + applicationWrapper.getName() + + ". Hence you can't update the application name from " + applicationDTO.getName() + " to " + + applicationWrapper.getName(); + log.error(msg); + throw new BadRequestException(msg); + } + applicationDTO.setName(applicationWrapper.getName()); } if (!StringUtils.isEmpty(applicationWrapper.getSubType()) && !applicationDTO.getSubType() .equals(applicationWrapper.getSubType())) { @@ -1473,30 +1506,12 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationDTO.setSubType(applicationWrapper.getSubType()); applicationDTO.setPaymentCurrency(applicationWrapper.getPaymentCurrency()); } - if (!StringUtils.isEmpty(applicationWrapper.getName())){ - Filter filter = new Filter(); - filter.setFullMatch(true); - filter.setAppName(applicationWrapper.getName().trim()); - filter.setOffset(0); - filter.setLimit(1); - List applicationList = applicationDAO - .getApplications(filter, applicationDTO.getDeviceTypeId(), tenantId); - if (!applicationList.isEmpty()) { - String msg = "Already an application registered with same name " + applicationWrapper.getName() - + ". Hence you can't update the application name from " + applicationDTO.getName() + " to " - + applicationWrapper.getName(); - log.error(msg); - throw new BadRequestException(msg); - } - applicationDTO.setName(applicationWrapper.getName()); - } if (!StringUtils.isEmpty(applicationWrapper.getDescription())){ applicationDTO.setDescription(applicationWrapper.getDescription()); } List appUnrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationId, tenantId); - List appCategories = this.applicationDAO.getAppCategories(applicationId, tenantId); boolean isExistingAppRestricted = !appUnrestrictedRoles.isEmpty(); boolean isUpdatingAppRestricted = !applicationWrapper.getUnrestrictedRoles().isEmpty(); @@ -1533,15 +1548,48 @@ public class ApplicationManagerImpl implements ApplicationManager { } applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles()); - List appTags = this.applicationDAO.getAppTags(applicationId, tenantId); - List addingTagList = getDifference(appTags, applicationWrapper.getTags()); - List removingTagList = getDifference(applicationWrapper.getTags(), appTags); - if (!addingTagList.isEmpty()) { -// applicationDAO.addTags(addingTags, application.getId(), tenantId); + String updatingAppCategory = applicationWrapper.getAppCategory(); + if ( updatingAppCategory != null){ + List appCategories = this.applicationDAO.getAppCategories(applicationId, tenantId); + if (!appCategories.contains(updatingAppCategory)){ + List allCategories = this.applicationDAO.getAllCategories(tenantId); + List categoryIds = allCategories.stream() + .filter(category -> category.getCategoryName().equals(updatingAppCategory)) + .map(CategoryDTO::getId).collect(Collectors.toList()); + if (!categoryIds.isEmpty()){ + String msg = + "You are trying to update application category into invalid application category, " + + "it is not registered in the system. Therefore please register the category " + + updatingAppCategory + " and perform the action"; + log.error(msg); + throw new BadRequestException(msg); + } + this.applicationDAO.addCategoryMapping(categoryIds, applicationId, tenantId); + } } - if (!removingTagList.isEmpty()) { - applicationDAO.deleteTags(removingTagList, applicationId, tenantId); + + List updatingAppTags = applicationWrapper.getTags(); + if ( updatingAppTags!= null){ + List appTags = this.applicationDAO.getAppTags(applicationId, tenantId); + List addingTagList = getDifference(appTags, updatingAppTags); + List removingTagList = getDifference(updatingAppTags, appTags); + if (!addingTagList.isEmpty()) { + List allTags = this.applicationDAO.getAllTags(tenantId); + List newTags = addingTagList.stream().filter(updatingTagName -> allTags.stream() + .noneMatch(tag -> tag.getTagName().equals(updatingTagName))).collect(Collectors.toList()); + if (!newTags.isEmpty()){ + this.applicationDAO.addTags(newTags, tenantId); + } + List addingTagIds = this.applicationDAO.getTagIdsForTagNames(addingTagList, tenantId); + this.applicationDAO.addTagMapping(addingTagIds, applicationId, tenantId); + } + if (!removingTagList.isEmpty()) { + List removingTagIds = this.applicationDAO.getTagIdsForTagNames(removingTagList, tenantId); + this.applicationDAO.deleteTagMapping(removingTagIds, applicationId, tenantId); + applicationDAO.deleteTags(removingTagList, applicationId, tenantId); + } } + //todo applicationDAO.editApplication(applicationDTO, tenantId); } catch (UserStoreException e) { ConnectionManagerUtil.rollbackDBTransaction(); @@ -1904,7 +1952,6 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationDTO.setTags(applicationWrapper.getTags()); applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles()); applicationDTO.setDeviceTypeId(deviceType.getId()); - applicationDTO.setDeviceTypeName(deviceType.getName()); List applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers() .stream().map(this::releaseWrapperToReleaseDTO).collect(Collectors.toList()); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); @@ -1923,9 +1970,11 @@ public class ApplicationManagerImpl implements ApplicationManager { return applicationReleaseDTO; } - private Application appDtoToAppResponse(ApplicationDTO applicationDTO) { + private Application appDtoToAppResponse(ApplicationDTO applicationDTO) + throws BadRequestException, UnexpectedServerErrorException { Application application = new Application(); + DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId()); application.setId(applicationDTO.getId()); application.setName(applicationDTO.getName()); application.setDescription(applicationDTO.getDescription()); @@ -1935,7 +1984,7 @@ public class ApplicationManagerImpl implements ApplicationManager { application.setPaymentCurrency(applicationDTO.getPaymentCurrency()); application.setTags(applicationDTO.getTags()); application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles()); - application.setDeviceType(applicationDTO.getDeviceTypeName()); + application.setDeviceType(deviceType.getName()); List applicationReleases = applicationDTO.getApplicationReleaseDTOs() .stream().map(this::releaseDtoToRelease).collect(Collectors.toList()); application.setApplicationReleases(applicationReleases); @@ -1943,7 +1992,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } private ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO){ - String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration().getArtifactDownloadEndpoint(); + String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration() + .getArtifactDownloadEndpoint(); String basePath = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid(); ApplicationRelease applicationRelease = new ApplicationRelease(); applicationRelease.setDescription(applicationReleaseDTO.getDescription()); @@ -1953,8 +2003,11 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants()); applicationRelease.setMetaData(applicationReleaseDTO.getMetaData()); applicationRelease.setUrl(applicationReleaseDTO.getUrl()); + applicationRelease.setCurrentStatus(applicationReleaseDTO.getCurrentState()); + applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants()); applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); - applicationRelease.setInstallerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getInstallerName()); + applicationRelease + .setInstallerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getInstallerName()); applicationRelease.setIconPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName()); applicationRelease.setBannerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getBannerName()); 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 69715b5998..02042a4125 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 @@ -176,8 +176,7 @@ public interface ApplicationManagementAPI { @PathParam("appId") int appId, @ApiParam( name = "state", - value = "state", - defaultValue = "PUBLISHED") + value = "state") @QueryParam("state") String state ); 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 4c4e49a2b7..3b99f1c50b 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 @@ -102,15 +102,14 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { @Path("/{appId}") public Response getApplication( @PathParam("appId") int appId, - @DefaultValue("PUBLISHED") @QueryParam("state") String state) { + @QueryParam("state") String state) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { Application application = applicationManager.getApplicationById(appId, state); if (application == null){ - String msg = "Couldn't found an application release which is in " + state + " state for application id " - + appId; + String msg = "Could not found an application release which is in " + state + " state."; log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + return Response.status(Response.Status.OK).entity(msg).build(); } return Response.status(Response.Status.OK).entity(application).build(); } catch (NotFoundException e) { @@ -317,6 +316,9 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { } } + /* + //todo ---------------------- + */ @PUT @Consumes("application/json")