Java Code Examples for org.alfresco.service.cmr.dictionary.ClassDefinition#getParentName()

The following examples show how to use org.alfresco.service.cmr.dictionary.ClassDefinition#getParentName() . 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: ClassFeatureBehaviourBinding.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public BehaviourBinding generaliseBinding()
{
    BehaviourBinding generalisedBinding = null;
    ClassDefinition classDefinition = getDictionary().getClass(getClassQName());
    
    if (classDefinition == null)
    {
        // The class definition doesn't exist so there can be no behaviour bound
        return null;
    }
    
    if (activeFeatureQName.equals(ALL_FEATURES))
    {
        QName parentClassName = classDefinition.getParentName();
        if (parentClassName != null)
        {
            generalisedBinding = new ClassFeatureBehaviourBinding(getDictionary(), getNodeRef(), parentClassName, featureQName, featureQName);
        }
    }
    else
    {
        generalisedBinding = new ClassFeatureBehaviourBinding(getDictionary(), getNodeRef(), getClassQName(), featureQName, ALL_FEATURES);
    }
    
    return generalisedBinding;
}
 
Example 2
Source File: ClassBehaviourBinding.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public BehaviourBinding generaliseBinding()
{
    BehaviourBinding generalisedBinding = null;
    ClassDefinition classDefinition = dictionary.getClass(classQName);
    if (classDefinition == null)
    {
        // The class definition doesn't exist so there can be no behaviour bound
        return null;
    }
    
    QName parentClassName = classDefinition.getParentName();
    if (parentClassName != null)
    {
        generalisedBinding = new ClassBehaviourBinding(dictionary, parentClassName);
    }
    return generalisedBinding;
}
 
Example 3
Source File: PermissionModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Query the model for a base permission group Uses the Data Dictionary to reolve inheritance
 * 
 * @param pg PermissionGroup
 * @return the permission group
 */
private PermissionGroup getBasePermissionGroupOrNullImpl(PermissionGroup pg)
{
    if (pg == null)
    {
        return null;
    }
    if (pg.isExtends())
    {
        if (pg.getTypeQName() != null)
        {
            return getPermissionGroup(SimplePermissionReference.getPermissionReference(pg.getTypeQName(), pg.getName()));
        }
        else
        {
            ClassDefinition classDefinition = dictionaryService.getClass(pg.getQName());
            QName parent;
            if (classDefinition != null) {
                while ((parent = classDefinition.getParentName()) != null)
                {
                    classDefinition = dictionaryService.getClass(parent);
                    PermissionGroup attempt = getPermissionGroupOrNull(SimplePermissionReference.getPermissionReference(parent, pg.getName()));
                    if ((attempt != null) && (!attempt.isExtends()))
                    {
                        return attempt;
                    }
                }
            }
            return null;
        }
    }
    else
    {
        return pg;
    }
}
 
Example 4
Source File: BehaviourFilterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param className the class name
 * @return the super class or <code>null</code>
 */
private QName generaliseClass(QName className)
{
    ClassDefinition classDefinition = dictionaryService.getClass(className);
    if (classDefinition == null)
    {
        // The class definition doesn't exist
        return null;
    }
    QName parentClassName = classDefinition.getParentName();
    return parentClassName;
}
 
Example 5
Source File: DictionaryComponent.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean isSubClass(QName className, QName ofClassName)
{
    // Validate arguments
    ParameterCheck.mandatory("className", className);
    ParameterCheck.mandatory("ofClassName", ofClassName);
    ClassDefinition classDef = getClass(className);
    if (classDef == null)
    {
        return false;
    }
    ClassDefinition ofClassDef = getClass(ofClassName);
    if (ofClassDef == null)
    {
        return false;
    }
    
    // Only check if both ends are either a type or an aspect
    boolean subClassOf = false;
    if (classDef.isAspect() == ofClassDef.isAspect())
    {
        while (classDef != null)
        {
            if (classDef.equals(ofClassDef))
            {
                subClassOf = true;
                break;
            }
            
            // No match yet, so go to parent class
            QName parentClassName = classDef.getParentName();
            classDef = (parentClassName == null) ? null : getClass(parentClassName);
        }
    }        
    return subClassOf;
}
 
Example 6
Source File: PermissionModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean checkPermission(PermissionReference required)
{
    Permission permission = getPermissionOrNull(required);
    if (permission != null)
    {
        return true;
    }
    PermissionGroup pg = getPermissionGroupOrNull(required);
    if (pg != null)
    {
        if (pg.isExtends())
        {
            if (pg.getTypeQName() != null)
            {
                return checkPermission(SimplePermissionReference.getPermissionReference(pg.getTypeQName(), pg.getName()));
            }
            else
            {
                ClassDefinition classDefinition = dictionaryService.getClass(pg.getQName());
                QName parent;
                while ((parent = classDefinition.getParentName()) != null)
                {
                    classDefinition = dictionaryService.getClass(parent);

                    PermissionGroup attempt = getPermissionGroupOrNull(SimplePermissionReference.getPermissionReference(parent, pg.getName()));
                    if ((attempt != null) && attempt.isAllowFullControl())
                    {
                        return true;
                    }
                }
                return false;
            }
        }
        else
        {
            return pg.isAllowFullControl();
        }
    }
    else
    {
        return false;
    }
}
 
Example 7
Source File: PermissionModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Set<PermissionReference> getGranteePermissionsImpl(PermissionReference permissionReference)
{
    // Query the model (we have the write lock)
    HashSet<PermissionReference> permissions = new HashSet<PermissionReference>(256, 1.0f);
    permissions.add(permissionReference);
    for (PermissionSet ps : permissionSets.values())
    {
        for (PermissionGroup pg : ps.getPermissionGroups())
        {
            if (pg.equals(permissionReference))
            {
                for (PermissionReference included : pg.getIncludedPermissionGroups())
                {
                    permissions.addAll(getGranteePermissions(included));
                }

                if (pg.isExtends())
                {
                    if (pg.getTypeQName() != null)
                    {
                        permissions.addAll(getGranteePermissions(SimplePermissionReference.getPermissionReference(pg.getTypeQName(), pg.getName())));
                    }
                    else
                    {
                        ClassDefinition classDefinition = dictionaryService.getClass(pg.getQName());
                        QName parent = classDefinition.getParentName();
                        if (parent != null)
                        {
                            classDefinition = dictionaryService.getClass(parent);
                            PermissionGroup attempt = getPermissionGroupOrNull(SimplePermissionReference.getPermissionReference(parent, pg.getName()));
                            if (attempt != null)
                            {
                                permissions.addAll(getGranteePermissions(attempt));
                            }
                        }
                    }
                }

                if (pg.isAllowFullControl())
                {
                    // add all available
                    permissions.addAll(getAllPermissions());
                }
            }
        }
        PermissionGroup baseGroup = getBasePermissionGroupOrNull(getPermissionGroupOrNull(permissionReference));
        if (baseGroup != null)
        {
            for (Permission p : ps.getPermissions())
            {
                for (PermissionReference grantedTo : p.getGrantedToGroups())
                {
                    PermissionGroup base = getBasePermissionGroupOrNull(getPermissionGroupOrNull(grantedTo));
                    if (baseGroup.equals(base))
                    {
                        permissions.add(p);
                    }
                }
            }
        }
    }
    return permissions;
}
 
Example 8
Source File: PermissionModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Set<PermissionReference> getImmediateGranteePermissionsImpl(PermissionReference permissionReference)
{
    // Query the model
    HashSet<PermissionReference> permissions = new HashSet<PermissionReference>(256);
    for (PermissionSet ps : permissionSets.values())
    {
        for (PermissionGroup pg : ps.getPermissionGroups())
        {
            if (pg.equals(permissionReference))
            {
                for (PermissionReference included : pg.getIncludedPermissionGroups())
                {
                    permissions.add(included);
                }
    
                if (pg.isExtends())
                {
                    if (pg.getTypeQName() != null)
                    {
                        permissions.addAll(getImmediateGranteePermissions(SimplePermissionReference.getPermissionReference(pg.getTypeQName(), pg.getName())));
                    }
                    else
                    {
                        ClassDefinition classDefinition = dictionaryService.getClass(pg.getQName());
                        QName parent = classDefinition.getParentName();
                        if (parent != null)
                        {
                            classDefinition = dictionaryService.getClass(parent);
                            PermissionGroup attempt = getPermissionGroupOrNull(SimplePermissionReference.getPermissionReference(parent, pg.getName()));
                            if (attempt != null)
                            {
                                permissions.addAll(getImmediateGranteePermissions(attempt));
                            }
                        }
                    }
                }
    
                if (pg.isAllowFullControl())
                {
                    // add all available
                    permissions.addAll(getAllPermissions());
                }
            }
        }
        PermissionGroup baseGroup = getBasePermissionGroupOrNull(getPermissionGroupOrNull(permissionReference));
        if (baseGroup != null)
        {
            for (Permission p : ps.getPermissions())
            {
                for (PermissionReference grantedTo : p.getGrantedToGroups())
                {
                    PermissionGroup base = getBasePermissionGroupOrNull(getPermissionGroupOrNull(grantedTo));
                    if (baseGroup.equals(base))
                    {
                        permissions.add(p);
                    }
                }
            }
        }
    }
    return permissions;
}
 
Example 9
Source File: PermissionModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean hasFull(PermissionReference permissionReference)
{
    if (permissionReference == null)
    {
        return false;
    }
    if(permissionReference.equals(ALL))
    {
        return true;
    }
    PermissionGroup group = getPermissionGroupOrNull(permissionReference);
    if (group == null)
    {
        return false;
    }
    else
    {
        if (group.isAllowFullControl())
        {
            return true;
        }
        else
        {
            if(group.isExtends())
            {
                if (group.getTypeQName() != null)
                {
                    return hasFull(SimplePermissionReference.getPermissionReference(group.getTypeQName(), group.getName()));
                }
                else
                {
                    ClassDefinition classDefinition = dictionaryService.getClass(group.getQName());
                    QName parent;
                    while ((parent = classDefinition.getParentName()) != null)
                    {
                        classDefinition = dictionaryService.getClass(parent);
                        PermissionGroup attempt = getPermissionGroupOrNull(SimplePermissionReference.getPermissionReference(parent, group.getName()));
                        if ((attempt != null) && (attempt.isAllowFullControl()))
                        {
                            return true;
                        }
                    }
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
    }
}