use of org.alfresco.rest.framework.core.exceptions.InvalidArgumentException in project alfresco-remote-api by Alfresco.
the class GroupsImpl method getGroupsSortProp.
private Pair<String, Boolean> getGroupsSortProp(Parameters parameters) {
Pair<String, Boolean> sortProp;
List<SortColumn> sortCols = parameters.getSorting();
if ((sortCols != null) && (sortCols.size() > 0)) {
if (sortCols.size() > 1) {
throw new InvalidArgumentException("Multiple sort fields not allowed.");
}
SortColumn sortCol = sortCols.get(0);
String sortPropName = SORT_PARAMS_TO_NAMES.get(sortCol.column);
if (sortPropName == null) {
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
}
sortProp = new Pair<>(sortPropName, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE));
} else {
sortProp = getGroupsSortPropDefault();
}
return sortProp;
}
use of org.alfresco.rest.framework.core.exceptions.InvalidArgumentException in project alfresco-remote-api by Alfresco.
the class NodesImpl method requestRenditions.
private void requestRenditions(List<ThumbnailDefinition> thumbnailDefs, Node fileNode) {
if (thumbnailDefs != null) {
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
for (ThumbnailDefinition thumbnailDef : thumbnailDefs) {
NodeRef sourceNodeRef = fileNode.getNodeRef();
String mimeType = fileNode.getContent().getMimeType();
long size = fileNode.getContent().getSizeInBytes();
// Check if anything is currently available to generate thumbnails for the specified mimeType
if (!registry.isThumbnailDefinitionAvailable(null, mimeType, size, sourceNodeRef, thumbnailDef)) {
throw new InvalidArgumentException("Unable to create thumbnail '" + thumbnailDef.getName() + "' for " + mimeType + " as no transformer is currently available.");
}
Action action = ThumbnailHelper.createCreateThumbnailAction(thumbnailDef, sr);
// Queue async creation of thumbnail
actionService.executeAction(action, sourceNodeRef, true, true);
}
}
}
use of org.alfresco.rest.framework.core.exceptions.InvalidArgumentException in project alfresco-remote-api by Alfresco.
the class RenditionsImpl method getRenditionByName.
protected NodeRef getRenditionByName(NodeRef nodeRef, String renditionId, Parameters parameters) {
if (nodeRef == null) {
return null;
}
if (StringUtils.isEmpty(renditionId)) {
throw new InvalidArgumentException("renditionId can't be null or empty.");
}
// Thumbnails have a cm: prefix.
QName renditionQName = QName.resolveToQName(namespaceService, renditionId);
ChildAssociationRef nodeRefRendition = renditionService.getRenditionByName(nodeRef, renditionQName);
if (nodeRefRendition == null) {
return null;
}
return tenantService.getName(nodeRef, nodeRefRendition.getChildRef());
}
use of org.alfresco.rest.framework.core.exceptions.InvalidArgumentException in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method deleteRMSiteWithPermanentParam.
@Test
public void deleteRMSiteWithPermanentParam() throws Exception {
String siteId = RM_SITE_ID;
Params parameters = mock(Params.class);
when(parameters.getParameter(PERMANENT_PARAMETER)).thenReturn(Boolean.toString(true));
try {
rmSiteEntityResource.delete(siteId, parameters);
fail("Expected ecxeption as parameter permanent was present in the request.");
} catch (InvalidArgumentException ex) {
assertEquals("DELETE does not support parameter: permanent", ex.getMsgId());
}
verify(mockedRMSites, never()).deleteSite(siteId, parameters);
}
use of org.alfresco.rest.framework.core.exceptions.InvalidArgumentException in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method updateRMSiteGuid.
@Test
public void updateRMSiteGuid() throws Exception {
String siteId = RM_SITE_ID;
Params parameters = mock(Params.class);
RMSite site = new RMSite();
site.setTitle("New Title");
site.setDescription("New Description");
site.setGuid("newGUID");
try {
rmSiteEntityResource.update(siteId, site, parameters);
fail("Expected ecxeption as rm site guid cannot be changed.");
} catch (InvalidArgumentException ex) {
assertEquals("Site update does not support field: guid", ex.getMsgId());
}
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
Aggregations