use of org.alfresco.rest.framework.core.exceptions.DisabledServiceException in project alfresco-remote-api by Alfresco.
the class NodesImpl method getThumbnailDefs.
private List<ThumbnailDefinition> getThumbnailDefs(Set<String> renditionNames) {
List<ThumbnailDefinition> thumbnailDefs = null;
if (renditionNames != null) {
// If thumbnail generation has been configured off, then don't bother.
if (!thumbnailService.getThumbnailsEnabled()) {
throw new DisabledServiceException("Thumbnail generation has been disabled.");
}
thumbnailDefs = new ArrayList<>(renditionNames.size());
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
for (String renditionName : renditionNames) {
// Use the thumbnail registry to get the details of the thumbnail
ThumbnailDefinition thumbnailDef = registry.getThumbnailDefinition(renditionName);
if (thumbnailDef == null) {
throw new NotFoundException(renditionName + " is not registered.");
}
thumbnailDefs.add(thumbnailDef);
}
}
return thumbnailDefs;
}
use of org.alfresco.rest.framework.core.exceptions.DisabledServiceException in project alfresco-remote-api by Alfresco.
the class PeopleImpl method uploadAvatarContent.
@Override
public Person uploadAvatarContent(String personId, BasicContentInfo contentInfo, InputStream stream, Parameters parameters) {
if (!thumbnailService.getThumbnailsEnabled()) {
throw new DisabledServiceException("Thumbnail generation has been disabled.");
}
personId = validatePerson(personId);
checkCurrentUserOrAdmin(personId);
NodeRef personNode = personService.getPerson(personId);
NodeRef avatarOrigNodeRef = getAvatarOriginal(personNode);
if (avatarOrigNodeRef != null) {
deleteAvatar(avatarOrigNodeRef);
}
QName origAvatarQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "origAvatar");
nodeService.addAspect(personNode, ContentModel.ASPECT_PREFERENCES, null);
ChildAssociationRef assoc = nodeService.createNode(personNode, ContentModel.ASSOC_PREFERENCE_IMAGE, origAvatarQName, ContentModel.TYPE_CONTENT);
NodeRef avatar = assoc.getChildRef();
String avatarOriginalNodeId = avatar.getId();
// TODO do we still need this ? - backward compatible with JSF web-client avatar
nodeService.createAssociation(personNode, avatar, ContentModel.ASSOC_AVATAR);
Node n = nodes.updateContent(avatarOriginalNodeId, contentInfo, stream, parameters);
String mimeType = n.getContent().getMimeType();
if (mimeType.indexOf("image/") != 0) {
throw new InvalidArgumentException("Uploaded content must be an image (content type determined to be '" + mimeType + "')");
}
// create thumbnail synchronously
Rendition avatarR = new Rendition();
avatarR.setId("avatar");
renditions.createRendition(avatar, avatarR, false, parameters);
List<String> include = Arrays.asList(PARAM_INCLUDE_ASPECTNAMES, PARAM_INCLUDE_PROPERTIES);
return getPersonWithProperties(personId, include);
}
use of org.alfresco.rest.framework.core.exceptions.DisabledServiceException in project alfresco-remote-api by Alfresco.
the class RenditionsImpl method createRendition.
@Override
public void createRendition(NodeRef nodeRef, Rendition rendition, boolean executeAsync, Parameters parameters) {
// If thumbnail generation has been configured off, then don't bother.
if (!thumbnailService.getThumbnailsEnabled()) {
throw new DisabledServiceException("Thumbnail generation has been disabled.");
}
final NodeRef sourceNodeRef = validateNode(nodeRef.getStoreRef(), nodeRef.getId());
final NodeRef renditionNodeRef = getRenditionByName(sourceNodeRef, rendition.getId(), parameters);
if (renditionNodeRef != null) {
throw new ConstraintViolatedException(rendition.getId() + " rendition already exists.");
}
// Use the thumbnail registry to get the details of the thumbnail
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
ThumbnailDefinition thumbnailDefinition = registry.getThumbnailDefinition(rendition.getId());
if (thumbnailDefinition == null) {
throw new NotFoundException(rendition.getId() + " is not registered.");
}
ContentData contentData = getContentData(sourceNodeRef, true);
// Check if anything is currently available to generate thumbnails for the specified mimeType
if (!registry.isThumbnailDefinitionAvailable(contentData.getContentUrl(), contentData.getMimetype(), contentData.getSize(), sourceNodeRef, thumbnailDefinition)) {
throw new InvalidArgumentException("Unable to create thumbnail '" + thumbnailDefinition.getName() + "' for " + contentData.getMimetype() + " as no transformer is currently available.");
}
Action action = ThumbnailHelper.createCreateThumbnailAction(thumbnailDefinition, serviceRegistry);
// Create thumbnail - or else queue for async creation
actionService.executeAction(action, sourceNodeRef, true, executeAsync);
}
Aggregations