Java Code Examples for org.alfresco.util.ParameterCheck#mandatory()

The following examples show how to use org.alfresco.util.ParameterCheck#mandatory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractWorkflowFormProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected ItemType getTypedItem(Item item)
{
    try
    {
        ParameterCheck.mandatory("item", item);
        return getTypedItemForDecodedId(item.getId());
    }
    catch (AccessDeniedException ade)
    {
        throw ade;
    }
    catch (Exception e)
    {
        throw new FormNotFoundException(item, e);
    }
}
 
Example 2
Source File: QuickShareLinkExpiryActionPersisterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public NodeRef getQuickShareLinkExpiryActionNode(QName linkExpiryActionName)
{
    ParameterCheck.mandatory("linkExpiryActionName", linkExpiryActionName);

    NodeRef rootNodeRef = getOrCreateActionsRootNodeRef();
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(rootNodeRef, ContentModel.ASSOC_CONTAINS, linkExpiryActionName);
    if (!childAssocs.isEmpty())
    {
        if (childAssocs.size() > 1)
        {
            throw new QuickShareLinkExpiryActionException(
                        "Multiple quick share link expiry actions with the name: " + linkExpiryActionName + " exist!");
        }
        return childAssocs.get(0).getChildRef();
    }
    return null;
}
 
Example 3
Source File: AdminUserPatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    ParameterCheck.mandatory("authenticationContextManager", authenticationContextManager);

    //Attempt to get RepositoryAuthenticationDao from the subsystem
    for(String contextName : authenticationContextManager.getInstanceIds())
    {
        ApplicationContext ctx = authenticationContextManager.getApplicationContext(contextName);
        try
        {
            authenticationDao = (RepositoryAuthenticationDao)
                    ctx.getBean(RepositoryAuthenticationDao.class);
        } catch(NoSuchBeanDefinitionException e) {}
    }

}
 
Example 4
Source File: ContentDataDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void getContentUrlsOrphaned(
        final ContentUrlHandler contentUrlHandler,
        final Long maxOrphanTimeExclusive,
        final int maxResults)
{
    ParameterCheck.mandatory("maxOrphanTimeExclusive", maxOrphanTimeExclusive);
    
    ContentUrlOrphanQuery query = new ContentUrlOrphanQuery();
    query.setMaxOrphanTimeExclusive(maxOrphanTimeExclusive);
    List<ContentUrlEntity> results = template.selectList(SELECT_CONTENT_URLS_ORPHANED, 
                                                                                  query, 
                                                                                  new RowBounds(0, maxResults));
    // Pass the result to the callback
    for (ContentUrlEntity result : results)
    {
        contentUrlHandler.handle(
                result.getId(),
                result.getContentUrl(),
                result.getOrphanTime());
    }
}
 
Example 5
Source File: TaggingServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Pair<List<String>, Integer> getPagedTags(StoreRef storeRef, int fromTag, int pageSize)
{
    ParameterCheck.mandatory("storeRef", storeRef);
    ParameterCheck.mandatory("fromTag", fromTag);
    ParameterCheck.mandatory("pageSize", pageSize);

    Collection<ChildAssociationRef> rootCategories = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE);

    final int totalCount = rootCategories.size();
    final int startIndex = Math.max(fromTag, 0);
    final int endIndex = Math.min(fromTag + pageSize, totalCount);
    List<String> result = new ArrayList<String>(pageSize);
    int index = 0;
    // paging for not sorted tag names
    for (ChildAssociationRef rootCategory : rootCategories)
    {
        if (startIndex > index++)
        {
            continue;
        }
        String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
        result.add(name);
        if (index == endIndex)
        {
            break;
        }
    }
    return new Pair<List<String>, Integer> (result, totalCount);
}
 
Example 6
Source File: CustomModelServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<CustomModelDefinition> getCustomModels(PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("pagingRequest", pagingRequest);

    List<CustomModelDefinition> result = getAllCustomModels();
    return result.isEmpty() ? new EmptyPagingResults<CustomModelDefinition>() : wrapResult(pagingRequest, result);
}
 
Example 7
Source File: ArchivedNodesCannedQueryBuilder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ArchivedNodesCannedQueryBuilder(Builder builder)
{
    ParameterCheck.mandatory("storeRef", (this.archiveRootNodeRef = builder.archiveRootNodeRef));
    ParameterCheck.mandatory("pagingRequest", builder.pagingRequest);        
  
    // Defensive copy
    PagingRequest pr = new PagingRequest(builder.pagingRequest.getSkipCount(),
                builder.pagingRequest.getMaxItems(),
                builder.pagingRequest.getQueryExecutionId());
    pr.setRequestTotalCountMax(builder.pagingRequest.getRequestTotalCountMax());
    this.pagingRequest = pr;
    this.filter = builder.filter;        
    this.sortOrderAscending = builder.sortOrderAscending;
}
 
Example 8
Source File: AclDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AccessControlListProperties getAccessControlListProperties(Long id)
{
    ParameterCheck.mandatory("id", id);                 // Prevent unboxing failures
    return aclCrudDAO.getAcl(id);
}
 
Example 9
Source File: GetArchivedNodesCannedQueryFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param archiveStoreRootNodeRef NodeRef
 * @param assocTypeQName QName
 * @param filter String
 * @param filterIgnoreCase boolean
 * @param pagingRequest PagingRequest
 * @param sortOrderAscending boolean
 * @return an implementation that will execute the query
 */
public CannedQuery<ArchivedNodeEntity> getCannedQuery(NodeRef archiveStoreRootNodeRef, QName assocTypeQName,
            String filter, boolean filterIgnoreCase, PagingRequest pagingRequest,
            boolean sortOrderAscending)
{
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    Long nodeId = (archiveStoreRootNodeRef == null) ? -1 : getNodeId(archiveStoreRootNodeRef);
    Long qnameId = (assocTypeQName == null) ? -1 : getQNameId(assocTypeQName);

    int requestTotalCountMax = pagingRequest.getRequestTotalCountMax();

    GetArchivedNodesCannedQueryParams paramBean = new GetArchivedNodesCannedQueryParams(nodeId,
                qnameId, filter, filterIgnoreCase, getQNameId(ContentModel.PROP_NAME),
                sortOrderAscending);

    // page details
    CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(),
                pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER,
                CannedQueryPageDetails.DEFAULT_PAGE_COUNT);

    // create query params holder
    CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, null,
                requestTotalCountMax, pagingRequest.getQueryExecutionId());

    // return canned query instance
    return getCannedQuery(params);
}
 
Example 10
Source File: GetChildrenCannedQueryFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Retrieve an optionally filtered/sorted instance of a {@link CannedQuery} based on parameters including request for a total count (up to a given max)
 * 
 * Note: if both filtering and sorting is required then the combined total of unique QName properties should be the 0 to 3.
 *
 * @param parentRef             parent node ref
 * @param pattern			    the pattern to use to filter children (wildcard character is '*')
 * @param assocTypeQNames	    qnames of assocs to include (may be null)
 * @param childTypeQNames       type qnames of children nodes (pre-filter)
 * @param inclusiveAspects      If not null, only child nodes with any aspect in this collection will be included in the results.
 * @param exclusiveAspects      If not null, any child nodes with any aspect in this collection will be excluded in the results.
 * @param filterProps           filter properties
 * @param sortProps             sort property pairs (QName and Boolean - true if ascending)
 * @param pagingRequest         skipCount, maxItems - optionally queryExecutionId and requestTotalCountMax
 * 
 * @return                      an implementation that will execute the query
 */
public CannedQuery<NodeRef> getCannedQuery(NodeRef parentRef, String pattern, Set<QName> assocTypeQNames, Set<QName> childTypeQNames, Set<QName> inclusiveAspects, Set<QName> exclusiveAspects, List<FilterProp> filterProps, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("parentRef", parentRef);
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    int requestTotalCountMax = pagingRequest.getRequestTotalCountMax();
    
    // specific query params - context (parent) and inclusive filters (child types, property values)
    GetChildrenCannedQueryParams paramBean = new GetChildrenCannedQueryParams(tenantService.getName(parentRef), assocTypeQNames, childTypeQNames, inclusiveAspects, exclusiveAspects, filterProps, pattern);

    // page details
    CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT);
    
    // sort details
    CannedQuerySortDetails cqsd = null;
    if (sortProps != null)
    {
        List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(sortProps.size());
        for (Pair<QName, Boolean> sortProp : sortProps)
        {
            sortPairs.add(new Pair<QName, SortOrder>(sortProp.getFirst(), (sortProp.getSecond() ? SortOrder.ASCENDING : SortOrder.DESCENDING)));
        }
        
        cqsd = new CannedQuerySortDetails(sortPairs);
    }
    
    // create query params holder
    CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId());
    
    // return canned query instance
    return getCannedQuery(params);
}
 
Example 11
Source File: QueriesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet()
{
    ParameterCheck.mandatory("sr", this.sr);
    ParameterCheck.mandatory("nodes", this.nodes);
    ParameterCheck.mandatory("people", this.people);
    ParameterCheck.mandatory("sites", this.sites);
    
    this.nodeService = sr.getNodeService();
    this.namespaceService = sr.getNamespaceService();
    this.dictionaryService = sr.getDictionaryService();
    this.siteService = sr.getSiteService();
}
 
Example 12
Source File: DeduplicatingContentWriter.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
protected DeduplicatingContentWriter(final String contentUrl, final ContentContext context, final ContentStore temporaryContentStore,
        final ContentStore backingContentStore, final String digestAlgorithm, final String digestAlgorithmProvider,
        final int pathSegments, final int bytesPerPathSegment)
{
    super(contentUrl, context.getExistingContentReader());

    ParameterCheck.mandatory("context", context);
    ParameterCheck.mandatory("temporaryContentStore", temporaryContentStore);
    ParameterCheck.mandatory("backingContentStore", backingContentStore);

    if (pathSegments < 0 || bytesPerPathSegment <= 0)
    {
        throw new IllegalArgumentException(
                "Only non-negative number of path segments and positive number of bytes per path segment are allowed");
    }

    this.context = context;
    this.temporaryContentStore = temporaryContentStore;
    this.backingContentStore = backingContentStore;

    this.digestAlgorithm = digestAlgorithm;
    this.digestAlgorithmProvider = digestAlgorithmProvider;

    this.pathSegments = pathSegments;
    this.bytesPerPathSegment = bytesPerPathSegment;

    this.originalContentUrl = contentUrl;

    // we are the first real listener (DoGuessingOnCloseListener always is first)
    super.addListener(this);

    final ContentContext temporaryContext = new ContentContext(context.getExistingContentReader(), null);
    this.temporaryWriter = this.temporaryContentStore.getWriter(temporaryContext);
}
 
Example 13
Source File: SearchMapper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Sets the Interval Parameters object on search parameters
 *
 * It does some valiation then takes any "SETS" at the top level and sets them at every field level.
 *
 * @param sp SearchParameters
 * @param facetIntervals IntervalParameters
 */
public void fromFacetIntervals(SearchParameters sp, IntervalParameters facetIntervals)
{
    if (facetIntervals != null)
    {
        ParameterCheck.mandatory("facetIntervals intervals", facetIntervals.getIntervals());

        Set<IntervalSet> globalSets = facetIntervals.getSets();
        validateSets(globalSets, "facetIntervals");

        if (facetIntervals.getIntervals() != null && !facetIntervals.getIntervals().isEmpty())
        {
            List<String> intervalLabels = new ArrayList<>(facetIntervals.getIntervals().size());
            for (Interval interval:facetIntervals.getIntervals())
            {
                ParameterCheck.mandatory("facetIntervals intervals field", interval.getField());
                validateSets(interval.getSets(), "facetIntervals intervals "+interval.getField());
                if (interval.getSets() != null && globalSets != null)
                {
                    interval.getSets().addAll(globalSets);
                }
                ParameterCheck.mandatoryCollection("facetIntervals intervals sets", interval.getSets());

                List<Map.Entry<String, Long>> duplicateSetLabels =
                            interval.getSets().stream().collect(groupingBy(IntervalSet::getLabel, Collectors.counting()))
                            .entrySet().stream().filter(e -> e.getValue().intValue() > 1).collect(toList());
                if (!duplicateSetLabels.isEmpty())
                {
                    throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
                                new Object[] { ": duplicate set interval label "+duplicateSetLabels.toString() });

                }
                if (interval.getLabel() != null) intervalLabels.add(interval.getLabel());
            }

            List<Map.Entry<String, Long>> duplicateIntervalLabels =
                        intervalLabels.stream().collect(groupingBy(Function.identity(), Collectors.counting()))
                        .entrySet().stream().filter(e -> e.getValue().intValue() > 1).collect(toList());
            if (!duplicateIntervalLabels.isEmpty())
            {
                throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
                            new Object[] { ": duplicate interval label "+duplicateIntervalLabels.toString() });
            }
        }

        if (facetIntervals.getSets() != null)
        {
            facetIntervals.getSets().clear();
        }
    }
    sp.setInterval(facetIntervals);
}
 
Example 14
Source File: SiteMembersRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void afterPropertiesSet()
{
    ParameterCheck.mandatory("sites", this.sites);
}
 
Example 15
Source File: PersonActivitiesRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void afterPropertiesSet()
{
    ParameterCheck.mandatory("activities", this.activities);
}
 
Example 16
Source File: NodeCommentsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void afterPropertiesSet()
{
    ParameterCheck.mandatory("comments", this.comments);
}
 
Example 17
Source File: NodeAuditEntriesRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception
{
    ParameterCheck.mandatory("audit", this.audit);

}
 
Example 18
Source File: PersonFavouritesRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void afterPropertiesSet()
{
    ParameterCheck.mandatory("favourites", this.favourites);
}
 
Example 19
Source File: TrashcanRenditionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception
{
    ParameterCheck.mandatory("deletedNodes", this.deletedNodes);
}
 
Example 20
Source File: AJProxyTrait.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private AJProxyTrait(Object extensibleInterface)
{
    ParameterCheck.mandatory("extensible",
                             extensibleInterface);
    this.extensibleInterface = extensibleInterface;
}