org.alfresco.util.EqualsHelper Java Examples

The following examples show how to use org.alfresco.util.EqualsHelper. 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: AuditModelEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof AuditModelEntity)
    {
        AuditModelEntity that = (AuditModelEntity) obj;
        return EqualsHelper.nullSafeEquals(this.id, that.id);
    }
    else
    {
        return false;
    }
}
 
Example #2
Source File: DocumentNavigator.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getElementQName(Object o)
{
    QName qName = ((ChildAssociationRef) o).getQName();
    if(qName == null)
    {
        return "";
    }
    String escapedLocalName = ISO9075.encode(qName.getLocalName());
    if (EqualsHelper.nullSafeEquals(escapedLocalName, qName.getLocalName()))        
    {
        return qName.toString();
    }
    else
    {
        return QName.createQName(qName.getNamespaceURI(), escapedLocalName).toString();
    }
}
 
Example #3
Source File: RepositoryAuthenticationDao.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
{
	String uidBefore = DefaultTypeConverter.INSTANCE.convert(String.class, before.get(ContentModel.PROP_USERNAME));
    String uidAfter = DefaultTypeConverter.INSTANCE.convert(String.class, after.get(ContentModel.PROP_USERNAME));
    if (uidBefore != null && !EqualsHelper.nullSafeEquals(uidBefore, uidAfter))
    {
        NodeRef userNode = getUserOrNull(uidBefore);
        if (userNode != null)
        {
            nodeService.setProperty(userNode, ContentModel.PROP_USER_USERNAME, uidAfter);
            nodeService.moveNode(userNode, nodeService.getPrimaryParent(userNode).getParentRef(),
                    ContentModel.ASSOC_CHILDREN, QName.createQName(ContentModel.USER_MODEL_URI, uidAfter));
            removeAuthenticationFromCache(uidBefore);
        }
    }
    removeAuthenticationFromCache(uidAfter);
}
 
Example #4
Source File: DbNodeServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Ensures name uniqueness for the child and the child association.  Note that nothing is done if the
 * association type doesn't enforce name uniqueness.
 * 
 * @return          Returns <tt>true</tt> if the child association <b>cm:name</b> was written
 */
private boolean setChildNameUnique(Pair<Long, NodeRef> childNodePair, String newName, String oldName)
{
    if (newName == null)
    {
        newName = childNodePair.getSecond().getId();            // Use the node's GUID
    }
    Long childNodeId = childNodePair.getFirst();
    
    if (EqualsHelper.nullSafeEquals(newName, oldName))
    {
        // The name has not changed
        return false;
    }
    else
    {
        nodeDAO.setChildAssocsUniqueName(childNodeId, newName);
        return true;
    }
}
 
Example #5
Source File: AbstractIntegrityEvent.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Compares based on the class of this instance and the incoming instance, before
 * comparing based on all the internal data.  If derived classes store additional
 * data for their functionality, then they should override this.
 */
@Override
public boolean equals(Object obj)
{
    if (obj == null)
        return false;
    else if (this == obj)
        return true;
    else if (this.getClass() != obj.getClass())
        return false;
    // we can safely cast
    AbstractIntegrityEvent that = (AbstractIntegrityEvent) obj;
    return
            EqualsHelper.nullSafeEquals(this.nodeRef, that.nodeRef) &&
            EqualsHelper.nullSafeEquals(this.typeQName, that.typeQName) &&
            EqualsHelper.nullSafeEquals(this.qname, that.qname);
}
 
Example #6
Source File: AuthorityAliasEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof AuthorityAliasEntity)
    {
        AuthorityAliasEntity that = (AuthorityAliasEntity)obj;
        return (EqualsHelper.nullSafeEquals(this.id, that.id));
    }
    else
    {
        return false;
    }
}
 
Example #7
Source File: PermissionEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof PermissionEntity)
    {
        PermissionEntity that = (PermissionEntity)obj;
        return (EqualsHelper.nullSafeEquals(this.typeQnameId, that.typeQnameId) &&
                EqualsHelper.nullSafeEquals(this.name, that.name));
    }
    else
    {
        return false;
    }
}
 
Example #8
Source File: AclMemberEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof AclMemberEntity)
    {
        AclMemberEntity that = (AclMemberEntity)obj;
        return (EqualsHelper.nullSafeEquals(this.id, that.id));
    }
    else
    {
        return false;
    }
}
 
Example #9
Source File: AbstractNodePermissionEntry.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object o)
{
    if (this == o)
    {
        return true;
    }
    if (!(o instanceof AbstractNodePermissionEntry))
    {
        return false;
    }
    AbstractNodePermissionEntry other = (AbstractNodePermissionEntry) o;

    return EqualsHelper.nullSafeEquals(this.getNodeRef(), other.getNodeRef()) &&
           EqualsHelper.nullSafeEquals(this.inheritPermissions(), other.inheritPermissions()) && 
           EqualsHelper.nullSafeEquals(this.getPermissionEntries(), other.getPermissionEntries());
}
 
Example #10
Source File: MimetypeEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof MimetypeEntity)
    {
        MimetypeEntity that = (MimetypeEntity) obj;
        return EqualsHelper.nullSafeEquals(this.mimetype, that.mimetype);
    }
    else
    {
        return false;
    }
}
 
Example #11
Source File: PropertyClassEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof PropertyClassEntity)
    {
        PropertyClassEntity that = (PropertyClassEntity) obj;
        return EqualsHelper.nullSafeEquals(this.javaClass, that.javaClass);
    }
    else
    {
        return false;
    }
}
 
Example #12
Source File: PropertyDoubleValueEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj != null && obj instanceof PropertyDoubleValueEntity)
    {
        PropertyDoubleValueEntity that = (PropertyDoubleValueEntity) obj;
        return EqualsHelper.nullSafeEquals(this.doubleValue, that.doubleValue);
    }
    else
    {
        return false;
    }
}
 
Example #13
Source File: PropertyStringValueEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj != null && obj instanceof PropertyStringValueEntity)
    {
        PropertyStringValueEntity that = (PropertyStringValueEntity) obj;
        return EqualsHelper.nullSafeEquals(this.stringValue, that.stringValue);
    }
    else
    {
        return false;
    }
}
 
Example #14
Source File: PropertyValueEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj != null && obj instanceof PropertyValueEntity)
    {
        PropertyValueEntity that = (PropertyValueEntity) obj;
        return EqualsHelper.nullSafeEquals(this.actualTypeId, that.actualTypeId) &&
               EqualsHelper.nullSafeEquals(this.longValue, that.longValue);
    }
    else
    {
        return false;
    }
}
 
Example #15
Source File: AbstractPropertyValueDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (!(obj instanceof CachePucKey))
    {
        return false;
    }
    CachePucKey that = (CachePucKey) obj;
    return EqualsHelper.nullSafeEquals(this.key1, that.key1) && 
           EqualsHelper.nullSafeEquals(this.key2, that.key2) &&
           EqualsHelper.nullSafeEquals(this.key3, that.key3);
}
 
Example #16
Source File: AclEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof AclEntity)
    {
        AclEntity that = (AclEntity) obj;
        return EqualsHelper.nullSafeEquals(this.id, that.id)
                && EqualsHelper.nullSafeEquals(this.version, that.version);
    }
    else
    {
        return false;
    }
}
 
Example #17
Source File: LocaleEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (obj == null)
    {
        return false;
    }
    else if (obj == this)
    {
        return true;
    }
    else if (!(obj instanceof LocaleEntity))
    {
        return false;
    }
    LocaleEntity that = (LocaleEntity) obj;
    return EqualsHelper.nullSafeEquals(this.localeStr, that.localeStr);
}
 
Example #18
Source File: TenantEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof TenantEntity)
    {
        TenantEntity that = (TenantEntity)obj;
        return (EqualsHelper.nullSafeEquals(this.tenantDomain.toLowerCase(), that.tenantDomain.toLowerCase()));
    }
    else
    {
        return false;
    }
}
 
Example #19
Source File: EncodingEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof EncodingEntity)
    {
        EncodingEntity that = (EncodingEntity) obj;
        return EqualsHelper.nullSafeEquals(this.encoding, that.encoding);
    }
    else
    {
        return false;
    }
}
 
Example #20
Source File: LockEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof LockEntity)
    {
        LockEntity that = (LockEntity) obj;
        return EqualsHelper.nullSafeEquals(this.sharedResourceId, that.sharedResourceId) &&
               EqualsHelper.nullSafeEquals(this.exclusiveResourceId, that.exclusiveResourceId);
    }
    else
    {
        return false;
    }
}
 
Example #21
Source File: ContentDataEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof ContentDataEntity)
    {
        ContentDataEntity that = (ContentDataEntity) obj;
        return EqualsHelper.nullSafeEquals(this.id, that.id);
    }
    else
    {
        return false;
    }
}
 
Example #22
Source File: ContentDataDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected int updateContentUrlEntity(ContentUrlEntity existing, ContentUrlEntity entity)
{
    int ret = 0;

    ContentUrlKeyEntity existingContentUrlKey = existing.getContentUrlKey();
    ContentUrlKeyEntity contentUrlKey = entity.getContentUrlKey();
    contentUrlKey.setContentUrlId(existing.getId());
    if(existingContentUrlKey == null)
    {
        ret = template.insert(INSERT_SYMMETRIC_KEY, contentUrlKey);
    }
    else if (!EqualsHelper.nullSafeEquals(existingContentUrlKey, contentUrlKey))
    {
        ret = template.update(UPDATE_SYMMETRIC_KEY, contentUrlKey);
    }

    return ret;
}
 
Example #23
Source File: SOLRTrackingParameters.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    SOLRTrackingParameters other = (SOLRTrackingParameters) obj;
    return
            EqualsHelper.nullSafeEquals(this.fromCommitTimeInclusive, other.fromCommitTimeInclusive) &&
            EqualsHelper.nullSafeEquals(this.fromIdInclusive, other.fromIdInclusive) &&
            EqualsHelper.nullSafeEquals(this.ids, other.ids) &&
            EqualsHelper.nullSafeEquals(this.toIdExclusive, other.toIdExclusive) &&
            EqualsHelper.nullSafeEquals(this.toCommitTimeExclusive, other.toCommitTimeExclusive) &&
            EqualsHelper.nullSafeEquals(this.deletedTypeQNameId, other.deletedTypeQNameId);
}
 
Example #24
Source File: NodePropertyKey.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (!(obj instanceof NodePropertyKey))
    {
        return false;
    }
    // Compare in order of selectivity
    NodePropertyKey that = (NodePropertyKey) obj;
    return (EqualsHelper.nullSafeEquals(this.qnameId, that.qnameId) &&
            EqualsHelper.nullSafeEquals(this.listIndex, that.listIndex) &&
            EqualsHelper.nullSafeEquals(this.localeId, that.localeId)
            );
}
 
Example #25
Source File: FixedValueLuceneBuilder.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public <Q, S, E extends Throwable> Q buildLuceneIn(LuceneQueryParserAdaptor<Q, S, E> lqpa, Collection<Serializable> values, Boolean not, PredicateMode mode) throws E
{
    boolean in = false;
    for (Serializable value : values)
    {
        if (EqualsHelper.nullSafeEquals(value, value))
        {
            in = true;
            break;
        }
    }

    if (in == !not)
    {
        return lqpa.getMatchAllQuery();
    }
    else
    {
        return lqpa.getMatchNoneQuery();
    }
}
 
Example #26
Source File: TransformationOptionLimits.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj)
    {
        return true;
    }
    else if (obj instanceof TransformationOptionLimits)
    {
        TransformationOptionLimits that = (TransformationOptionLimits) obj;
        return
            EqualsHelper.nullSafeEquals(time, that.time) &&
            EqualsHelper.nullSafeEquals(kbytes, that.kbytes) &&
            EqualsHelper.nullSafeEquals(pages, that.pages);
    }
    else
    {
        return false;
    }
}
 
Example #27
Source File: TestAuthenticationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void invalidateTicket(String ticket) throws AuthenticationException
{
    String userToRemove = null;
    for (String user : userToTicket.keySet())
    {
        String currentTicket = userToTicket.get(user);
        if (EqualsHelper.nullSafeEquals(currentTicket, ticket))
        {
            userToRemove = user;
        }
    }
    if (userToRemove != null)
    {
        userToTicket.remove(userToRemove);
    }

}
 
Example #28
Source File: TestAuthenticationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void validate(String ticket) throws AuthenticationException
{
    String userToSet = null;
    for (String user : userToTicket.keySet())
    {
        String currentTicket = userToTicket.get(user);
        if (EqualsHelper.nullSafeEquals(currentTicket, ticket))
        {
            userToSet = user;
        }
    }
    if (userToSet != null)
    {
        setCurrentUser(userToSet);
    }
    else
    {
        throw new AuthenticationException("Invalid ticket");
    }

}
 
Example #29
Source File: AssociationRef.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Compares:
 * <ul>
 * <li>{@link #sourceRef}</li>
 * <li>{@link #targetRef}</li>
 * <li>{@link #assocTypeQName}</li>
 * </ul>
 */
public boolean equals(Object o)
{
    if (this == o)
    {
        return true;
    }
    if (!(o instanceof AssociationRef))
    {
        return false;
    }
    AssociationRef other = (AssociationRef) o;

    return (EqualsHelper.nullSafeEquals(this.sourceRef, other.sourceRef)
            && EqualsHelper.nullSafeEquals(this.assocTypeQName, other.assocTypeQName)
            && EqualsHelper.nullSafeEquals(this.targetRef, other.targetRef));
}
 
Example #30
Source File: ChildAssociationRef.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Compares:
 * <ul>
 * <li>{@link #assocTypeQName}</li>
 * <li>{@link #parentRef}</li>
 * <li>{@link #childRef}</li>
 * <li>{@link #childQName}</li>
 * </ul>
 */
public boolean equals(Object o)
{
    if (this == o)
    {
        return true;
    }
    if (!(o instanceof ChildAssociationRef))
    {
        return false;
    }
    ChildAssociationRef other = (ChildAssociationRef) o;

    return (EqualsHelper.nullSafeEquals(this.assocTypeQName, other.assocTypeQName)
            && EqualsHelper.nullSafeEquals(this.parentRef, other.parentRef)
            && EqualsHelper.nullSafeEquals(this.childQName, other.childQName)
            && EqualsHelper.nullSafeEquals(this.childRef, other.childRef));
}