Exemple #1
0
  private static Tag newTag(String tagType, String tagID, UCMEntity entity, String cgi)
      throws TagException, UnableToCreateEntityException, UCMEntityNotFoundException,
          UnableToGetEntityException, UnableToInitializeEntityException {
    logger.fine("ENTITY=" + entity.toString());
    logger.fine("CGI FOR NEW = " + cgi);
    // System.out.println( "CGI==="+cgi );

    /* Delete any existing Tags with the unique ID */
    logger.fine(
        "Deleting Tags with ID: "
            + tagType
            + tagID
            + " for entity "
            + entity.getFullyQualifiedName());
    deleteTagsWithID(tagType, tagID, entity);

    cgi = "tagtype=" + tagType + "&tagid=" + tagID + (cgi.length() > 0 ? "&" + cgi : "");
    String fqname = storeTag(entity, cgi);

    Tag tag = (Tag) UCMEntity.getEntity(Tag.class, fqname);
    // tag.SetEntry( "tagtype", tagType );
    // tag.SetEntry( "tagid", tagID );
    tag.setKeyValue(cgi);
    tag.setTagEntity(entity);

    return tag;
  }
Exemple #2
0
  private static Tag newTag(UCMEntity entity, String tagType, String tagID)
      throws UnableToInitializeEntityException {
    Tag tag = (Tag) UCMEntity.getEntity(Tag.class, "tag@0@" + entity.getPVob().getName());
    // tag.SetEntry( "tagtype", tagType );
    // tag.SetEntry( "tagid", tagID );
    String cgi = "tagtype=" + tagType + "&tagid=" + tagID;
    tag.setKeyValue(cgi);
    tag.setTagEntity(entity);

    tag.setCreated(true);

    return tag;
  }
Exemple #3
0
  public static Tag getTag(UCMEntity entity, String tagType, String tagID, boolean create)
      throws TagException, UnableToInitializeEntityException, UnableToCreateEntityException,
          UCMEntityNotFoundException, UnableToGetEntityException {
    logger.fine(entity.toString());
    List<Tag> tags = getTags(entity);

    for (Tag t : tags) {
      logger.fine("Current: " + t);
      /* Is it the correct tag? Return it! */
      if (t.getTagType().equals(tagType) && t.getTagID().equals(tagID)) {
        logger.fine("This is it!");
        t.setTagEntity(entity);
        return t;
      }
    }

    logger.fine("Could not find the Tag with ID " + tagType + tagID + ". Creating new.");

    if (create) {
      return newTag(entity, tagType, tagID);
    } else {
      return null;
    }
  }