Example #1
0
  private static void deleteTagsWithID(String tagType, String tagID, UCMEntity entity)
      throws TagException, UnableToInitializeEntityException {
    logger.fine(tagType + tagID);

    List<Tag> list = getTags(entity);
    logger.fine(list.size() + " Tags!");

    for (Tag t : list) {
      logger.fine("Testing " + t.getTagType() + " > " + t.getTagID());

      if (t.getTagID().matches("^.*tagtype=" + tagType + ".*$")
          && t.getTagID().matches("^.*tagid=" + tagID + ".*$")) {
        String cmd = "rmhlink " + t.getTagType();
        try {
          Cleartool.run(cmd);
        } catch (AbnormalProcessTerminationException e) {
          // throw new UCMException( "Unable to delete tag with " + tagID + ": " + e.getMessage() );
          throw new TagException(entity, "", __TAG_NAME, Type.DELETION_FAILED, e);
        }
      }
    }
  }
Example #2
0
  public static Tag persist(Tag tag)
      throws TagException, UnableToCreateEntityException, UnableToLoadEntityException,
          UCMEntityNotFoundException, UnableToGetEntityException,
          UnableToInitializeEntityException {
    /* Make the new tag */
    Tag newtag =
        Tag.newTag(
            tag.getTagType(),
            tag.getTagID(),
            tag.getTagEntity(),
            Tag.mapToCGI(tag.GetEntries(), true));

    /* Delete the old tag */
    delete(tag);

    return newtag;
  }
Example #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;
    }
  }