Esempio n. 1
0
 private void addClaimType(OMElement parent, String[] claimUris) {
   OMElement element = null;
   // For each and every claim uri, create an <ClaimType/> elem
   for (String attr : claimUris) {
     element =
         parent
             .getOMFactory()
             .createOMElement(
                 new QName("http://schemas.xmlsoap.org/ws/2005/05/identity", "ClaimType", "wsid"),
                 parent);
     element.addAttribute(parent.getOMFactory().createOMAttribute("Uri", null, attr));
   }
 }
Esempio n. 2
0
  public OMElement toOMElement(OMElement element) throws OMException, AxisFault {

    OMFactory factory = element.getOMFactory();

    if (acksTo == null)
      throw new OMException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.acceptNullAcksTo));

    OMNamespace rmNamespace =
        factory.createOMNamespace(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
    OMElement acceptElement =
        factory.createOMElement(Sandesha2Constants.WSRM_COMMON.ACCEPT, rmNamespace);

    acksTo.toOMElement(acceptElement);
    element.addChild(acceptElement);

    return element;
  }
Esempio n. 3
0
  public OMElement toOMElement(OMElement body) throws OMException {

    if (body == null || !(body instanceof SOAPBody))
      throw new OMException(
          SandeshaMessageHelper.getMessage(
              SandeshaMessageKeys.closeSeqResponseCannotBeAddedToNonBody));

    if (identifier == null)
      throw new OMException(
          SandeshaMessageHelper.getMessage(SandeshaMessageKeys.closeSeqResponsePartNullID));

    OMFactory factory = body.getOMFactory();

    OMNamespace rmNamespace =
        factory.createOMNamespace(namespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
    OMElement closeSequenceResponseElement =
        factory.createOMElement(
            Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE, rmNamespace);
    identifier.toOMElement(closeSequenceResponseElement, rmNamespace);
    body.addChild(closeSequenceResponseElement);

    return body;
  }
  public void put(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    Object content = resource.getContent();
    String contentString;
    if (content instanceof String) {
      contentString = (String) content;
    } else {
      contentString = RegistryUtils.decodeBytes((byte[]) content);
    }
    OMElement payload;
    try {
      payload = AXIOMUtil.stringToOM(contentString);
    } catch (XMLStreamException e) {
      String msg = "Unable to serialize resource content";
      log.error(msg, e);
      throw new RegistryException(msg, e);
    }
    OMNamespace namespace = payload.getNamespace();
    String namespaceURI = namespace.getNamespaceURI();
    OMElement definition = payload.getFirstChildWithName(new QName(namespaceURI, "definition"));
    OMElement projectPath =
        definition.getFirstChildWithName(new QName(namespaceURI, "projectPath"));
    String projectMetadataPath = null;
    if (projectPath != null) {
      projectMetadataPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + projectPath.getText();
    }

    Resource metadataResource = requestContext.getRegistry().get(projectMetadataPath);

    String remainingWork = metadataResource.getProperty("Remaining Work");
    String scheduledWork = metadataResource.getProperty("Scheduled Work");
    String actualWork = metadataResource.getProperty("Actual Work");

    String remainingCost = metadataResource.getProperty("Remaining Cost");
    String scheduledCost = metadataResource.getProperty("Scheduled Cost");
    String actualCost = metadataResource.getProperty("Actual Cost");

    String duration = metadataResource.getProperty("Duration");
    String startDate = metadataResource.getProperty("Start Date");
    String endDate = metadataResource.getProperty("Finish Date");

    OMFactory factory = payload.getOMFactory();
    OMElement work = payload.getFirstChildWithName(new QName(namespaceURI, "work"));
    if (work == null) {
      work = factory.createOMElement("work", namespace, payload);
    }
    OMElement remainingWorkElement =
        work.getFirstChildWithName(new QName(namespaceURI, "remaining"));
    if (remainingWorkElement == null) {
      remainingWorkElement = factory.createOMElement("remaining", namespace, work);
    }
    remainingWorkElement.setText(remainingWork);
    OMElement actualWorkElement = work.getFirstChildWithName(new QName(namespaceURI, "actual"));
    if (actualWorkElement == null) {
      actualWorkElement = factory.createOMElement("actual", namespace, work);
    }
    actualWorkElement.setText(remainingWork);
    OMElement scheduledWorkElement =
        work.getFirstChildWithName(new QName(namespaceURI, "scheduled"));
    if (scheduledWorkElement == null) {
      scheduledWorkElement = factory.createOMElement("scheduled", namespace, work);
    }
    scheduledWorkElement.setText(remainingWork);

    OMElement cost = payload.getFirstChildWithName(new QName(namespaceURI, "cost"));
    if (cost == null) {
      cost = factory.createOMElement("cost", namespace, payload);
    }
    OMElement remainingCostElement =
        cost.getFirstChildWithName(new QName(namespaceURI, "remaining"));
    if (remainingCostElement == null) {
      remainingCostElement = factory.createOMElement("remaining", namespace, cost);
    }
    remainingCostElement.setText(remainingCost);
    OMElement actualCostElement = cost.getFirstChildWithName(new QName(namespaceURI, "actual"));
    if (actualCostElement == null) {
      actualCostElement = factory.createOMElement("actual", namespace, cost);
    }
    actualCostElement.setText(remainingCost);
    OMElement scheduledCostElement =
        cost.getFirstChildWithName(new QName(namespaceURI, "scheduled"));
    if (scheduledCostElement == null) {
      scheduledCostElement = factory.createOMElement("scheduled", namespace, cost);
    }
    scheduledCostElement.setText(remainingCost);

    OMElement timeline = payload.getFirstChildWithName(new QName(namespaceURI, "timeline"));
    if (timeline == null) {
      timeline = factory.createOMElement("timeline", namespace, payload);
    }
    OMElement durationElement = timeline.getFirstChildWithName(new QName(namespaceURI, "duration"));
    if (durationElement == null) {
      durationElement = factory.createOMElement("duration", namespace, timeline);
    }
    durationElement.setText(duration);
    OMElement startDateElement =
        timeline.getFirstChildWithName(new QName(namespaceURI, "startDate"));
    if (startDateElement == null) {
      startDateElement = factory.createOMElement("startDate", namespace, timeline);
    }
    startDateElement.setText(startDate);
    OMElement endDateElement = timeline.getFirstChildWithName(new QName(namespaceURI, "endDate"));
    if (endDateElement == null) {
      endDateElement = factory.createOMElement("endDate", namespace, timeline);
    }
    endDateElement.setText(endDate);

    resource.setContent(payload.toString());
  }