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

The following examples show how to use org.alfresco.util.Pair#getFirst() . 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: 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 2
Source File: AbstractAclCrudDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private PermissionEntity getPermissionImpl(PermissionReference permissionReference)
{
    ParameterCheck.mandatory("permissionReference", permissionReference);
    
    PermissionEntity entity = null;
    
    // Get the persistent ID for the QName
    Pair<Long, QName> qnamePair = qnameDAO.getOrCreateQName(permissionReference.getQName());
    if (qnamePair != null)
    {
        Long qnameId  = qnamePair.getFirst();
        
        PermissionEntity permission = new PermissionEntity(qnameId, permissionReference.getName());
        Pair<Long, PermissionEntity> entityPair = permissionEntityCache.getByValue(permission);
        if (entityPair != null)
        {
            entity = entityPair.getSecond();
        }
    }
    
    return entity;
}
 
Example 3
Source File: SOLRDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
    * {@inheritDoc}
    */
   @Override
   @SuppressWarnings("unchecked")
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, Long maxTxnId, Long toCommitTime, int maxResults)
{
       if (maxResults <= 0 || maxResults == Integer.MAX_VALUE)
       {
           throw new IllegalArgumentException("Maximum results must be a reasonable number.");
       }

       // We simulate an ID for the sys:deleted type
       Pair<Long, QName> deletedTypeQNamePair = qnameDAO.getQName(ContentModel.TYPE_DELETED);
       Long deletedTypeQNameId = deletedTypeQNamePair == null ? -1L : deletedTypeQNamePair.getFirst();

       SOLRTrackingParameters params = new SOLRTrackingParameters(deletedTypeQNameId);
    params.setFromIdInclusive(minTxnId);
    params.setFromCommitTimeInclusive(fromCommitTime);
    params.setToIdExclusive(maxTxnId);
       params.setToCommitTimeExclusive(toCommitTime);

       return template.selectList(SELECT_TRANSACTIONS, params, new RowBounds(0, maxResults));
}
 
Example 4
Source File: ExecParameterTokenizer.java    From alfresco-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * The substrings will be a list of quoted and unquoted substrings.
 * The unquoted ones need to be further tokenized in the normal way.
 * The quoted ones must not be tokenized, but need their quotes stripped off.
 */
private List<Substring> getSubstrings(String str, List<Pair<Integer, Integer>> quotedRegionIndices)
{
    List<Substring> result = new ArrayList<Substring>();

    int cursorPosition = 0;
    for (Pair<Integer, Integer> nextQuotedRegionIndices : quotedRegionIndices)
    {
        if (cursorPosition < nextQuotedRegionIndices.getFirst())
        {
            int startIndexOfNextQuotedRegion = nextQuotedRegionIndices.getFirst() - 1;
            result.add(new UnquotedSubstring(str.substring(cursorPosition, startIndexOfNextQuotedRegion)));
            cursorPosition = startIndexOfNextQuotedRegion;
        }
        result.add(new QuotedSubstring(str.substring(nextQuotedRegionIndices.getFirst(), nextQuotedRegionIndices.getSecond())));
        cursorPosition = nextQuotedRegionIndices.getSecond();
    }

    // We've processed all the quoted regions, but there may be a final unquoted region
    if (cursorPosition < str.length() - 1)
    {
        result.add(new UnquotedSubstring(str.substring(cursorPosition, str.length() - 1)));
    }
    
    return result;
}
 
Example 5
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 6
Source File: DbNodeServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class)
public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(NodeRef parent, QName assocTypeQName)
{
    // Get the parent node
    Pair<Long, NodeRef> nodePair = getNodePairNotNull(parent);
    Long parentNodeId = nodePair.getFirst();

    final List<ChildAssociationRef> results = new ArrayList<ChildAssociationRef>(100);

    NodeDAO.ChildAssocRefQueryCallback callback = new NodeDAO.ChildAssocRefQueryCallback()
    {
        public boolean preLoadNodes()
        {
            return false;
        }

        @Override
        public boolean orderResults()
        {
            return false;
        }

        public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair, Pair<Long, NodeRef> parentNodePair,
                Pair<Long, NodeRef> childNodePair)
        {
            results.add(childAssocPair.getSecond());
            // More results
            return true;
        }

        public void done()
        {
        }                               
    };
    // Get the child associations that meet the criteria
    nodeDAO.getChildAssocsWithoutParentAssocsOfType(parentNodeId, assocTypeQName, callback);
    // done
    return results;
}
 
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: AbstractUsageDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private long getNodeIdNotNull(NodeRef nodeRef)
{
    ParameterCheck.mandatory("nodeRef", nodeRef);
    
    Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(nodeRef);
    if (nodePair == null)
    {
        throw new InvalidNodeRefException("Node does not exist: " + nodeRef, nodeRef);
    }
    return nodePair.getFirst();
}
 
Example 9
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testUpdate() throws Exception
{
    ContentData contentData = getContentData();
    Pair<Long, ContentData> resultPair = create(contentData);
    Long id = resultPair.getFirst();
    // Update
    contentData = ContentData.setMimetype(contentData, "TEXT/HTML"); // Note the upper case mimetype
    contentData = ContentData.setEncoding(contentData, "UTF-16");
    // Don't update the content itself
    update(id, contentData);
    // Check
    Pair<Long, ContentData> result = getAndCheck(id, contentData);
    // Check the mimetype has been lowercased
    assertEquals("text/html", result.getSecond().getMimetype());
}
 
Example 10
Source File: AbstractNodeDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Pair<Long, StoreRef> getStore(StoreRef storeRef)
{
    Pair<StoreRef, Node> rootNodePair = rootNodesCache.getByKey(storeRef);
    if (rootNodePair == null)
    {
        return null;
    }
    else
    {
        return new Pair<Long, StoreRef>(rootNodePair.getSecond().getStore().getId(), rootNodePair.getFirst());
    }
}
 
Example 11
Source File: AuthorityDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param authorityNodeRef              a containing authority
 * @param authorityToFindRef            an authority to find in the hierarchy
 * @return                              Returns <tt>true</tt> if the authority to find occurs
 *                                      in the hierarchy and is reachable via the {@link ContentModel#ASSOC_MEMBER}
 *                                      association.
 */
private boolean isAuthorityContainedImpl(NodeRef authorityNodeRef, String authority, NodeRef authorityToFindRef,
        Set<String> positiveHits, Set<String> negativeHits)
{
    if (positiveHits.contains(authority))
    {
        return true;
    }
    if (negativeHits.contains(authority))
    {
        return false;
    }
    Pair<Map<NodeRef, String>, List<NodeRef>> childAuthorities = getChildAuthorities(authorityNodeRef);
    Map<NodeRef, String> childAuthorityMap = childAuthorities.getFirst();

    // Is the authority we are looking for in the set provided (NodeRef is lookup)
    if (childAuthorityMap.containsKey(authorityToFindRef))
    {
        positiveHits.add(authority);
        return true;
    }

    // Recurse on non-user authorities
    for (NodeRef nodeRef : childAuthorities.getSecond())
    {
        if (isAuthorityContainedImpl(nodeRef, childAuthorityMap.get(nodeRef),
                authorityToFindRef, positiveHits, negativeHits))
        {
            positiveHits.add(authority);
            return true;
        }
    }
    negativeHits.add(authority);
    return false;
}
 
Example 12
Source File: AttributeServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void updateOrCreateAttribute(
        Serializable keyBefore1,
        Serializable keyBefore2,
        Serializable keyBefore3,
        Serializable keyAfter1,
        Serializable keyAfter2,
        Serializable keyAfter3)
{
    Pair<Long, Long> pair = propertyValueDAO.getPropertyUniqueContext(keyBefore1, keyBefore2, keyBefore3);
    try
    {
        if (pair == null)
        {
            pair = propertyValueDAO.createPropertyUniqueContext(keyAfter1, keyAfter2, keyAfter3, null);
        }
        else
        {
            Long id = pair.getFirst();
            propertyValueDAO.updatePropertyUniqueContextKeys(id, keyAfter1, keyAfter2, keyAfter3);
        }
    }
    catch (PropertyUniqueConstraintViolation e)
    {
        throw new DuplicateAttributeException(keyAfter1, keyAfter2, keyAfter3, e); 
    }
    // Done
    if (logger.isDebugEnabled())
    {
        Serializable[] keysBefore = normalizeKeys(keyBefore1, keyBefore2, keyBefore3);
        Serializable[] keysAfter = normalizeKeys(keyAfter1, keyAfter2, keyAfter3);
        logger.debug(
                "Updated attribute: \n" +
                "   Before:   " + Arrays.asList(keysBefore) + "\n" +
                "   After:    " + Arrays.asList(keysAfter));
    }
}
 
Example 13
Source File: UserAuditFilter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean acceptUser(String value)
{
    if (value == null)
    {
        value = "null";
    }
    for (Pair<Boolean, Pattern> val : listOfPairValue)
    {
        if (val.getSecond().matcher(value).matches())
        {
            return val.getFirst();
        }
    }
    return true;
}
 
Example 14
Source File: ModuleDetailsImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean isValidDependency(ModuleDetails moduleDetails)
{
    // Nothing to compare to
    if (moduleDetails == null)
    {
        return false;
    }
    // Check the ID
    if (!moduleDetails.getId().equals(dependencyId))
    {
        return false;
    }
    // Check the version number
    ModuleVersionNumber checkVersion = moduleDetails.getModuleVersionNumber();
    boolean matched = false;
    for (Pair<ModuleVersionNumber, ModuleVersionNumber> versionRange : versionRanges)
    {
        ModuleVersionNumber versionLower = versionRange.getFirst();
        ModuleVersionNumber versionUpper = versionRange.getSecond();
        if (checkVersion.compareTo(versionLower) < 0)
        {
            // The version is too low
            continue; 
        }
        if (checkVersion.compareTo(versionUpper) > 0)
        {
            // The version is too high
            continue;
        }
        // It is a match
        matched = true;
        break;
    }
    return matched;
}
 
Example 15
Source File: UsageDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void selectUsersWithoutUsage(StoreRef storeRef, MapHandler resultsCallback)
{
    Pair<Long, ? extends Object> personTypeQNamePair = qnameDAO.getQName(ContentModel.TYPE_PERSON);
    Pair<Long, ? extends Object> usernamePropQNamePair = qnameDAO.getQName(ContentModel.PROP_USERNAME);
    Pair<Long, ? extends Object> sizeCurrentPropQNamePair = qnameDAO.getQName(ContentModel.PROP_SIZE_CURRENT);
    
    if (personTypeQNamePair == null || usernamePropQNamePair == null || sizeCurrentPropQNamePair == null)
    {
        return;             // The statics have not been used, so there can be no results
    }
    
    Long personTypeQNameEntityId = personTypeQNamePair.getFirst();
    Long usernamePropQNameEntityId = usernamePropQNamePair.getFirst();
    Long sizeCurrentPropQNameEntityId = sizeCurrentPropQNamePair.getFirst();
    
    Map<String, Object> params = new HashMap<String, Object>(5);
    params.put("personTypeQNameID", personTypeQNameEntityId); // cm:person (type)
    params.put("usernamePropQNameID", usernamePropQNameEntityId); // cm:username (prop)
    params.put("sizeCurrentPropQNameID", sizeCurrentPropQNameEntityId); // cm:sizeCurrent (prop)
    params.put("storeProtocol", storeRef.getProtocol());
    params.put("storeIdentifier", storeRef.getIdentifier());
    
    MapResultHandler resultHandler = new MapResultHandler(resultsCallback);
    
    template.select(SELECT_USERS_WITHOUT_USAGE, params, resultHandler);
    
    if (logger.isDebugEnabled())
    {
        logger.debug("   Listed " + resultHandler.total + " users without usage");
    }
}
 
Example 16
Source File: GetPeopleCannedQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Long getQNameId(QName sortPropQName)
{
    Pair<Long, QName> qnamePair = qnameDAO.getQName(sortPropQName);
    return (qnamePair == null ? null : qnamePair.getFirst());
}
 
Example 17
Source File: AbstractGetBlogWebScript.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void createFtlModel(WebScriptRequest req, Map<String, Object> model, NodeRef node, PagingRequest pagingReq,
                              PagingResults<BlogPostInfo> blogPostList)
{
    Map<String, Object> blogPostsData = new HashMap<String, Object>();
    
    final Pair<Integer, Integer> totalResultCount = blogPostList.getTotalResultCount();
    int total = blogPostList.getPage().size();
    if (totalResultCount != null && totalResultCount.getFirst() != null)
    {
       total = totalResultCount.getFirst();
    }
    //FIXME What to do? null
    blogPostsData.put("total", total);
    blogPostsData.put("pageSize", pagingReq.getMaxItems());
    blogPostsData.put("startIndex", pagingReq.getSkipCount());
    blogPostsData.put("itemCount", blogPostList.getPage().size());
    
    if (total == pagingReq.getRequestTotalCountMax())
    {
        blogPostsData.put("totalRecordsUpper", true);
    }
    else
    {
        blogPostsData.put("totalRecordsUpper", false);
    }
    
    List<Map<String, Object>> blogPostDataSets = new ArrayList<Map<String, Object>>(blogPostList.getPage().size());
    for (BlogPostInfo postInfo : blogPostList.getPage())
    {
        Map<String, Object> data = BlogPostLibJs.getBlogPostData(postInfo.getNodeRef(), services);
        blogPostDataSets.add(data);
    }
    blogPostsData.put("items", blogPostDataSets);

    model.put("data", blogPostsData);

    // fetch the contentLength param
    String contentLengthStr = req.getParameter("contentLength");
    int contentLength = contentLengthStr == null ? -1 : Integer.parseInt(contentLengthStr);
    model.put("contentLength", contentLength);
    
    // assign the blog node
    model.put("blog", node);
    model.put("externalBlogConfig", BlogPostLibJs.hasExternalBlogConfiguration(node, services));
}
 
Example 18
Source File: ShareContentGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected Map<String, Object> executeImpl(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
    {
        Pair<String, NodeRef> pair = quickShareService.getTenantNodeRefFromSharedId(sharedId);
        final String tenantDomain = pair.getFirst();
        final NodeRef nodeRef = pair.getSecond();
        
        String siteId = siteService.getSiteShortName(nodeRef);
        
        Map<String, Object> model = new HashMap<String, Object>(3);
        model.put("sharedId", sharedId);
        model.put("nodeRef", nodeRef.toString());
        model.put("siteId", siteId);
        model.put("tenantDomain", tenantDomain);
        
        if (logger.isInfoEnabled())
        {
            logger.info("QuickShare - get shared context: "+sharedId+" ["+model+"]");
        }
        
        return model;
    }
    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: AbstractPropertyValueDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Pair<Long, Long> getPropertyUniqueContext(Serializable value1, Serializable value2, Serializable value3)
{
    // Translate the properties.  Null values are quite acceptable
    Pair<Long, Serializable> pair1 = getPropertyValue(value1);
    Pair<Long, Serializable> pair2 = getPropertyValue(value2);
    Pair<Long, Serializable> pair3 = getPropertyValue(value3);
    if (pair1 == null || pair2 == null || pair3 == null)
    {
        // None of the values exist so no unique context values can exist
        return null;
    }
    Long id1 = pair1.getFirst();
    Long id2 = pair2.getFirst();
    Long id3 = pair3.getFirst();
    
    CachePucKey pucKey = getPucKey(id1, id2, id3);
    
    // check cache
    PropertyUniqueContextEntity entity = propertyUniqueContextCache.get(pucKey);
    if (entity == null)
    {
        // Remove from cache
        propertyUniqueContextCache.remove(pucKey);
        
        // query DB
        entity = getPropertyUniqueContextByValues(id1, id2, id3);
        
        if (entity != null)
        {
            // cache
            propertyUniqueContextCache.put(pucKey, entity);
        }
    }
     
    if ((entity != null) && (entity.getPropertyId() != null))
    {
        try
        {
            // eager fetch - ignore return for now (could change API)
            getPropertyById(entity.getPropertyId());
        }
        catch (DataIntegrityViolationException dive)
        {
        	// Remove from cache
            propertyUniqueContextCache.remove(pucKey);
            throw dive;
        }
    }
    
    // Done
    if (logger.isDebugEnabled())
    {
        logger.debug(
                "Searched for unique property context: \n" +
                "   Values: " + value1 + "-" + value2 + "-" + value3 + "\n" +
                "   Result: " + entity);
    }
    return entity == null ? null : new Pair<Long, Long>(entity.getId(), entity.getPropertyId());
}
 
Example 20
Source File: TestCustomModel.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
//SHA-726
public void testUpdateModel_WithAspectsAndTypes() throws Exception
{
    setRequestContext(customModelAdmin);
    
    String modelName = "testModel" + System.currentTimeMillis();
    Pair<String, String> namespacePair = getTestNamespaceUriPrefixPair();
    // Create the model as a Model Administrator
    createCustomModel(modelName, namespacePair, ModelStatus.DRAFT);

    // Add type
    String typeBaseName = "testTypeBase" + System.currentTimeMillis();
    final String typeBaseNameWithPrefix = namespacePair.getSecond() + QName.NAMESPACE_PREFIX + typeBaseName;
    createTypeAspect(CustomType.class, modelName, typeBaseName, "test typeBase title", null, "cm:content");

    // Add aspect
    final String aspectName = "testAspect" + System.currentTimeMillis();
    final String aspectNameWithPrefix = namespacePair.getSecond() + QName.NAMESPACE_PREFIX + aspectName;
    createTypeAspect(CustomAspect.class, modelName, aspectName, null, null, null);

    // Activate the model
    CustomModel modelOneStatusPayload = new CustomModel();
    modelOneStatusPayload.setStatus(ModelStatus.ACTIVE);
    put("cmm", modelName, RestApiUtil.toJsonAsString(modelOneStatusPayload), SELECT_STATUS_QS, 200);

    // Add another type with 'typeBaseName' as its parent
    String childTypeName = "testTypeChild" + System.currentTimeMillis();
    createTypeAspect(CustomType.class, modelName, childTypeName, "test typeChild title", "test typeChild Desc", typeBaseNameWithPrefix);

    // Add another aspect with 'aspectName' as its parent
    final String childAspectName = "testChildAspect" + System.currentTimeMillis();
    createTypeAspect(CustomAspect.class, modelName, childAspectName, "test child aspect title", null, aspectNameWithPrefix);

     // Deactivate the model
    modelOneStatusPayload = new CustomModel();
    modelOneStatusPayload.setStatus(ModelStatus.DRAFT);
    put("cmm", modelName, RestApiUtil.toJsonAsString(modelOneStatusPayload), SELECT_STATUS_QS, 200);

    // Test update the namespace prefix
    CustomModel updatePayload = new CustomModel();
    String modifiedPrefix = namespacePair.getSecond() + "Modified";
    updatePayload.setNamespacePrefix(modifiedPrefix);
    updatePayload.setNamespaceUri(namespacePair.getFirst());
    HttpResponse response = put("cmm", modelName, RestApiUtil.toJsonAsString(updatePayload), null, 200);
    CustomModel returnedModel = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomModel.class);
    assertEquals(modifiedPrefix, returnedModel.getNamespacePrefix());
    assertEquals("The namespace URI shouldn't have changed.", namespacePair.getFirst(), returnedModel.getNamespaceUri());

    // Test update the namespace URI
    updatePayload = new CustomModel();
    updatePayload.setNamespacePrefix(modifiedPrefix);
    String modifiedURI = namespacePair.getFirst() + "Modified";
    updatePayload.setNamespaceUri(modifiedURI);
    response = put("cmm", modelName, RestApiUtil.toJsonAsString(updatePayload), null, 200);
    returnedModel = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomModel.class);
    assertEquals(modifiedURI, returnedModel.getNamespaceUri());
    assertEquals("The namespace prefix shouldn't have changed.", modifiedPrefix, returnedModel.getNamespacePrefix());

    // Retrieve the child type
    response = getSingle("cmm/" + modelName + "/types", childTypeName,  200);
    CustomType returnedChildType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
    final String newTypeParentName = modifiedPrefix + QName.NAMESPACE_PREFIX + typeBaseName;
    assertEquals("The parent name prefix should have been updated.", newTypeParentName, returnedChildType.getParentName());

    // Retrieve the child aspect
    response = getSingle("cmm/" + modelName + "/aspects", childAspectName,  200);
    CustomAspect returnedChildAspect = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomAspect.class);
    final String newAspectParentName = modifiedPrefix + QName.NAMESPACE_PREFIX + aspectName;
    assertEquals("The parent name prefix should have been updated.", newAspectParentName, returnedChildAspect.getParentName());
}