/*
   * (non-Javadoc)
   * @see org.alfresco.repo.security.authority.AuthorityBridgeDAO#getAuthorityBridgeLinks()
   */
  @Override
  public List<AuthorityBridgeLink> getAuthorityBridgeLinks() {
    Long authorityContainerTypeQNameId = Long.MIN_VALUE;
    Pair<Long, QName> authorityContainerTypeQNamePair =
        qnameDAO.getQName(ContentModel.TYPE_AUTHORITY_CONTAINER);
    if (authorityContainerTypeQNamePair != null) {
      authorityContainerTypeQNameId = authorityContainerTypeQNamePair.getFirst();
    }

    Long memberAssocQNameId = Long.MIN_VALUE;
    Pair<Long, QName> memberAssocQNamePair = qnameDAO.getQName(ContentModel.ASSOC_MEMBER);
    if (memberAssocQNamePair != null) {
      memberAssocQNameId = memberAssocQNamePair.getFirst();
    }

    Long authorityNameQNameId = Long.MIN_VALUE;
    Pair<Long, QName> authorityNameQNamePair = qnameDAO.getQName(ContentModel.PROP_AUTHORITY_NAME);
    if (authorityNameQNamePair != null) {
      authorityNameQNameId = authorityNameQNamePair.getFirst();
    }

    // Get tenenat specifc store id
    StoreRef tenantSpecificStoreRef =
        tenantService.getName(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    Long storeId = Long.MIN_VALUE;
    if (tenantSpecificStoreRef != null) {
      Pair<Long, StoreRef> storePair = nodeDAO.getStore(tenantSpecificStoreRef);
      if (storePair != null) {
        storeId = storePair.getFirst();
      }
    }

    return selectAuthorityBridgeLinks(
        authorityContainerTypeQNameId, memberAssocQNameId, authorityNameQNameId, storeId);
  }
  /** Construct from higher-level parameters */
  public NodeParametersEntity(NodeParameters params, QNameDAO qnameDAO) {
    this(qnameDAO);

    this.setFromNodeId(params.getFromNodeId());
    this.setToNodeId(params.getToNodeId());

    this.setFromTxnId(params.getFromTxnId());
    this.setToTxnId(params.getToTxnId());
    this.setTransactionIds(params.getTransactionIds());

    this.setStoreIdentifier(params.getStoreIdentifier());
    this.setStoreProtocol(params.getStoreProtocol());

    // Translate the QNames, if provided
    if (params.getIncludeNodeTypes() != null) {
      Set<Long> qnamesIds = qnameDAO.convertQNamesToIds(params.getIncludeNodeTypes(), false);
      this.setIncludeTypeIds(new ArrayList<Long>(qnamesIds));
    }

    if (params.getExcludeNodeTypes() != null) {
      Set<Long> qnamesIds = qnameDAO.convertQNamesToIds(params.getExcludeNodeTypes(), false);
      this.setExcludeTypeIds(new ArrayList<Long>(qnamesIds));
    }

    if (params.getExcludeAspects() != null) {
      Set<Long> qnamesIds = qnameDAO.convertQNamesToIds(params.getExcludeAspects(), false);
      this.setExcludeAspectIds(new ArrayList<Long>(qnamesIds));
    }

    if (params.getIncludeAspects() != null) {
      Set<Long> qnamesIds = qnameDAO.convertQNamesToIds(params.getIncludeAspects(), false);
      this.setIncludeAspectIds(new ArrayList<Long>(qnamesIds));
    }
  }
 public ChildAssociationRef getRef(QNameDAO qnameDAO) {
   QName typeQName = qnameDAO.getQName(typeQNameId).getSecond();
   QName qname =
       QName.createQName(qnameDAO.getNamespace(qnameNamespaceId).getSecond(), qnameLocalName);
   return new ChildAssociationRef(
       typeQName, parentNode.getNodeRef(), qname, childNode.getNodeRef(), isPrimary, assocIndex);
 }
 /**
  * Helper method to set the {@link #setTypeQNameId(Long)}.
  *
  * @param qnameDAO the DAO to resolve the QName ID
  * @param typeQName the association type
  * @param forUpdate <tt>true</tt> if the QName must exist i.e. this entity will be used for
  *     updates and the type <code>QName</code> <b>must</b> exist.
  * @return <tt>true</tt> if the set worked otherwise <tt>false</tt>
  */
 public boolean setTypeQNameAll(QNameDAO qnameDAO, QName typeQName, boolean forUpdate) {
   if (forUpdate) {
     typeQNameId = qnameDAO.getOrCreateQName(typeQName).getFirst();
     return true;
   } else {
     Pair<Long, QName> qnamePair = qnameDAO.getQName(typeQName);
     if (qnamePair == null) {
       return false;
     } else {
       typeQNameId = qnamePair.getFirst();
       return true;
     }
   }
 }
 private Long getQNameId(QName qname) {
   Pair<Long, QName> qnamePair = qnameDAO.getQName(qname);
   if (qnamePair == null) {
     throw new AlfrescoRuntimeException("QName does not exist: " + qname);
   }
   return qnamePair.getFirst();
 }
示例#6
0
 public void setTypeQName(QNameDAO qnameDAO, QName typeQName) {
   Long typeQNameId = qnameDAO.getOrCreateQName(typeQName).getFirst();
   refWriteLock.lock();
   try {
     setTypeQNameId(typeQNameId);
   } finally {
     refWriteLock.unlock();
   }
 }
示例#7
0
 /**
  * {@inheritDoc}
  *
  * <p>This method is thread-safe and lazily creates the required references, if required.
  */
 public ChildAssociationRef getChildAssocRef(QNameDAO qnameDAO) {
   boolean trashReference = false;
   // first check if it is available
   refReadLock.lock();
   try {
     if (childAssocRef != null) {
       // double check that the parent and child node references match those of our reference
       if (childAssocRef.getParentRef() != parent.getNodeRef()
           || childAssocRef.getChildRef() != child.getNodeRef()) {
         trashReference = true;
       } else {
         // we are sure that the reference is correct
         return childAssocRef;
       }
     }
   } finally {
     refReadLock.unlock();
   }
   // get write lock
   refWriteLock.lock();
   try {
     // double check
     if (childAssocRef == null || trashReference) {
       if (typeQName == null) {
         typeQName = qnameDAO.getQName(this.typeQNameId).getSecond();
       }
       if (qname == null) {
         String qnameNamespace = qnameDAO.getNamespace(qnameNamespaceId).getSecond();
         qname = QName.createQName(qnameNamespace, qnameLocalName);
       }
       childAssocRef =
           new ChildAssociationRef(
               typeQName, parent.getNodeRef(), qname, child.getNodeRef(), this.isPrimary, index);
     }
     return childAssocRef;
   } finally {
     refWriteLock.unlock();
   }
 }
示例#8
0
 public void setQName(QNameDAO qnameDAO, QName qname) {
   String assocQNameNamespace = qname.getNamespaceURI();
   String assocQNameLocalName = qname.getLocalName();
   Long assocQNameNamespaceId = qnameDAO.getOrCreateNamespace(assocQNameNamespace).getFirst();
   Long assocQNameCrc = getCrc(qname);
   // get write lock
   refWriteLock.lock();
   try {
     setQnameNamespaceId(assocQNameNamespaceId);
     setQnameLocalName(assocQNameLocalName);
     setQnameCrc(assocQNameCrc);
   } finally {
     refWriteLock.unlock();
   }
 }
  /**
   * Set all required fields associated with the patch <code>QName</code>.
   *
   * @param forUpdate <tt>true</tt> if the entity is going to be used for a data update i.e. the
   *     <code>QName</code> <b>must</b> exist.
   * @return Returns <tt>true</tt> if the <code>QName</code> namespace exists.
   */
  public boolean setQNameAll(QNameDAO qnameDAO, QName qname, boolean forUpdate) {
    String assocQNameNamespace = qname.getNamespaceURI();
    String assocQNameLocalName = qname.getLocalName();
    Long assocQNameNamespaceId = null;
    if (forUpdate) {
      assocQNameNamespaceId = qnameDAO.getOrCreateNamespace(assocQNameNamespace).getFirst();
    } else {
      Pair<Long, String> nsPair = qnameDAO.getNamespace(assocQNameNamespace);
      if (nsPair == null) {
        // We can't set anything
        return false;
      } else {
        assocQNameNamespaceId = nsPair.getFirst();
      }
    }
    Long assocQNameCrc = getQNameCrc(qname);

    this.qnameNamespaceId = assocQNameNamespaceId;
    this.qnameLocalName = assocQNameLocalName;
    this.qnameCrc = assocQNameCrc;

    // All set correctly
    return true;
  }
示例#10
0
 /** {@inheritDoc} */
 public QName getTypeQName(QNameDAO qnameDAO) {
   refReadLock.lock();
   try {
     if (typeQName != null) {
       return typeQName;
     }
   } finally {
     refReadLock.unlock();
   }
   refWriteLock.lock();
   try {
     typeQName = qnameDAO.getQName(typeQNameId).getSecond();
     return typeQName;
   } finally {
     refWriteLock.unlock();
   }
 }
示例#11
0
 /**
  * {@inheritDoc}
  *
  * <p>This method is thread-safe and lazily creates the required references, if required.
  */
 public QName getQName(QNameDAO qnameDAO) {
   // first check if it is available
   refReadLock.lock();
   try {
     if (qname != null) {
       return qname;
     }
   } finally {
     refReadLock.unlock();
   }
   // get write lock
   refWriteLock.lock();
   try {
     // double check
     if (qname == null) {
       String qnameNamespace = qnameDAO.getNamespace(qnameNamespaceId).getSecond();
       qname = QName.createQName(qnameNamespace, qnameLocalName);
     }
     return qname;
   } finally {
     refWriteLock.unlock();
   }
 }
 /** Public constructor, but not generally useful */
 public NodeParametersEntity(QNameDAO qnameDAO) {
   Pair<Long, QName> qnamePair = qnameDAO.getQName(ContentModel.PROP_ORIGINAL_ID);
   this.setOriginalIdPropQNameId(qnamePair == null ? -1 : qnamePair.getFirst());
 }