|
|
@ -85,7 +85,6 @@ import org.wso2.carbon.user.api.UserRealm;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
|
|
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
@ -663,28 +662,26 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
List<String> filteringUnrestrictedRoles = filter.getUnrestrictedRoles();
|
|
|
|
List<String> filteringUnrestrictedRoles = filter.getUnrestrictedRoles();
|
|
|
|
|
|
|
|
|
|
|
|
if (!lifecycleStateManager.getEndState().equals(applicationDTO.getStatus())) {
|
|
|
|
if (!lifecycleStateManager.getEndState().equals(applicationDTO.getStatus())) {
|
|
|
|
|
|
|
|
//get application categories, tags and unrestricted roles.
|
|
|
|
List<String> appUnrestrictedRoles = visibilityDAO
|
|
|
|
List<String> appUnrestrictedRoles = visibilityDAO
|
|
|
|
.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
|
|
|
|
.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
List<String> appCategoryList = applicationDAO.getAppCategories(applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
List<String> appTagList = applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Set application categories, tags and unrestricted roles to the application DTO.
|
|
|
|
applicationDTO.setUnrestrictedRoles(appUnrestrictedRoles);
|
|
|
|
applicationDTO.setUnrestrictedRoles(appUnrestrictedRoles);
|
|
|
|
|
|
|
|
applicationDTO.setAppCategories(appCategoryList);
|
|
|
|
|
|
|
|
applicationDTO.setTags(appTagList);
|
|
|
|
|
|
|
|
|
|
|
|
if ((appUnrestrictedRoles.isEmpty() || hasUserRole(appUnrestrictedRoles, userName)) && (
|
|
|
|
if ((appUnrestrictedRoles.isEmpty() || hasUserRole(appUnrestrictedRoles, userName)) && (
|
|
|
|
filteringUnrestrictedRoles == null || filteringUnrestrictedRoles.isEmpty()
|
|
|
|
filteringUnrestrictedRoles == null || filteringUnrestrictedRoles.isEmpty()
|
|
|
|
|| hasAppUnrestrictedRole(appUnrestrictedRoles, filteringUnrestrictedRoles,
|
|
|
|
|| hasAppUnrestrictedRole(appUnrestrictedRoles, filteringUnrestrictedRoles,
|
|
|
|
userName))) {
|
|
|
|
userName))) {
|
|
|
|
if (filteringCategories != null && !filteringCategories.isEmpty()) {
|
|
|
|
if (filteringCategories != null && !filteringCategories.isEmpty()) {
|
|
|
|
List<String> appCategoryList = applicationDAO
|
|
|
|
isSearchingApp = filteringCategories.stream().anyMatch(appCategoryList::contains);
|
|
|
|
.getAppCategories(applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
applicationDTO.setAppCategories(appCategoryList);
|
|
|
|
|
|
|
|
boolean isAppCategory = filteringCategories.stream().anyMatch(appCategoryList::contains);
|
|
|
|
|
|
|
|
if (!isAppCategory) {
|
|
|
|
|
|
|
|
isSearchingApp = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filteringTags != null && !filteringTags.isEmpty()) {
|
|
|
|
if (filteringTags != null && !filteringTags.isEmpty() && isSearchingApp) {
|
|
|
|
List<String> appTagList = applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
|
|
|
|
isSearchingApp = filteringTags.stream().anyMatch(appTagList::contains);
|
|
|
|
boolean isAppTag = filteringTags.stream().anyMatch(appTagList::contains);
|
|
|
|
|
|
|
|
if (!isAppTag) {
|
|
|
|
|
|
|
|
isSearchingApp = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isSearchingApp) {
|
|
|
|
if (isSearchingApp) {
|
|
|
|
filteredApplications.add(applicationDTO);
|
|
|
|
filteredApplications.add(applicationDTO);
|
|
|
@ -701,16 +698,20 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs);
|
|
|
|
applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(ApplicationDTO appDTO : filteredApplications){
|
|
|
|
for (ApplicationDTO appDTO : filteredApplications) {
|
|
|
|
applications.add(appDtoToAppResponse(appDTO));
|
|
|
|
applications.add(appDtoToAppResponse(appDTO));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationList.setApplications(applications);
|
|
|
|
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
|
|
|
|
pagination.setCount(applications.size());
|
|
|
|
|
|
|
|
pagination.setSize(applications.size());
|
|
|
|
|
|
|
|
pagination.setOffset(filter.getOffset());
|
|
|
|
|
|
|
|
pagination.setLimit(filter.getLimit());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applicationList.setApplications(applications);
|
|
|
|
applicationList.setPagination(pagination);
|
|
|
|
applicationList.setPagination(pagination);
|
|
|
|
applicationList.getPagination().setSize(filter.getOffset());
|
|
|
|
|
|
|
|
applicationList.getPagination().setCount(applicationList.getApplications().size());
|
|
|
|
|
|
|
|
return applicationList;
|
|
|
|
return applicationList;
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
"User-store exception while checking whether the user " + userName + " of tenant " + tenantId
|
|
|
|
"User-store exception while checking whether the user " + userName + " of tenant " + tenantId
|
|
|
|
+ " has the publisher permission", e);
|
|
|
|
+ " has the publisher permission", e);
|
|
|
@ -2006,6 +2007,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateTag(String oldTagName, String newTagName) throws ApplicationManagementException {
|
|
|
|
public void updateTag(String oldTagName, String newTagName) throws ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(oldTagName) || StringUtils.isEmpty(newTagName)) {
|
|
|
|
|
|
|
|
String msg = "Either old tag name or new tag name contains empty/null value. Hence please verify the "
|
|
|
|
|
|
|
|
+ "request.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
TagDTO tag = applicationDAO.getTagForTagName(oldTagName, tenantId);
|
|
|
|
TagDTO tag = applicationDAO.getTagForTagName(oldTagName, tenantId);
|
|
|
@ -2080,10 +2087,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<String> applicationTags = this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
|
|
|
|
List<String> applicationTags = this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
|
|
|
|
List<String> newApplicationTags = getDifference(applicationTags, tags);
|
|
|
|
List<String> newApplicationTags = getDifference(tags, applicationTags);
|
|
|
|
if (!newApplicationTags.isEmpty()) {
|
|
|
|
if (!newApplicationTags.isEmpty()) {
|
|
|
|
List<Integer> newTagIds = this.applicationDAO.getTagIdsForTagNames(newApplicationTags, tenantId);
|
|
|
|
List<Integer> newTagIds = this.applicationDAO.getTagIdsForTagNames(newApplicationTags, tenantId);
|
|
|
|
this.applicationDAO.addTagMapping(newTagIds, applicationDTO.getId(), tenantId);
|
|
|
|
this.applicationDAO.addTagMapping(newTagIds, applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Stream.concat(applicationTags.stream(), newApplicationTags.stream())
|
|
|
|
return Stream.concat(applicationTags.stream(), newApplicationTags.stream())
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
@ -2095,6 +2103,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
String msg = "Error occurred while accessing application tags. Application ID: " + appId;
|
|
|
|
String msg = "Error occurred while accessing application tags. Application ID: " + appId;
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|