コード例 #1
0
  /**
   * Helper method to set all values associated with the {@link #setChildNodeName(String) child node
   * name}.
   *
   * @param dictionaryService the service that determines how the CRC values are generated. If this
   *     is <tt>null</tt> then the CRC values are generated assuming that positive enforcement of
   *     the name constraint is required.
   * @param childNodeName the child node name
   */
  public void setChildNodeNameAll(
      DictionaryService dictionaryService, QName typeQName, String childNodeName) {
    ParameterCheck.mandatory("childNodeName", childNodeName);

    if (dictionaryService != null) {
      ParameterCheck.mandatory("typeQName", typeQName);

      Pair<String, Long> childNameUnique =
          ChildAssocEntity.getChildNameUnique(dictionaryService, typeQName, childNodeName);
      this.childNodeName = childNameUnique.getFirst();
      this.childNodeNameCrc = childNameUnique.getSecond();
    } else {
      String childNameNewLower = childNodeName.toLowerCase();
      this.childNodeName = ChildAssocEntity.getChildNodeNameShort(childNameNewLower);
      this.childNodeNameCrc = ChildAssocEntity.getChildNodeNameCrc(childNameNewLower);
    }
  }
 /** Creates a node with two properties */
 public void makeNode(ContentData contentData) {
   StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
   Long rootNodeId = nodeDAO.newStore(storeRef).getFirst();
   ChildAssocEntity assoc =
       nodeDAO.newNode(
           rootNodeId,
           ContentModel.ASSOC_CHILDREN,
           ContentModel.ASSOC_CHILDREN,
           storeRef,
           null,
           ContentModel.TYPE_CONTENT,
           I18NUtil.getLocale(),
           null,
           null);
   Long nodeId = assoc.getChildNode().getId();
   nodeDAO.addNodeProperty(nodeId, contentQName, contentData);
 }