use of org.alfresco.repo.quickshare.QuickShareLinkExpiryActionException in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method create.
/**
* Create quick share.
* <p>
* Requires authenticated access.
*
* @param nodeIds
* @param parameters
* @return
*/
public List<QuickShareLink> create(List<QuickShareLink> nodeIds, Parameters parameters) {
checkEnabled();
List<QuickShareLink> result = new ArrayList<>(nodeIds.size());
List<String> includeParam = parameters != null ? parameters.getInclude() : Collections.<String>emptyList();
for (QuickShareLink qs : nodeIds) {
String nodeId = qs.getNodeId();
if (nodeId == null) {
throw new InvalidArgumentException("A valid nodeId must be specified !");
}
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
try {
// Note: will throw InvalidNodeRefException (=> 404) if node does not exist
String sharedId = (String) nodeService.getProperty(nodeRef, QuickShareModel.PROP_QSHARE_SHAREDID);
if (sharedId != null) {
throw new ConstraintViolatedException("sharedId already exists: " + nodeId + " [" + sharedId + "]");
}
// Note: since we already check node exists above, we can assume that InvalidNodeRefException (=> 404) here means not content (see type check)
try {
QuickShareDTO qsDto = quickShareService.shareContent(nodeRef, qs.getExpiresAt());
result.add(getQuickShareInfo(qsDto.getId(), false, includeParam));
} catch (InvalidNodeRefException inre) {
throw new InvalidArgumentException("Unable to create shared link to non-file content: " + nodeId);
} catch (QuickShareLinkExpiryActionException ex) {
throw new InvalidArgumentException(ex.getMessage());
}
} catch (AccessDeniedException ade) {
throw new PermissionDeniedException("Unable to create shared link to node that does not exist: " + nodeId);
} catch (InvalidNodeRefException inre) {
logger.warn("Unable to create shared link: [" + nodeRef + "]");
throw new EntityNotFoundException(nodeId);
}
}
return result;
}
Aggregations