public Collection<FilesetItem> getItems(ObjectType obj, IRequestContext rc)
      throws CollectException {
    FilesetObject fObj = (FilesetObject) obj;
    Collection<FilesetItem> items = new Vector<FilesetItem>();
    switch (fObj.getFlstinst().getOperation()) {
      case EQUALS:
        try {
          String fileset = SafeCLI.checkArgument((String) fObj.getFlstinst().getValue(), session);
          session.getLogger().trace(JOVALMsg.STATUS_AIX_FILESET, fileset);
          for (String line :
              SafeCLI.multiLine("lslpp -lac '" + fileset + "'", session, IUnixSession.Timeout.M)) {
            if (!line.startsWith("#")) {
              List<String> info = StringTools.toList(StringTools.tokenize(line, ":"));
              if (info.get(0).equals("/etc/objrepos")) {
                FilesetItem item = Factories.sc.aix.createFilesetItem();

                EntityItemStringType flstinst = Factories.sc.core.createEntityItemStringType();
                flstinst.setValue(info.get(1));
                item.setFlstinst(flstinst);

                EntityItemVersionType level = Factories.sc.core.createEntityItemVersionType();
                level.setValue(info.get(2));
                level.setDatatype(SimpleDatatypeEnumeration.VERSION.value());
                item.setLevel(level);

                EntityItemFilesetStateType state =
                    Factories.sc.aix.createEntityItemFilesetStateType();
                state.setValue(info.get(4));
                item.setState(state);

                EntityItemStringType description = Factories.sc.core.createEntityItemStringType();
                description.setValue(info.get(6));
                item.setDescription(description);

                items.add(item);
              }
            }
          }
        } catch (Exception e) {
          MessageType msg = Factories.common.createMessageType();
          msg.setLevel(MessageLevelEnumeration.ERROR);
          msg.setValue(e.getMessage());
          rc.addMessage(msg);
          session.getLogger().warn(JOVALMsg.getMessage(JOVALMsg.ERROR_EXCEPTION), e);
        }
        break;

      default:
        {
          String msg =
              JOVALMsg.getMessage(
                  JOVALMsg.ERROR_UNSUPPORTED_OPERATION, fObj.getFlstinst().getOperation());
          throw new CollectException(msg, FlagEnumeration.NOT_COLLECTED);
        }
    }

    return items;
  }
Exemple #2
0
  /** REMIND: Stops if it encounters any exceptions at all; make this more robust? */
  protected void scanRevisions() {
    try {
      for (String line :
          SafeCLI.multiLine("/usr/bin/showrev -p", session, IUnixSession.Timeout.M)) {
        if (!line.startsWith(PATCH)) {
          continue;
        }
        StringTokenizer tok = null;
        String buff = null;
        int begin, end;

        begin = line.indexOf(PATCH) + PATCH.length();
        end = line.indexOf(OBSOLETES);
        buff = line.substring(begin, end).trim();
        PatchEntry patch = new PatchEntry(buff);

        begin = line.indexOf(OBSOLETES) + OBSOLETES.length();
        end = line.indexOf(REQUIRES);
        buff = line.substring(begin, end).trim();
        ArrayList<PatchEntry> obsoletes = new ArrayList<PatchEntry>();
        tok = new StringTokenizer(buff, ",");
        while (tok.hasMoreTokens()) {
          PatchEntry superceded = new PatchEntry(tok.nextToken().trim());
          obsoletes.add(superceded);
          String obsoleteBase = superceded.getBaseString();
          Collection<SupercedenceEntry> list = supercedence.get(obsoleteBase);
          if (list == null) {
            list = new ArrayList<SupercedenceEntry>();
            supercedence.put(obsoleteBase, list);
          }
          SupercedenceEntry entry = new SupercedenceEntry(superceded, patch);
          if (!list.contains(entry)) {
            list.add(entry);
          }
        }

        begin = line.indexOf(REQUIRES) + REQUIRES.length();
        end = line.indexOf(INCOMPATIBLES);
        buff = line.substring(begin, end).trim();
        ArrayList<PatchEntry> requires = new ArrayList<PatchEntry>();
        tok = new StringTokenizer(buff, ",");
        while (tok.hasMoreTokens()) {
          requires.add(new PatchEntry(tok.nextToken().trim()));
        }

        begin = line.indexOf(INCOMPATIBLES) + INCOMPATIBLES.length();
        end = line.indexOf(PACKAGES);
        buff = line.substring(begin, end).trim();
        ArrayList<PatchEntry> incompatibles = new ArrayList<PatchEntry>();
        tok = new StringTokenizer(buff, ",");
        while (tok.hasMoreTokens()) {
          incompatibles.add(new PatchEntry(tok.nextToken().trim()));
        }

        begin = line.indexOf(PACKAGES) + PACKAGES.length();
        buff = line.substring(begin).trim();
        ArrayList<String> packages = new ArrayList<String>();
        tok = new StringTokenizer(buff, ",");
        while (tok.hasMoreTokens()) {
          packages.add(tok.nextToken().trim());
        }

        RevisionEntry entry =
            new RevisionEntry(patch, obsoletes, requires, incompatibles, packages);
        if (revisions.containsKey(patch.getBaseString())) {
          revisions.get(patch.getBaseString()).add(entry);
        } else {
          Collection<RevisionEntry> list = new ArrayList<RevisionEntry>();
          list.add(entry);
          revisions.put(patch.getBaseString(), list);
        }
      }
    } catch (Exception e) {
      error = e.getMessage();
      session.getLogger().error(JOVALMsg.getMessage(JOVALMsg.ERROR_EXCEPTION), e);
    }
    initialized = true;
  }