use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class IssueManager method createIssue.
/**
* Creates a new issue that refers to existing {@link com.epam.pipeline.entity.AbstractSecuredEntity}.
* If {@link com.epam.pipeline.entity.AbstractSecuredEntity} doesn't exist an error will be occurred.
* @param issueVO {@link IssueVO} to create
* @return create {@link Issue}
*/
@Transactional(propagation = Propagation.REQUIRED)
public Issue createIssue(IssueVO issueVO) {
validateIssueParameters(issueVO);
EntityVO entityVO = issueVO.getEntity();
validateEntityParameters(entityVO);
AbstractSecuredEntity entity = ensureEntityExists(entityVO);
Issue issue = issueMapper.toIssue(issueVO);
issue.setAuthor(authManager.getAuthorizedUser());
issueDao.createIssue(issue);
issueVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentIssueId(a.getId(), issue.getId()));
notificationManager.notifyIssue(issue, entity, StringUtils.defaultIfBlank(issueVO.getHtmlText(), issue.getText()));
return issue;
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method deleteAllPermissions.
@Transactional(propagation = Propagation.REQUIRED)
public AclSecuredEntry deleteAllPermissions(Long id, AclClass aclClass) {
AbstractSecuredEntity entity = entityManager.load(aclClass, id);
Assert.isTrue(!entity.isLocked(), messageHelper.getMessage(MessageConstants.ERROR_ENTITY_IS_LOCKED, entity.getAclClass(), entity.getId()));
MutableAcl acl = aclService.getOrCreateObjectIdentity(entity);
acl = deleteAllAces(acl);
return convertAclToEntry(entity, acl);
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method getEntitiesPermissions.
private Map<AbstractSecuredEntity, List<AclPermissionEntry>> getEntitiesPermissions(Collection<? extends AbstractSecuredEntity> entities) {
Set<AbstractSecuredEntity> result = new HashSet<>(entities);
entities.forEach(entity -> {
AbstractSecuredEntity parent = entity.getParent();
while (parent != null) {
result.add(parent);
parent = parent.getParent();
}
});
return getPermissions(result);
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method metadataEntityPermission.
public boolean metadataEntityPermission(Long entityId, String permissionName) {
MetadataEntity entity = metadataEntityManager.load(entityId);
if (entity.getParent() == null || entity.getParent().getId() == null) {
return isAdmin(getSids());
}
AbstractSecuredEntity securedEntity = entityManager.load(AclClass.FOLDER, entity.getParent().getId());
return permissionsHelper.isAllowed(permissionName, securedEntity);
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method loadEntityPermission.
public EntityPermissionVO loadEntityPermission(final AclClass entityClass, final Long id) {
AbstractSecuredEntity entity = entityManager.loadEntityWithParents(entityClass, id);
Assert.notNull(entity, messageHelper.getMessage(MessageConstants.ERROR_ENTITY_NOT_FOUND, id, entityClass));
AbstractSecuredEntity aclEntity = getAclEntity(entity);
Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions = getEntitiesPermissions(Collections.singleton(aclEntity));
EntityPermission entityPermission = getEntityPermission(allPermissions, entity);
return entityPermissionMapper.toEntityPermissionVO(entityPermission);
}
Aggregations