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; }
public Collection<PatchItem> getItems(ObjectType obj, IRequestContext rc) throws CollectException { if (!initialized) { scanRevisions(); } PatchObject pObj = (PatchObject) obj; Collection<PatchItem> items = new ArrayList<PatchItem>(); if (error != null) { MessageType msg = Factories.common.createMessageType(); msg.setLevel(MessageLevelEnumeration.ERROR); msg.setValue(error); rc.addMessage(msg); } try { int iBase = Integer.parseInt((String) pObj.getBase().getValue()); switch (pObj.getBase().getOperation()) { case EQUALS: items.addAll(getItems((String) pObj.getBase().getValue())); break; case NOT_EQUAL: for (String base : revisions.keySet()) { if (!base.equals((String) pObj.getBase().getValue())) { items.addAll(getItems(base)); } } break; case LESS_THAN: for (String base : revisions.keySet()) { if (Integer.parseInt(base) < iBase) { items.addAll(getItems(base)); } } break; case LESS_THAN_OR_EQUAL: for (String base : revisions.keySet()) { if (Integer.parseInt(base) <= iBase) { items.addAll(getItems(base)); } } break; case GREATER_THAN: for (String base : revisions.keySet()) { if (Integer.parseInt(base) > iBase) { items.addAll(getItems(base)); } } break; case GREATER_THAN_OR_EQUAL: for (String base : revisions.keySet()) { if (Integer.parseInt(base) >= iBase) { items.addAll(getItems(base)); } } break; case PATTERN_MATCH: Pattern p = StringTools.pattern((String) pObj.getBase().getValue()); for (String base : revisions.keySet()) { if (p.matcher(base).find()) { items.addAll(getItems(base)); } } break; default: String msg = JOVALMsg.getMessage( JOVALMsg.ERROR_UNSUPPORTED_OPERATION, pObj.getBase().getOperation()); throw new CollectException(msg, FlagEnumeration.NOT_COLLECTED); } } catch (NumberFormatException 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); } catch (PatternSyntaxException e) { MessageType msg = Factories.common.createMessageType(); msg.setLevel(MessageLevelEnumeration.ERROR); msg.setValue(JOVALMsg.getMessage(JOVALMsg.ERROR_PATTERN, e.getMessage())); rc.addMessage(msg); session.getLogger().warn(JOVALMsg.getMessage(JOVALMsg.ERROR_EXCEPTION), e); } return items; }
public Collection<XinetdItem> getItems(ObjectType obj, IRequestContext rc) throws CollectException { init(); Collection<XinetdItem> items = new ArrayList<XinetdItem>(); List<Service> list = new ArrayList<Service>(); XinetdObject xObj = (XinetdObject) obj; try { String protocol = (String) xObj.getProtocol().getValue(); OperationEnumeration op = xObj.getProtocol().getOperation(); Pattern p = null; if (op == OperationEnumeration.PATTERN_MATCH) { p = StringTools.pattern(protocol); } for (Service service : services.values()) { String serviceProtocol = ""; try { serviceProtocol = service.getString(Property.PROTOCOL); } catch (NoSuchElementException e) { } switch (op) { case EQUALS: if (protocol.equals(serviceProtocol)) { list.add(service); } break; case CASE_INSENSITIVE_EQUALS: if (protocol.equalsIgnoreCase(serviceProtocol)) { list.add(service); } break; case NOT_EQUAL: if (!protocol.equals(serviceProtocol)) { list.add(service); } break; case PATTERN_MATCH: if (p.matcher(serviceProtocol).find()) { list.add(service); } break; default: String msg = JOVALMsg.getMessage(JOVALMsg.ERROR_UNSUPPORTED_OPERATION, op); throw new CollectException(msg, FlagEnumeration.NOT_COLLECTED); } } String name = (String) xObj.getServiceName().getValue(); op = xObj.getServiceName().getOperation(); if (op == OperationEnumeration.PATTERN_MATCH) { p = StringTools.pattern(name); } for (Service service : list) { String serviceName = service.getName(); switch (op) { case EQUALS: if (name.equals(serviceName)) { items.add(makeItem(service)); } break; case CASE_INSENSITIVE_EQUALS: if (name.equalsIgnoreCase(serviceName)) { items.add(makeItem(service)); } break; case NOT_EQUAL: if (!name.equals(serviceName)) { items.add(makeItem(service)); } break; case PATTERN_MATCH: if (p.matcher(serviceName).find()) { items.add(makeItem(service)); } break; default: String msg = JOVALMsg.getMessage(JOVALMsg.ERROR_UNSUPPORTED_OPERATION, op); throw new CollectException(msg, FlagEnumeration.NOT_COLLECTED); } } } catch (PatternSyntaxException e) { MessageType msg = Factories.common.createMessageType(); msg.setLevel(MessageLevelEnumeration.ERROR); msg.setValue(JOVALMsg.getMessage(JOVALMsg.ERROR_PATTERN, e.getMessage())); rc.addMessage(msg); session.getLogger().warn(JOVALMsg.getMessage(JOVALMsg.ERROR_EXCEPTION), e); } return items; }