use of org.alfresco.service.cmr.quickshare.InvalidSharedIdException in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method readProperty.
/**
* Download content via shared link.
* <p>
* Note: does *not* require authenticated access for (public) shared link.
*
* @param sharedId
* @param renditionId - optional
* @param parameters {@link Parameters}
* @return
* @throws EntityNotFoundException
*/
public BinaryResource readProperty(String sharedId, final String renditionId, final Parameters parameters) throws EntityNotFoundException {
checkEnabled();
checkValidShareId(sharedId);
try {
Pair<String, NodeRef> pair = quickShareService.getTenantNodeRefFromSharedId(sharedId);
String networkTenantDomain = pair.getFirst();
final NodeRef nodeRef = pair.getSecond();
return TenantUtil.runAsSystemTenant(() -> {
// belt-and-braces (similar to QuickShareContentGet)
if (!nodeService.hasAspect(nodeRef, QuickShareModel.ASPECT_QSHARE)) {
throw new InvalidNodeRefException(nodeRef);
}
if (renditionId != null) {
return renditions.getContent(nodeRef, renditionId, parameters);
} else {
return nodes.getContent(nodeRef, parameters, false);
}
}, networkTenantDomain);
} catch (InvalidSharedIdException ex) {
logger.warn("Unable to find: " + sharedId);
throw new EntityNotFoundException(sharedId);
} catch (InvalidNodeRefException inre) {
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new EntityNotFoundException(sharedId);
}
}
use of org.alfresco.service.cmr.quickshare.InvalidSharedIdException in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method emailSharedLink.
@Override
public void emailSharedLink(String sharedId, QuickShareLinkEmailRequest emailRequest, Parameters parameters) {
checkEnabled();
checkValidShareId(sharedId);
validateEmailRequest(emailRequest);
try {
NodeRef nodeRef = quickShareService.getTenantNodeRefFromSharedId(sharedId).getSecond();
String sharedNodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
QuickShareEmailRequest request = new QuickShareEmailRequest();
request.setSharedNodeName(sharedNodeName);
request.setClient(emailRequest.getClient());
request.setSharedId(sharedId);
request.setSenderMessage(emailRequest.getMessage());
request.setLocale(I18NUtil.parseLocale(emailRequest.getLocale()));
request.setToEmails(emailRequest.getRecipientEmails());
quickShareService.sendEmailNotification(request);
} catch (InvalidSharedIdException ex) {
throw new EntityNotFoundException(sharedId);
} catch (InvalidNodeRefException inre) {
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new EntityNotFoundException(sharedId);
}
}
use of org.alfresco.service.cmr.quickshare.InvalidSharedIdException in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method getRenditions.
@Override
public CollectionWithPagingInfo<Rendition> getRenditions(String sharedId) {
checkEnabled();
checkValidShareId(sharedId);
try {
Pair<String, NodeRef> pair = quickShareService.getTenantNodeRefFromSharedId(sharedId);
String networkTenantDomain = pair.getFirst();
final NodeRef nodeRef = pair.getSecond();
return TenantUtil.runAsSystemTenant(() -> {
Parameters params = getParamsWithCreatedStatus();
return renditions.getRenditions(nodeRef, params);
}, networkTenantDomain);
} catch (InvalidSharedIdException ex) {
logger.warn("Unable to find: " + sharedId);
throw new EntityNotFoundException(sharedId);
} catch (InvalidNodeRefException inre) {
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new EntityNotFoundException(sharedId);
}
}
use of org.alfresco.service.cmr.quickshare.InvalidSharedIdException in project alfresco-remote-api by Alfresco.
the class QuickShareMetaDataGet method executeImpl.
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache) {
if (!isEnabled()) {
throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
}
// create map of params (template vars)
Map<String, String> params = req.getServiceMatch().getTemplateVars();
final String sharedId = params.get("shared_id");
if (sharedId == null) {
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
}
try {
return quickShareService.getMetaData(sharedId);
} catch (InvalidSharedIdException ex) {
logger.error("Unable to find: " + sharedId);
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
} catch (InvalidNodeRefException inre) {
logger.error("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
}
}
use of org.alfresco.service.cmr.quickshare.InvalidSharedIdException in project alfresco-remote-api by Alfresco.
the class ReadGet method executeImpl.
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache) {
if (!isEnabled()) {
throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
}
// create map of params (template vars)
Map<String, String> params = req.getServiceMatch().getTemplateVars();
final String sharedId = params.get("shared_id");
if (sharedId == null) {
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
}
try {
boolean canRead = quickShareService.canRead(sharedId);
Map<String, Object> result = new HashMap<String, Object>();
result.put("canRead", canRead);
return result;
} catch (InvalidSharedIdException ex) {
logger.error("Unable to find: " + sharedId);
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
} catch (InvalidNodeRefException inre) {
logger.error("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
}
}
Aggregations