Ejemplo n.º 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;
  }
Ejemplo n.º 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;
  }
Ejemplo n.º 3
0
  public static List<Tag> getTags(UCMEntity entity)
      throws TagException, UnableToInitializeEntityException {
    logger.fine(entity.toString());

    String cmd = "describe -ahlink " + __TAG_NAME + " -l " + entity;
    CmdResult res = null;
    try {
      res = Cleartool.run(cmd);
    } catch (AbnormalProcessTerminationException e) {
      Matcher match = pattern_hlink_type_missing.matcher(e.getMessage());
      logger.warning("Unable to get tags: " + e.getMessage());
      if (match.find()) {
        logger.fine("Tag type not found");
        // UCM.addMessage( "The Hyperlink type \"" + match.group( 1 ) + "\" was not
        // found.\nInstallation: \"cleartool mkhltype " + __TAG_NAME + " -c \"Hyperlink type for
        // tagging entities\"\"" );
        // throw new UCMException( "ClearCase hyperlink type \"" + match.group( 1 ) + "\" was not
        // found. ", e.getMessage(), UCMType.UNKNOWN_HLINK_TYPE );
        // UCMException ucme = new UCMException( "ClearCase hyperlink type \"" + match.group( 1 ) +
        // "\" was not found. ", e, UCMType.UNKNOWN_HLINK_TYPE );
        // ucme.addInformation(  "The Hyperlink type \"" + match.group( 1 ) + "\" was not
        // found.\nInstallation: \"cleartool mkhltype -global -c \"Hyperlink type for tagging
        // entities\" " + __TAG_NAME + "@" + match.group( 2 ) );
        TagException te = new TagException(entity, "", __TAG_NAME, Type.NO_SUCH_HYPERLINK, e);
        te.addInformation(
            "The Hyperlink type \""
                + match.group(1)
                + "\" was not found.\nInstallation: \"cleartool mkhltype -global -c \"Hyperlink type for tagging entities\" "
                + __TAG_NAME
                + "@"
                + match.group(2));
        throw te;
      } else {
        logger.fine("Something else");
        throw new TagException(entity, "", __TAG_NAME, Type.CREATION_FAILED, e);
      }
    }

    List<String> list = res.stdoutList;

    // List<Tuple<String, String>> tags = new ArrayList<Tuple<String,
    // String>>();
    // List<String[]> tags = new ArrayList<String[]>();

    ArrayList<Tag> tags = new ArrayList<Tag>();

    /* There are tags */
    if (list.size() > 2) {
      for (int i = 2; i < list.size(); i++) {
        logger.fine("[" + i + "]" + list.get(i));

        Matcher match = pattern_tags.matcher(list.get(i));
        if (match.find()) {
          // tags.add( new Tuple<String, String>( match.group( 1 ),
          // match.group( 2 ) ) );
          // tags.add( new String[] { match.group( 1 ), match.group( 2 ) } );

          Tag tag = (Tag) UCMEntity.getEntity(Tag.class, match.group(1).trim());
          tag.setKeyValue(match.group(2));
          tags.add(tag);
        }
      }
    }

    return tags;
  }