Java Code Examples for org.alfresco.util.Pair#getSecond()

The following examples show how to use org.alfresco.util.Pair#getSecond() . 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: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<Activity> getActivities(String personId, String siteId, boolean excludeUser, boolean excludeOthers)
{
	List<ActivityFeedEntity> feedEntities = activityService.getUserFeedEntries(personId, siteId, excludeUser, excludeOthers, 0);
	List<Activity> activities = new ArrayList<Activity>(feedEntities.size());
	for(ActivityFeedEntity entity : feedEntities)
	{
		String siteNetwork = entity.getSiteNetwork();
		Pair<String, String> pair = splitSiteNetwork(siteNetwork);
		siteId = pair.getFirst();
		String networkId = pair.getSecond();
		String postDateStr = PublicApiDateFormat.getDateFormat().format(entity.getPostDate());
		Activity activity = new Activity(entity.getId(), networkId, siteId, entity.getFeedUserId(), entity.getPostUserId(), postDateStr, entity.getActivityType(), parseActivitySummary(entity));
		activities.add(activity);
	}

	return activities;
}
 
Example 2
Source File: ProtocolHashStringifier.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String stringifyResource(ClasspathResource resource) throws ReferenceEncodingException
{
    String cp = resource.getClasspath();
    Pair<String, String> hash = classpathHasher.hash(cp);
    final String hashed = hash.getFirst();
    final String nonHashed = hash.getSecond();
    if (nonHashed == null)
    {
        return HASHED_CLASSPATH_RESOUCE_CODE + "-" + hashed;
    }
    else if (hashed == null)
    {
        return CLASSPATH_RESOUCE_CODE + "-" + nonHashed;
    }
    else
    {
        return MIXED_CLASSPATH_RESOUCE_CODE + "-" + hashed + "-" + nonHashed;
    }

}
 
Example 3
Source File: SortConstraint.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters,
            VirtualQuery query)
{
    SearchParameters searchParametersCopy = searchParameters.copy();
    for (Pair<QName, Boolean> sort : sortProps)
    {
        if (!IGNORED_SORT_PROPERTIES.contains(sort.getFirst()))
        {
            SortDefinition sortDefinition = new SortDefinition(SortType.FIELD,
                                                               sort.getFirst().getPrefixString(),
                                                               sort.getSecond());
            searchParametersCopy.addSort(sortDefinition);
        }
    }
    return searchParametersCopy;
}
 
Example 4
Source File: QuickShareServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean canRead(String sharedId)
{
    Pair<String, NodeRef> pair = getTenantNodeRefFromSharedId(sharedId);
    final String tenantDomain = pair.getFirst();
    final NodeRef nodeRef = pair.getSecond();
    
    return TenantUtil.runAsTenant(new TenantRunAsWork<Boolean>()
    {
        public Boolean doWork() throws Exception
        {
            try
            {
                checkQuickShareNode(nodeRef);
                return permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.ALLOWED;
            }
            catch (AccessDeniedException ex)
            {
                return false;
            }
        }
    }, tenantDomain);
    
}
 
Example 5
Source File: AlfrescoLuceneQParserPlugin.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Query parse() throws SyntaxError
{
    Pair<SearchParameters, Boolean> searchParametersAndFilter = getSearchParameters();
    SearchParameters searchParameters = searchParametersAndFilter.getFirst();
    Boolean isFilter = searchParametersAndFilter.getSecond();
    
    Solr4QueryParser qp = AlfrescoSolrDataModel.getInstance().getLuceneQueryParser(searchParameters, req, FTSQueryParser.RerankPhase.SINGLE_PASS_WITH_AUTO_PHRASE);
    Query query;
    try
    {
        // escape / not in a string and not already escaped
        String escapedQ = escape(searchParameters.getQuery());
        query = qp.parse(escapedQ);
    }
    catch (ParseException pe)
    {
        throw new SyntaxError(pe);
    }
    ContextAwareQuery contextAwareQuery = new ContextAwareQuery(query, Boolean.TRUE.equals(isFilter) ? null : searchParameters);
    if(log.isDebugEnabled())
    {
        log.debug("Lucene QP query as lucene:\t    "+contextAwareQuery);
    }
    return contextAwareQuery;
}
 
Example 6
Source File: ACLEntryAfterInvocationProvider.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
private Pair decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Pair returnedObject) throws AccessDeniedException
{
    NodeRef nodeRef = (NodeRef) returnedObject.getSecond();
    decide(authentication, object, config, nodeRef);
    // the noderef was allowed
    return returnedObject;
}
 
Example 7
Source File: VirtualFileFolderServiceExtension.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Set<QName>[] buildSearchAndIgnore(final boolean files, final boolean folders, Set<QName> ignoreQNames)
{
    Set<QName>[] searchAndIgnore = (Set<QName>[]) Array.newInstance(Set.class,
                                                                    3);

    Pair<Set<QName>, Set<QName>> searchTypesAndIgnoreAspects = getTrait().buildSearchTypesAndIgnoreAspects(files,
                                                                                                           folders,
                                                                                                           ignoreQNames);
    if (searchTypesAndIgnoreAspects != null)
    {
        Set<QName> searchTypesQNames = searchTypesAndIgnoreAspects.getFirst();
        Set<QName> ignoreAspectsQNames = searchTypesAndIgnoreAspects.getSecond();

        Set<QName> ignoreTypesQNames = null;
        if ((searchTypesQNames != null || ignoreAspectsQNames != null) && ignoreQNames != null)
        {
            ignoreTypesQNames = new HashSet<>(ignoreQNames);
            if (searchTypesQNames != null)
            {
                ignoreTypesQNames.removeAll(searchTypesQNames);
            }
            if (ignoreAspectsQNames != null)
            {
                ignoreTypesQNames.removeAll(ignoreAspectsQNames);
            }
        }
        searchAndIgnore[0] = searchTypesQNames;
        searchAndIgnore[1] = ignoreTypesQNames;
        searchAndIgnore[2] = ignoreAspectsQNames;
    }

    return searchAndIgnore;
}
 
Example 8
Source File: DbNodeServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class)
public AssociationRef getAssoc(Long id)
{
    Pair<Long, AssociationRef> nodeAssocPair = nodeDAO.getNodeAssocOrNull(id);
    return nodeAssocPair == null ? null : nodeAssocPair.getSecond();
}
 
Example 9
Source File: AbstractAclCrudDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private AclEntity getAclImpl(Long id)
{
    if (id == null)
    {
        return null;
    }
    Pair<Long, AclEntity> entityPair = aclEntityCache.getByKey(id);
    if (entityPair == null)
    {
        return null;
    }
    return entityPair.getSecond();
}
 
Example 10
Source File: NodeDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Ensure that the {@link NodeEntity} values cached as root nodes are valid instances.
 * <p/>
 * ACE-987: NPE in NodeEntity during post-commit write through to shared cache
 */
public void testRootNodeCacheEntries() throws Throwable
{
    // Get the stores
    List<Pair<Long, StoreRef>> storeRefPairs = nodeDAO.getStores();
    assertTrue("No stores in the system.", storeRefPairs.size() > 0);
    // Drop all cache entries and reload them one by one
    for (Pair<Long, StoreRef> storeRefPair : storeRefPairs)
    {
        StoreRef storeRef = storeRefPair.getSecond();
        nodeDAO.getRootNode(storeRef);
    }
    // The cache should be populated again
    Collection<Serializable> keys = rootNodesCache.getKeys();
    assertTrue("Cache entries were not populated. ", keys.size() > 0);
    // Check each root node
    for (Serializable key : keys)
    {
        NodeEntity node = (NodeEntity) TransactionalCache.getSharedCacheValue(rootNodesCache, key);
        
        // Create a good value
        NodeEntity clonedNode = (NodeEntity) node.clone();
        // Run equals and hashcode
        node.hashCode();
        Assert.assertEquals(node, clonedNode);          // Does NPE check implicitly
    }
}
 
Example 11
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void speedTestRead(String name, List<Pair<Long, ContentData>> pairs)
{
    System.out.println("Starting read speed test: " + name);
    long start = System.nanoTime();
    // Loop and check for performance degradation
    int num = 1;
    for (Pair<Long, ContentData> pair : pairs)
    {
        Long id = pair.getFirst();
        ContentData contentData = pair.getSecond();
        // Retrieve it
        getAndCheck(id, contentData);
        // Report
        if (num % 1000 == 0)
        {
            long now = System.nanoTime();
            double diffMs = (double) (now - start) / 1E6;
            double aveMs = diffMs / (double) num;
            String msg = String.format(
                    "   Read %7d rows; average is %5.2f ms per row or %5.2f rows per second",
                    num,
                    aveMs,
                    1000.0 / aveMs);
            System.out.println(msg);
        }
        num++;
    }
    // Done
}
 
Example 12
Source File: GetPeopleCannedQueryFactory.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 filterProps           filter props
 * @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 includeAdministrators include administrators in the returned results
 * @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, List<QName> filterProps, Set<QName> inclusiveAspects, Set<QName> exclusiveAspects, boolean includeAdministrators, 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 (property values)
    GetPeopleCannedQueryParams paramBean = new GetPeopleCannedQueryParams(tenantService.getName(parentRef), filterProps, pattern, inclusiveAspects, exclusiveAspects, includeAdministrators);

    // 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)
        {
            boolean sortAsc = ((sortProp.getSecond() == null) || sortProp.getSecond());
            sortPairs.add(new Pair<QName, SortOrder>(sortProp.getFirst(), (sortAsc ? 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 13
Source File: QuickShareServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void deleteQuickShareLinkExpiryAction(QuickShareLinkExpiryAction linkExpiryAction)
{
    ParameterCheck.mandatory("linkExpiryAction", linkExpiryAction);

    NodeRef nodeRef = null;
    try
    {
        Pair<String, NodeRef> pair = getTenantNodeRefFromSharedId(linkExpiryAction.getSharedId());
        nodeRef = pair.getSecond();
    }
    catch (InvalidSharedIdException ex)
    {
        // do nothing, as the node might be already unshared
    }
    final NodeRef sharedNodeRef = nodeRef;

    TenantUtil.runAsSystemTenant(() -> {
        // Delete the expiry action and its related persisted schedule
        deleteQuickShareLinkExpiryActionImpl(linkExpiryAction);

        // As the method is called directly (ie. not via unshareContent method which removes the aspect properties),
        // then we have to remove the 'expiryDate' property as well.
        if (sharedNodeRef != null && nodeService.getProperty(sharedNodeRef, QuickShareModel.PROP_QSHARE_EXPIRY_DATE) != null)
        {
            behaviourFilter.disableBehaviour(sharedNodeRef, ContentModel.ASPECT_AUDITABLE);
            try
            {
                nodeService.removeProperty(sharedNodeRef, QuickShareModel.PROP_QSHARE_EXPIRY_DATE);
            }
            finally
            {
                behaviourFilter.enableBehaviour(sharedNodeRef, ContentModel.ASPECT_AUDITABLE);
            }
        }
        return null;
    }, TenantUtil.getCurrentDomain());
}
 
Example 14
Source File: AbstractAclCrudDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Authority createAuthority(String authorityName)
{
    ParameterCheck.mandatory("authorityName", authorityName);
    
    AuthorityEntity entity = new AuthorityEntity();
    entity.setAuthority(authorityName);
    entity.setCrc(CrcHelper.getStringCrcPair(authorityName, 32, true, true).getSecond());
    
    entity.setVersion(0L);
    
    Pair<Long, AuthorityEntity> entityPair = authorityEntityCache.getOrCreateByValue(entity);
    return entityPair.getSecond();
}
 
Example 15
Source File: PreferencesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CollectionWithPagingInfo<Preference> getPreferences(String personId, Paging paging)
{
	personId = people.validatePerson(personId);

	PagingResults<Pair<String, Serializable>> preferences = preferenceService.getPagedPreferences(personId, null, Util.getPagingRequest(paging));
	List<Preference> ret = new ArrayList<Preference>(preferences.getPage().size());
	for(Pair<String, Serializable> prefEntity : preferences.getPage())
	{
		Preference pref = new Preference(prefEntity.getFirst(), prefEntity.getSecond());
		ret.add(pref);
	}

       return CollectionWithPagingInfo.asPaged(paging, ret, preferences.hasMoreItems(), preferences.getTotalResultCount().getFirst());
}
 
Example 16
Source File: NodesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(final Parameters parameters)
{
    // filters
    Boolean includeFolders = null;
    Boolean includeFiles = null;
    QName filterNodeTypeQName = null;

    // note: for files/folders, include subtypes by default (unless filtering by a specific nodeType - see below)
    boolean filterIncludeSubTypes = true;

    Query q = parameters.getQuery();

    if (q != null)
    {
        // filtering via "where" clause
        MapBasedQueryWalker propertyWalker = createListChildrenQueryWalker();
        QueryHelper.walk(q, propertyWalker);

        Boolean isFolder = propertyWalker.getProperty(PARAM_ISFOLDER, WhereClauseParser.EQUALS, Boolean.class);
        Boolean isFile = propertyWalker.getProperty(PARAM_ISFILE, WhereClauseParser.EQUALS, Boolean.class);

        if (isFolder != null)
        {
            includeFolders = isFolder;
        }

        if (isFile != null)
        {
            includeFiles = isFile;
        }

        if (Boolean.TRUE.equals(includeFiles) && Boolean.TRUE.equals(includeFolders))
        {
            throw new InvalidArgumentException("Invalid filter (isFile=true and isFolder=true) - a node cannot be both a file and a folder");
        }

        String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
        if ((nodeTypeStr != null) && (! nodeTypeStr.isEmpty()))
        {
            if ((isFile != null) || (isFolder != null))
            {
                throw new InvalidArgumentException("Invalid filter - nodeType and isFile/isFolder are mutually exclusive");
            }

            Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeStr);
            filterNodeTypeQName = pair.getFirst();
            filterIncludeSubTypes = pair.getSecond();
        }
    }

    // notes (see also earlier validation checks):
    // - no filtering means any types/sub-types (well, apart from hidden &/or default ignored types - eg. systemfolder, fm types)
    // - node type filtering is mutually exclusive from isFile/isFolder, can optionally also include sub-types
    // - isFile & isFolder cannot both be true
    // - (isFile=false) means any other types/sub-types (other than files)
    // - (isFolder=false) means any other types/sub-types (other than folders)
    // - (isFile=false and isFolder=false) means any other types/sub-types (other than files or folders)

    if (filterNodeTypeQName == null)
    {
        if ((includeFiles == null) && (includeFolders == null))
        {
            // no additional filtering
            filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
        }
        else if ((includeFiles != null) && (includeFolders != null))
        {
            if ((! includeFiles) && (! includeFolders))
            {
                // no files or folders
                filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
            }
        }
        else if ((includeFiles != null) && (! includeFiles))
        {
            // no files
            filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
        }
        else if ((includeFolders != null) && (! includeFolders))
        {
            // no folders
            filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
        }
    }

    return buildSearchTypesAndIgnoreAspects(filterNodeTypeQName, filterIncludeSubTypes, ignoreQNames, includeFiles, includeFolders);
}
 
Example 17
Source File: AbstractRemoteContentTransformer.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void afterPropertiesSet()
{
    if (enabled)
    {
        // check availability
        if (remoteTransformerClientConfigured())
        {
            Log logger = getLogger();
            try
            {
                Pair<Boolean, String> result = remoteTransformerClient.check(logger);
                Boolean isAvailable = result.getFirst();
                String msg = result.getSecond() == null ? "" : result.getSecond();
                if (isAvailable != null && isAvailable)
                {
                    String versionString = msg;
                    setAvailable(true);
                    logger.debug("Using legacy " + getName() + ": " + versionString);
                }
                else
                {
                    setAvailable(false);
                    String message = "Legacy " + getName() + " is not available for transformations. " + msg;
                    if (isAvailable == null)
                    {
                        logger.debug(message);
                    }
                    else
                    {
                        logger.error(message);
                    }
                }
            }
            catch (Throwable e)
            {
                setAvailable(false);
                logger.error("Remote " + getName() + " is not available: " + (e.getMessage() != null ? e.getMessage() : ""));
                // debug so that we can trace the issue if required
                logger.debug(e);
            }
        }
        else
        {
            available = true;
        }
    }
}
 
Example 18
Source File: QuickShareContentGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of template vars (params)
    final 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
    {
        Pair<String, NodeRef> pair = quickShareSerivce.getTenantNodeRefFromSharedId(sharedId);
        final String tenantDomain = pair.getFirst();
        final NodeRef nodeRef = pair.getSecond();

        TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>()
        {
            public Void doWork() throws Exception
            {
                if (! nodeService.getAspects(nodeRef).contains(QuickShareModel.ASPECT_QSHARE))
                {
                    throw new InvalidNodeRefException(nodeRef);
                }

                // MNT-21118 (XSS prevention)
                // Force the attachment in case of asking for the content file only
                // (will be overridden for thumbnails)
                executeImpl(nodeRef, params, req, res, null, true);
                
                return null;
            }
        }, tenantDomain);
        
        if (logger.isDebugEnabled())
        {
            logger.debug("QuickShare - retrieved content: "+sharedId+" ["+nodeRef+"]");
        }

    }
    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);
    }
}
 
Example 19
Source File: CustomModelsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void validateTypeAspectParent(AbstractClassModel typeAspect, CustomModel existingModel)
{
    String parentPrefixedName = typeAspect.getParentName();
    if (StringUtils.isBlank(parentPrefixedName))
    {
        return;
    }

    Pair<String, String> prefixLocaNamePair = splitPrefixedQName(parentPrefixedName);
    String parentPrefix = prefixLocaNamePair.getFirst();
    String parentLocalName = prefixLocaNamePair.getSecond();

    // Validate parent prefix and localName
    // We know that the values are not null, we just check against the defined RegEx
    validateName(parentPrefix, null);
    validateName(parentLocalName, null);

    final boolean isAspect = (typeAspect instanceof CustomAspect);
    ClassDefinition classDefinition = null;
    QName qname = null;
    if (existingModel.getNamespacePrefix().equals(parentPrefix))
    {
        // Check for types/aspects within the model
        qname = QName.createQName(existingModel.getNamespaceUri(), parentLocalName);
        classDefinition = (isAspect) ? customModelService.getCustomAspect(qname) : customModelService.getCustomType(qname);
    }
    else
    {
        // Make sure the namespace URI and Prefix are registered
        Pair<String, String> uriPrefixPair = resolveToUriAndPrefix(parentPrefixedName);

        qname = QName.createQName(uriPrefixPair.getFirst(), parentLocalName);
        classDefinition = (isAspect) ? dictionaryService.getAspect(qname) : dictionaryService.getType(qname);
    }

    if (classDefinition == null)
    {
        String msgId = (isAspect) ? "cmm.rest_api.aspect_parent_not_exist" : "cmm.rest_api.type_parent_not_exist";
        throw new ConstraintViolatedException(I18NUtil.getMessage(msgId, parentPrefixedName));
    }
    else
    {
        checkCircularDependency(classDefinition.getModel(), existingModel, parentPrefixedName);
    }
}
 
Example 20
Source File: AttributeServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void getAttributes(final AttributeQueryCallback callback, Serializable ... keys)
{
    PropertyUniqueContextCallback propertyUniqueContextCallback = new PropertyUniqueContextCallback()
    {
        private boolean more = true;
        public void handle(Long id, Long valueId, Serializable[] resultKeyIds)
        {
            if (!more)
            {
                // The callback has terminated fetching
                return;
            }
            
            Serializable value = null;
            if (valueId != null)
            {
                value = propertyValueDAO.getPropertyById(valueId);
            }
            
            Serializable[] resultsKeyValues = new Serializable[resultKeyIds.length];
            for (int i = 0; i < resultKeyIds.length; i++)
            {
                if (resultKeyIds[i] != null)
                {
                    Pair<Long, Serializable> keyValuePair = propertyValueDAO.getPropertyValueById((Long)resultKeyIds[i]);
                    resultsKeyValues[i] = (keyValuePair != null ? keyValuePair.getSecond() : null);
                }
            }
            
            more = callback.handleAttribute(id, value, resultsKeyValues);
            
            // Done
            if (logger.isTraceEnabled())
            {
                logger.trace(
                        "Got attribute: \n" +
                        "   Keys:   " + Arrays.asList(resultsKeyValues) + "\n" +
                        "   Value: " + value);
            }
        }
    };
    propertyValueDAO.getPropertyUniqueContext(propertyUniqueContextCallback, keys);
    // Done
}