Add support for application category list adding for an application.

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent be992c4b8d
commit c6440a779d

@ -0,0 +1,32 @@
/* 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.common;
public class LifecycleChanger {
private String action;
private String reason;
public String getAction() { return action; }
public void setAction(String action) { this.action = action; }
public String getReason() { return reason; }
public void setReason(String reason) { this.reason = reason; }
}

@ -49,6 +49,10 @@ public class LifecycleState {
value = "Timestamp of the lifecycle has been updated")
private Timestamp updatedAt;
@ApiModelProperty(name = "resonForChange",
value = "Reason for the application release lifecycle change from previous state to current state.")
private String resonForChange;
public String getCurrentState() {
return currentState;
}
@ -88,4 +92,8 @@ public class LifecycleState {
public void setNextStates(List<String> nextStates) {
this.nextStates = nextStates;
}
public String getResonForChange() { return resonForChange; }
public void setResonForChange(String resonForChange) { this.resonForChange = resonForChange; }
}

@ -41,11 +41,11 @@ public class ApplicationDTO {
required = true)
private String description;
@ApiModelProperty(name = "appCategory",
@ApiModelProperty(name = "appCategories",
value = "Category of the application",
required = true,
example = "Educational, Gaming, Travel, Entertainment etc")
private String appCategory;
private List<String> appCategories;
@ApiModelProperty(name = "type",
value = "Type of the application",
@ -108,13 +108,11 @@ public class ApplicationDTO {
public void setName(String name) { this.name = name; }
public String getAppCategory() {
return appCategory;
public List<String> getAppCategories() {
return appCategories;
}
public void setAppCategory(String appCategory) {
this.appCategory = appCategory;
}
public void setAppCategories(List<String> appCategories) { this.appCategories = appCategories; }
public List<String> getTags() { return tags; }

@ -35,11 +35,11 @@ public class Application {
required = true)
private String description;
@ApiModelProperty(name = "appCategory",
@ApiModelProperty(name = "appCategories",
value = "CategoryDTO of the application",
required = true,
example = "Educational, Gaming, Travel, Entertainment etc")
private String appCategory;
private List<String> appCategories;
@ApiModelProperty(name = "type",
value = "Type of the application",
@ -88,12 +88,12 @@ public class Application {
public void setName(String name) { this.name = name; }
public String getAppCategory() {
return appCategory;
public List<String> getAppCategories() {
return appCategories;
}
public void setAppCategory(String appCategory) {
this.appCategory = appCategory;
public void setAppCategories(List<String> appCategories) {
this.appCategories = appCategories;
}
public List<String> getTags() { return tags; }

@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.common.services;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.wso2.carbon.device.application.mgt.common.ApplicationArtifact;
import org.wso2.carbon.device.application.mgt.common.LifecycleChanger;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
@ -147,10 +148,11 @@ public interface ApplicationManager {
* To get all the releases of a particular ApplicationDTO.
*
* @param releaseUuid UUID of the ApplicationDTO Release.
* @param stateName Lifecycle state to change the app
* @param lifecycleChanger Lifecycle changer that contains the action and the reson for the change.
* @throws ApplicationManagementException ApplicationDTO Management Exception.
*/
void changeLifecycleState(String releaseUuid, String stateName) throws ApplicationManagementException;
void changeLifecycleState(String releaseUuid, LifecycleChanger lifecycleChanger)
throws ApplicationManagementException;
/**
* To update release images such as icons, banner and screenshots.

@ -35,11 +35,11 @@ public class ApplicationWrapper {
required = true)
private String description;
@ApiModelProperty(name = "appCategory",
@ApiModelProperty(name = "appCategories",
value = "CategoryDTO of the application",
required = true,
example = "Educational, Gaming, Travel, Entertainment etc")
private String appCategory;
private List<String> appCategories;
@ApiModelProperty(name = "type",
value = "Type of the application",
@ -85,12 +85,10 @@ public class ApplicationWrapper {
public void setName(String name) { this.name = name; }
public String getAppCategory() {
return appCategory;
}
public List<String> getAppCategories() { return appCategories; }
public void setAppCategory(String appCategory) {
this.appCategory = appCategory;
public void setAppCategories(List<String> appCategories) {
this.appCategories = appCategories;
}
public List<String> getTags() { return tags; }

@ -1478,7 +1478,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
application.setId(rs.getInt("APP_ID"));
application.setName(rs.getString("APP_NAME"));
application.setType(rs.getString("APP_TYPE"));
application.setAppCategory(rs.getString("APP_CATEGORY"));
// application.setAppCategories(rs.getString("APP_CATEGORY"));
application.setSubType(rs.getString("SUB_TYPE"));
application.setPaymentCurrency(rs.getString("CURRENCY"));
// application.setIsRestricted(rs.getBoolean("RESTRICTED"));

@ -174,9 +174,10 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
+ "TENANT_ID, "
+ "UPDATED_BY, "
+ "UPDATED_AT, "
+ "REASON, "
+ "AP_APP_RELEASE_ID, "
+ "AP_APP_ID) "
+ "VALUES (?, ?, ?, ?, ?, ?, (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE ID = ?));";
+ "VALUES (?, ?, ?, ?, ?, ?, ?, (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE ID = ?));";
Calendar calendar = Calendar.getInstance();
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
@ -187,8 +188,9 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
stmt.setInt(3, tenantId);
stmt.setString(4, state.getUpdatedBy());
stmt.setTimestamp(5, timestamp);
stmt.setInt(6, appReleaseId);
stmt.setString(6, state.getResonForChange());
stmt.setInt(7, appReleaseId);
stmt.setInt(8, appReleaseId);
stmt.executeUpdate();
} catch (DBConnectionException e) {
log.error("Error occurred while obtaining the DB connection.", e);

@ -29,6 +29,7 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.ApplicationArtifact;
import org.wso2.carbon.device.application.mgt.common.ApplicationInstaller;
import org.wso2.carbon.device.application.mgt.common.LifecycleChanger;
import org.wso2.carbon.device.application.mgt.common.Pagination;
import org.wso2.carbon.device.application.mgt.common.config.RatingConfiguration;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
@ -84,6 +85,7 @@ import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.ws.rs.core.Response;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -96,7 +98,6 @@ 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;
@ -149,7 +150,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationDTO applicationDTO;
List<String> unrestrictedRoles;
Optional<CategoryDTO> category;
List<Integer> categoryIds = new ArrayList<>();
List<String> tags;
//validating and verifying application data
@ -189,7 +190,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
List<CategoryDTO> registeredCategories = this.applicationDAO.getAllCategories(tenantId);
String categoryName = applicationWrapper.getAppCategory();
List<String> appCategories = applicationWrapper.getAppCategories();
if (registeredCategories.isEmpty()) {
ConnectionManagerUtil.rollbackDBTransaction();
@ -198,13 +199,21 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new ApplicationManagementException(msg);
}
category = registeredCategories.stream().filter(obj -> obj.getCategoryName().equals(categoryName))
.findAny();
if (!category.isPresent()) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Request contains invalid category: " + categoryName;
log.error(msg);
throw new ApplicationManagementException(msg);
for (String cat : appCategories) {
boolean isValidCategory = false;
for (CategoryDTO obj : registeredCategories) {
if (cat.equals(obj.getCategoryName())) {
categoryIds.add(obj.getId());
isValidCategory = true;
break;
}
}
if (!isValidCategory) {
String msg = "Application Creating request contains invalid categories. Hence please verify the "
+ "application creating payload.";
log.error(msg);
throw new BadRequestException(msg);
}
}
} catch (DBConnectionException e) {
String msg = "Error occurred while getting database connection.";
@ -260,6 +269,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (log.isDebugEnabled()) {
log.debug("New ApplicationDTO entry added to AP_APP table. App Id:" + appId);
}
//add application categories
this.applicationDAO.addCategoryMapping(categoryIds, appId, tenantId);
//adding application unrestricted roles
if (unrestrictedRoles != null && !unrestrictedRoles.isEmpty()) {
this.visibilityDAO.addUnrestrictedRoles(unrestrictedRoles, appId, tenantId);
@ -269,15 +281,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
}
/*
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<Integer> categoryIds = new ArrayList<>();
categoryIds.add(category.get().getId());
this.applicationDAO.addCategoryMapping(categoryIds, appId, tenantId);
//adding application tags
if (tags != null && !tags.isEmpty()) {
List<TagDTO> registeredTags = applicationDAO.getAllTags(tenantId);
@ -623,6 +626,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
if (filter == null) {
String msg = "Request Payload is null";
log.error(msg);
throw new BadRequestException(msg);
}
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
ApplicationList applicationList = new ApplicationList();
@ -631,24 +639,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
List<ApplicationDTO> filteredApplications = new ArrayList<>();
DeviceType deviceType = null;
try {
//set default values
if (filter.getLimit() == 0) {
filter.setLimit(20);
}
String deviceTypename = filter.getDeviceType();
if (!StringUtils.isEmpty(deviceTypename)) {
deviceType = getDeviceTypeData(deviceTypename);
}
if (deviceType == null) {
deviceType = new DeviceType();
deviceType.setId(-1);
}
//set default values
if (!StringUtils.isEmpty(filter.getDeviceType())) {
deviceType = getDeviceTypeData(filter.getDeviceType());
}
if (filter.getLimit() == 0) {
filter.setLimit(20);
}
if (deviceType == null) {
deviceType = new DeviceType();
deviceType.setId(-1);
}
try {
ConnectionManagerUtil.openDBConnection();
validateFilter(filter);
appDTOs = applicationDAO.getApplications(filter, deviceType.getId(), tenantId);
//todo as a performance improvement get these data from DB. Consider where in clause.
for (ApplicationDTO applicationDTO : appDTOs) {
boolean isSearchingApp = true;
List<String> filteringTags = filter.getTags();
@ -656,14 +663,18 @@ public class ApplicationManagerImpl implements ApplicationManager {
List<String> filteringUnrestrictedRoles = filter.getUnrestrictedRoles();
if (!lifecycleStateManager.getEndState().equals(applicationDTO.getStatus())) {
List<String> appUnrestrictedRoles = visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
List<String> appUnrestrictedRoles = visibilityDAO
.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
applicationDTO.setUnrestrictedRoles(appUnrestrictedRoles);
if ((appUnrestrictedRoles.isEmpty() || hasUserRole(appUnrestrictedRoles, userName)) && (
filteringUnrestrictedRoles == null || filteringUnrestrictedRoles.isEmpty()
|| hasAppUnrestrictedRole(appUnrestrictedRoles, filteringUnrestrictedRoles,
userName))) {
if (filteringCategories != null && !filteringCategories.isEmpty()) {
List<String> appTagList = applicationDAO.getAppCategories(applicationDTO.getId(), tenantId);
boolean isAppCategory = filteringCategories.stream().anyMatch(appTagList::contains);
List<String> appCategoryList = applicationDAO
.getAppCategories(applicationDTO.getId(), tenantId);
applicationDTO.setAppCategories(appCategoryList);
boolean isAppCategory = filteringCategories.stream().anyMatch(appCategoryList::contains);
if (!isAppCategory) {
isSearchingApp = false;
}
@ -699,9 +710,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationList.getPagination().setSize(filter.getOffset());
applicationList.getPagination().setCount(applicationList.getApplications().size());
return applicationList;
} catch (UnexpectedServerErrorException e){
throw new ApplicationManagementException(e.getMessage(), e);
}catch (UserStoreException e) {
} catch (UserStoreException e) {
throw new ApplicationManagementException(
"User-store exception while checking whether the user " + userName + " of tenant " + tenantId
+ " has the publisher permission", e);
@ -843,9 +852,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
List<String> tags = this.applicationDAO.getAppTags(appId, tenantId);
List<String> categories = this.applicationDAO.getAppCategories(appId, tenantId);
applicationDTO.setTags(tags);
//todo when support to add multiple categories this has to be changed
if (!categories.isEmpty()){
applicationDTO.setAppCategory(categories.get(0));
applicationDTO.setAppCategories(categories);
}
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
return appDtoToAppResponse(applicationDTO);
@ -1595,10 +1603,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
@Override
public void changeLifecycleState(String releaseUuid, String stateName)
public void changeLifecycleState(String releaseUuid, LifecycleChanger lifecycleChanger)
throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (lifecycleChanger == null || StringUtils.isEmpty(lifecycleChanger.getAction())) {
String msg = "The Action is null or empty. Please verify the request.";
log.error(msg);
throw new BadRequestException(msg);
}
try {
ConnectionManagerUtil.beginDBTransaction();
ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO
@ -1609,23 +1624,24 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new NotFoundException(msg);
}
if (lifecycleStateManager
.isValidStateChange(applicationReleaseDTO.getCurrentState(), stateName, userName, tenantId)) {
if (lifecycleStateManager.isInstallableState(stateName) && applicationReleaseDAO
.isValidStateChange(applicationReleaseDTO.getCurrentState(), lifecycleChanger.getAction(), userName,
tenantId)) {
if (lifecycleStateManager.isInstallableState(lifecycleChanger.getAction()) && applicationReleaseDAO
.hasExistInstallableAppRelease(applicationReleaseDTO.getUuid(),
lifecycleStateManager.getInstallableState(), tenantId)) {
String msg = "Installable application release is already registered for the application. "
+ "Therefore it is not permitted to change the lifecycle state from "
+ applicationReleaseDTO.getCurrentState() + " to " + stateName;
+ applicationReleaseDTO.getCurrentState() + " to " + lifecycleChanger.getAction();
log.error(msg);
throw new ForbiddenException(msg);
}
LifecycleState lifecycleState = new LifecycleState();
lifecycleState.setCurrentState(stateName);
lifecycleState.setCurrentState(lifecycleChanger.getAction());
lifecycleState.setPreviousState(applicationReleaseDTO.getCurrentState());
lifecycleState.setUpdatedBy(userName);
applicationReleaseDTO.setCurrentState(stateName);
lifecycleState.setResonForChange(lifecycleChanger.getReason());
applicationReleaseDTO.setCurrentState(lifecycleChanger.getAction());
if (this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId) == null) {
String msg = "Application release updating is failed/.";
log.error(msg);
@ -1635,7 +1651,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction();
} else {
String msg = "Invalid lifecycle state transition from '" + applicationReleaseDTO.getCurrentState() + "'"
+ " to '" + stateName + "'";
+ " to '" + lifecycleChanger.getAction() + "'";
log.error(msg);
throw new ApplicationManagementException(msg);
}
@ -2347,7 +2363,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new RequestValidatingException(msg);
}
if (StringUtils.isEmpty(applicationWrapper.getAppCategory())) {
if (applicationWrapper.getAppCategories().isEmpty()) {
String msg = "Application category can't be empty.";
log.error(msg);
throw new RequestValidatingException(msg);
@ -2459,7 +2475,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationDTO applicationDTO = new ApplicationDTO();
applicationDTO.setName(applicationWrapper.getName());
applicationDTO.setDescription(applicationWrapper.getDescription());
applicationDTO.setAppCategory(applicationWrapper.getAppCategory());
applicationDTO.setAppCategories(applicationWrapper.getAppCategories());
applicationDTO.setType(applicationWrapper.getType());
applicationDTO.setSubType(applicationWrapper.getSubType());
applicationDTO.setPaymentCurrency(applicationWrapper.getPaymentCurrency());
@ -2492,7 +2508,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
application.setId(applicationDTO.getId());
application.setName(applicationDTO.getName());
application.setDescription(applicationDTO.getDescription());
application.setAppCategory(applicationDTO.getAppCategory());
application.setAppCategories(applicationDTO.getAppCategories());
application.setType(applicationDTO.getType());
application.setSubType(applicationDTO.getSubType());
application.setPaymentCurrency(applicationDTO.getPaymentCurrency());

@ -2,12 +2,17 @@ package org.wso2.carbon.device.application.mgt.core.dto;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import java.util.ArrayList;
import java.util.List;
public class ApplicationsDTO {
public static ApplicationDTO getApp1() {
ApplicationDTO app = new ApplicationDTO();
List<String> categories = new ArrayList<>();
app.setAppCategory("Test Category");
categories.add("Test Category");
app.setAppCategories(categories);
app.setDescription("Test app Description");
app.setDeviceTypeId(1);
app.setName("First Test App");

@ -52,7 +52,10 @@ public class ApplicationManagementTest extends BaseTestCase {
ApplicationWrapper applicationWrapper = new ApplicationWrapper();
applicationWrapper.setAppCategory("Test Category");
List<String> categories = new ArrayList<>();
categories.add("Test Category");
applicationWrapper.setAppCategories(categories);
applicationWrapper.setDescription("Test Description");
applicationWrapper.setDeviceType("android");
applicationWrapper.setName("Test Application");

@ -35,6 +35,7 @@ import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.LifecycleChanger;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
import org.wso2.carbon.device.application.mgt.common.response.ApplicationRelease;
@ -729,6 +730,10 @@ public interface ApplicationManagementPublisherAPI {
code = 400,
message = "Bad Request. \n " +
"Lifecycle State changing request contains unacceptable or vulnerable data"),
@ApiResponse(
code = 403,
message = "Don't have permission to move the lifecycle state of a given application release"
+ " to the given lifecycle state."),
@ApiResponse(
code = 404,
message = "NOT FOUND. \n Error occurred while adding new lifecycle state.",
@ -745,10 +750,10 @@ public interface ApplicationManagementPublisherAPI {
required = true)
@PathParam("uuid") String applicationUuid,
@ApiParam(
name = "action",
value = "Changing lifecycle state",
name = "LifecycleChanger",
value = "Lifecycle Changer which contains the action and the reason for the lifecycle change.",
required = true)
@QueryParam("action") String action
LifecycleChanger lifecycleChanger
);
@GET

@ -35,6 +35,7 @@ import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationUpdateWr
import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper;
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementPublisherAPI;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
@ -84,11 +85,15 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
.entity("Couldn't find any application for the requested query.").build();
}
return Response.status(Response.Status.OK).entity(applications).build();
} catch(BadRequestException e){
} catch (BadRequestException e) {
String msg = "Incompatible request payload is found. Please try with valid request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}catch (ApplicationManagementException e) {
} catch (UnexpectedServerErrorException e) {
String msg = "Error Occured when getting supported device types by Entgra IoTS";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).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();
@ -442,16 +447,19 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Path("/life-cycle/{uuid}")
public Response addLifecycleState(
@PathParam("uuid") String applicationUuid,
@QueryParam("action") String action) {
@Valid LifecycleChanger lifecycleChanger) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
if (StringUtils.isEmpty(action)) {
String msg = "The Action is null or empty. Please verify the request.";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).build();
}
applicationManager.changeLifecycleState( applicationUuid, action);
applicationManager.changeLifecycleState(applicationUuid, lifecycleChanger);
} catch (BadRequestException e) {
String msg = "Request payload contains invalid data, hence veryfy the request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).build();
} catch (ForbiddenException e) {
String msg = "You are trying to move the application release into incompatible state for application "
+ "which has application ID: " + applicationUuid;
log.error(msg, e);
return Response.status(Response.Status.FORBIDDEN).build();
} catch (NotFoundException e) {
String msg = "Could,t find application release for application release uuid: " + applicationUuid;
log.error(msg, e);
@ -579,9 +587,8 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
List<String> tagNames) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
applicationManager.addTags(tagNames);
String msg = "New application tags are added successfully.";
return Response.status(Response.Status.OK).entity(msg).build();
List<String> tags = applicationManager.addTags(tagNames);
return Response.status(Response.Status.OK).entity(tags).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg);
@ -602,9 +609,8 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
List<String> tagNames) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
applicationManager.addApplicationTags(appId, tagNames);
String msg = "New tags are added successfully, for application which has application ID: " + appId +".";
return Response.status(Response.Status.OK).entity(msg).build();
List<String> applicationTags = applicationManager.addApplicationTags(appId, tagNames);
return Response.status(Response.Status.OK).entity(applicationTags).build();
} catch (NotFoundException e) {
String msg = e.getMessage();
log.error(msg);

@ -130,9 +130,8 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
List<String> categoryNames) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
applicationManager.addCategories(categoryNames);
String msg = "New application categories are added successfully.";
return Response.status(Response.Status.OK).entity(msg).build();
List<String> categories = applicationManager.addCategories(categoryNames);
return Response.status(Response.Status.OK).entity(categories).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg);

@ -80,7 +80,7 @@ CREATE TABLE IF NOT EXISTS AP_APP_LIFECYCLE_STATE(
UPDATED_AT TIMESTAMP NOT NULL,
AP_APP_RELEASE_ID INTEGER NOT NULL,
AP_APP_ID INTEGER NOT NULL,
REASON VARCHAR(45) NULL,
REASON TEXT DEFAULT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1
FOREIGN KEY (AP_APP_RELEASE_ID)

Loading…
Cancel
Save