Improve application edit functionality

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 9fab48839d
commit 460394c9da

@ -55,7 +55,6 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI {
Response.ResponseBuilder response = Response Response.ResponseBuilder response = Response
.ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM); .ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM);
response.status(Response.Status.OK); response.status(Response.Status.OK);
// response.type("application/html");
response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
return response.build(); return response.build();
} catch (NotFoundException e) { } catch (NotFoundException e) {

@ -79,12 +79,6 @@ public class ApplicationDTO {
example = "1, 2, 3") example = "1, 2, 3")
private int deviceTypeId; 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", @ApiModelProperty(name = "appRating",
value = "Rating of the aplication") value = "Rating of the aplication")
private int appRating; private int appRating;
@ -168,12 +162,6 @@ public class ApplicationDTO {
this.unrestrictedRoles = unrestrictedRoles; this.unrestrictedRoles = unrestrictedRoles;
} }
public String getDeviceTypeName() {
return deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) { this.deviceTypeName = deviceTypeName; }
public int getDeviceTypeId() { public int getDeviceTypeId() {
return deviceTypeId; return deviceTypeId;
} }

@ -66,6 +66,12 @@ public class ApplicationRelease {
example = "alpha, beta etc") example = "alpha, beta etc")
private String releaseType; 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", @ApiModelProperty(name = "price",
value = "Price of the application release", value = "Price of the application release",
required = true) required = true)
@ -172,4 +178,8 @@ public class ApplicationRelease {
public String getSupportedOsVersions() { return supportedOsVersions; } public String getSupportedOsVersions() { return supportedOsVersions; }
public void setSupportedOsVersions(String supportedOsVersions) { this.supportedOsVersions = supportedOsVersions; } public void setSupportedOsVersions(String supportedOsVersions) { this.supportedOsVersions = supportedOsVersions; }
public String getCurrentStatus() { return currentStatus; }
public void setCurrentStatus(String currentStatus) { this.currentStatus = currentStatus; }
} }

@ -58,7 +58,8 @@ public interface ApplicationManager {
* @return Updated Application * @return Updated Application
* @throws ApplicationManagementException ApplicationDTO Management Exception * @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. * Delete an application identified by the unique ID.

@ -57,9 +57,9 @@ public interface ApplicationDAO {
List<String> getAppTags(int appId, int tenantId) throws ApplicationManagementDAOException; List<String> getAppTags(int appId, int tenantId) throws ApplicationManagementDAOException;
List<String> getAppCategories (int appId, int tenantId) throws ApplicationManagementDAOException; void deleteTagMapping (List<Integer> tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException;
List<String> getAppCategories (int appId, int tenantId) throws ApplicationManagementDAOException;
List<CategoryDTO> getAllCategories(int tenantId) throws ApplicationManagementDAOException; List<CategoryDTO> getAllCategories(int tenantId) throws ApplicationManagementDAOException;

@ -934,6 +934,37 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
} }
@Override
public void deleteTagMapping (List<Integer> 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 @Override
public List<String> getAppCategories(int appId, int tenantId) throws ApplicationManagementDAOException { public List<String> getAppCategories(int appId, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

@ -145,8 +145,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO initialApplicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0); ApplicationReleaseDTO initialApplicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
applicationDTO.getApplicationReleaseDTOs().clear(); applicationDTO.getApplicationReleaseDTOs().clear();
ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(), applicationDTO.getDeviceTypeName(), ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(),
initialApplicationReleaseDTO, applicationArtifact); applicationWrapper.getDeviceType(), initialApplicationReleaseDTO, applicationArtifact);
applicationDTO.getApplicationReleaseDTOs().add(addImageArtifacts(applicationReleaseDTO, applicationArtifact)); applicationDTO.getApplicationReleaseDTOs().add(addImageArtifacts(applicationReleaseDTO, applicationArtifact));
} catch (UnexpectedServerErrorException e) { } catch (UnexpectedServerErrorException e) {
String msg = "Error occurred when getting Device Type data."; String msg = "Error occurred when getting Device Type data.";
@ -550,7 +550,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (!haveAllUserRoles(filteringUnrestrictedRoles, userName)) { if (!haveAllUserRoles(filteringUnrestrictedRoles, userName)) {
String msg = String msg =
"At least one filtering role is not assigned for the user: " + userName + ". Hence user " + userName "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); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -582,8 +582,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg); log.error(msg);
throw new NotFoundException(msg); throw new NotFoundException(msg);
} }
DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId());
ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(), ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(),
applicationDTO.getDeviceTypeName(), releaseWrapperToReleaseDTO(applicationReleaseWrapper), deviceType.getName(), releaseWrapperToReleaseDTO(applicationReleaseWrapper),
applicationArtifact); applicationArtifact);
applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact); applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact);
@ -630,18 +631,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
ApplicationDTO applicationDTO; ApplicationDTO applicationDTO;
List<ApplicationReleaseDTO> filteredApplicationReleaseDTOs;
boolean isVisibleApp = false; boolean isVisibleApp = false;
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
applicationDTO = this.applicationDAO.getApplicationById(appId, tenantId); applicationDTO = this.applicationDAO.getApplicationById(appId, tenantId);
if (applicationDTO == null) { 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() List<ApplicationReleaseDTO> filteredApplicationReleaseDTOs = new ArrayList<>();
.filter(applicationReleaseDTO -> applicationReleaseDTO.getCurrentState().equals(state)) for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) {
.collect(Collectors.toList()); if (!applicationReleaseDTO.getCurrentState().equals(lifecycleStateManager.getEndState()) && (
state == null || applicationReleaseDTO.getCurrentState().equals(state))) {
filteredApplicationReleaseDTOs.add(applicationReleaseDTO);
}
}
applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs); applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs);
if (applicationDTO.getApplicationReleaseDTOs().isEmpty()){ if (applicationDTO.getApplicationReleaseDTOs().isEmpty()){
return null; return null;
@ -674,9 +680,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ForbiddenException(msg); throw new ForbiddenException(msg);
} }
return appDtoToAppResponse(applicationDTO); return appDtoToAppResponse(applicationDTO);
} catch (UserStoreException e) { } catch (LifecycleManagementException e){
throw new ApplicationManagementException( String msg = "Error occurred when getting the last state of the application lifecycle flow";
"User-store exception while getting application with the application id " + appId); 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 { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -1438,15 +1449,37 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (!StringUtils.isEmpty(applicationWrapper.getDeviceType()) && !applicationDTO.getDeviceTypeName()
.equals(applicationWrapper.getDeviceType())) { String deviceTypeName = applicationWrapper.getDeviceType();
String msg = "You are trying to change the compatible device type of the application type and it is not " if (!StringUtils.isEmpty(deviceTypeName)) {
+ "possible after you create an application for device type. " + DeviceType deviceType = getDeviceTypeData(deviceTypeName);
applicationWrapper.getDeviceType() + "Therefore please remove this application and publish " if (!deviceType.getName().equals(deviceTypeName)){
+ "new application with device type: " + 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. " + 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<ApplicationDTO> 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); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
applicationDTO.setName(applicationWrapper.getName());
}
if (!StringUtils.isEmpty(applicationWrapper.getSubType()) && !applicationDTO.getSubType() if (!StringUtils.isEmpty(applicationWrapper.getSubType()) && !applicationDTO.getSubType()
.equals(applicationWrapper.getSubType())) { .equals(applicationWrapper.getSubType())) {
if (!ApplicationSubscriptionType.PAID.toString().equals(applicationWrapper.getSubType()) if (!ApplicationSubscriptionType.PAID.toString().equals(applicationWrapper.getSubType())
@ -1473,30 +1506,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationDTO.setSubType(applicationWrapper.getSubType()); applicationDTO.setSubType(applicationWrapper.getSubType());
applicationDTO.setPaymentCurrency(applicationWrapper.getPaymentCurrency()); 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<ApplicationDTO> 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())){ if (!StringUtils.isEmpty(applicationWrapper.getDescription())){
applicationDTO.setDescription(applicationWrapper.getDescription()); applicationDTO.setDescription(applicationWrapper.getDescription());
} }
List<String> appUnrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationId, tenantId); List<String> appUnrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationId, tenantId);
List<String> appCategories = this.applicationDAO.getAppCategories(applicationId, tenantId);
boolean isExistingAppRestricted = !appUnrestrictedRoles.isEmpty(); boolean isExistingAppRestricted = !appUnrestrictedRoles.isEmpty();
boolean isUpdatingAppRestricted = !applicationWrapper.getUnrestrictedRoles().isEmpty(); boolean isUpdatingAppRestricted = !applicationWrapper.getUnrestrictedRoles().isEmpty();
@ -1533,15 +1548,48 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles()); applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles());
String updatingAppCategory = applicationWrapper.getAppCategory();
if ( updatingAppCategory != null){
List<String> appCategories = this.applicationDAO.getAppCategories(applicationId, tenantId);
if (!appCategories.contains(updatingAppCategory)){
List<CategoryDTO> allCategories = this.applicationDAO.getAllCategories(tenantId);
List<Integer> 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);
}
}
List<String> updatingAppTags = applicationWrapper.getTags();
if ( updatingAppTags!= null){
List<String> appTags = this.applicationDAO.getAppTags(applicationId, tenantId); List<String> appTags = this.applicationDAO.getAppTags(applicationId, tenantId);
List<String> addingTagList = getDifference(appTags, applicationWrapper.getTags()); List<String> addingTagList = getDifference(appTags, updatingAppTags);
List<String> removingTagList = getDifference(applicationWrapper.getTags(), appTags); List<String> removingTagList = getDifference(updatingAppTags, appTags);
if (!addingTagList.isEmpty()) { if (!addingTagList.isEmpty()) {
// applicationDAO.addTags(addingTags, application.getId(), tenantId); List<TagDTO> allTags = this.applicationDAO.getAllTags(tenantId);
List<String> 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<Integer> addingTagIds = this.applicationDAO.getTagIdsForTagNames(addingTagList, tenantId);
this.applicationDAO.addTagMapping(addingTagIds, applicationId, tenantId);
} }
if (!removingTagList.isEmpty()) { if (!removingTagList.isEmpty()) {
List<Integer> removingTagIds = this.applicationDAO.getTagIdsForTagNames(removingTagList, tenantId);
this.applicationDAO.deleteTagMapping(removingTagIds, applicationId, tenantId);
applicationDAO.deleteTags(removingTagList, applicationId, tenantId); applicationDAO.deleteTags(removingTagList, applicationId, tenantId);
} }
}
//todo
applicationDAO.editApplication(applicationDTO, tenantId); applicationDAO.editApplication(applicationDTO, tenantId);
} catch (UserStoreException e) { } catch (UserStoreException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
@ -1904,7 +1952,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationDTO.setTags(applicationWrapper.getTags()); applicationDTO.setTags(applicationWrapper.getTags());
applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles()); applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles());
applicationDTO.setDeviceTypeId(deviceType.getId()); applicationDTO.setDeviceTypeId(deviceType.getId());
applicationDTO.setDeviceTypeName(deviceType.getName());
List<ApplicationReleaseDTO> applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers() List<ApplicationReleaseDTO> applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers()
.stream().map(this::releaseWrapperToReleaseDTO).collect(Collectors.toList()); .stream().map(this::releaseWrapperToReleaseDTO).collect(Collectors.toList());
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
@ -1923,9 +1970,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
return applicationReleaseDTO; return applicationReleaseDTO;
} }
private Application appDtoToAppResponse(ApplicationDTO applicationDTO) { private Application appDtoToAppResponse(ApplicationDTO applicationDTO)
throws BadRequestException, UnexpectedServerErrorException {
Application application = new Application(); Application application = new Application();
DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId());
application.setId(applicationDTO.getId()); application.setId(applicationDTO.getId());
application.setName(applicationDTO.getName()); application.setName(applicationDTO.getName());
application.setDescription(applicationDTO.getDescription()); application.setDescription(applicationDTO.getDescription());
@ -1935,7 +1984,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
application.setPaymentCurrency(applicationDTO.getPaymentCurrency()); application.setPaymentCurrency(applicationDTO.getPaymentCurrency());
application.setTags(applicationDTO.getTags()); application.setTags(applicationDTO.getTags());
application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles()); application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles());
application.setDeviceType(applicationDTO.getDeviceTypeName()); application.setDeviceType(deviceType.getName());
List<ApplicationRelease> applicationReleases = applicationDTO.getApplicationReleaseDTOs() List<ApplicationRelease> applicationReleases = applicationDTO.getApplicationReleaseDTOs()
.stream().map(this::releaseDtoToRelease).collect(Collectors.toList()); .stream().map(this::releaseDtoToRelease).collect(Collectors.toList());
application.setApplicationReleases(applicationReleases); application.setApplicationReleases(applicationReleases);
@ -1943,7 +1992,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
private ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO){ 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(); String basePath = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid();
ApplicationRelease applicationRelease = new ApplicationRelease(); ApplicationRelease applicationRelease = new ApplicationRelease();
applicationRelease.setDescription(applicationReleaseDTO.getDescription()); applicationRelease.setDescription(applicationReleaseDTO.getDescription());
@ -1953,8 +2003,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants()); applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants());
applicationRelease.setMetaData(applicationReleaseDTO.getMetaData()); applicationRelease.setMetaData(applicationReleaseDTO.getMetaData());
applicationRelease.setUrl(applicationReleaseDTO.getUrl()); applicationRelease.setUrl(applicationReleaseDTO.getUrl());
applicationRelease.setCurrentStatus(applicationReleaseDTO.getCurrentState());
applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants());
applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); 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.setIconPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName());
applicationRelease.setBannerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getBannerName()); applicationRelease.setBannerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getBannerName());

@ -176,8 +176,7 @@ public interface ApplicationManagementAPI {
@PathParam("appId") int appId, @PathParam("appId") int appId,
@ApiParam( @ApiParam(
name = "state", name = "state",
value = "state", value = "state")
defaultValue = "PUBLISHED")
@QueryParam("state") String state @QueryParam("state") String state
); );

@ -102,15 +102,14 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@Path("/{appId}") @Path("/{appId}")
public Response getApplication( public Response getApplication(
@PathParam("appId") int appId, @PathParam("appId") int appId,
@DefaultValue("PUBLISHED") @QueryParam("state") String state) { @QueryParam("state") String state) {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
try { try {
Application application = applicationManager.getApplicationById(appId, state); Application application = applicationManager.getApplicationById(appId, state);
if (application == null){ if (application == null){
String msg = "Couldn't found an application release which is in " + state + " state for application id " String msg = "Could not found an application release which is in " + state + " state.";
+ appId;
log.error(msg); 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(); return Response.status(Response.Status.OK).entity(application).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
@ -317,6 +316,9 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
} }
} }
/*
//todo ----------------------
*/
@PUT @PUT
@Consumes("application/json") @Consumes("application/json")

Loading…
Cancel
Save