/** * Returns a string representation of this object. * * @return a string representation of this object. */ public String toXMLString() { StringBuilder xmlsb = new StringBuilder(1000); xmlsb .append("<") .append(POLICY_REQUEST) .append(" ") .append(APP_SSOTOKEN) .append("=\"") .append(appSSOToken) .append("\" ") .append(REQUEST_ID) .append("=\"") .append(requestId) .append("\">") .append(CRLF); if (methodID == POLICY_REQUEST_GET_RESOURCE_RESULTS) { xmlsb.append(resourceResultReq.toXMLString()); } else if (methodID == POLICY_REQUEST_ADD_POLICY_LISTENER) { xmlsb.append(policyListenerReq.toXMLString()); } else if (methodID == POLICY_REQUEST_REMOVE_POLICY_LISTENER) { xmlsb.append(removeListenerReq.toXMLString()); } else if (methodID == POLICY_REQUEST_ADVICES_HANDLEABLE_BY_AM_REQUEST) { xmlsb.append(advicesHandleableByAMRequest.toXMLString()); } xmlsb.append("</").append(POLICY_REQUEST).append(">").append(CRLF); return xmlsb.toString(); }
/** * Returns a <code>RemoveListenerRequest</code> object constructed from a XML. * * @param pNode the XML DOM node for the <code>RemoveListenerRequest</code> object. * @return constructed <code>RemoveListenerRequest</code> object. */ public static RemoveListenerRequest parseXML(Node pNode) throws PolicyEvaluationException { RemoveListenerRequest removeListenerReq = new RemoveListenerRequest(); String attr = XMLUtils.getNodeAttributeValue(pNode, SERVICE_NAME); if (attr == null) { debug.error("RemoveListenerRequest: missing attribute " + SERVICE_NAME); String objs[] = {SERVICE_NAME}; throw new PolicyEvaluationException(ResBundleUtils.rbName, "missing_attribute", objs, null); } removeListenerReq.setServiceName(attr); attr = XMLUtils.getNodeAttributeValue(pNode, NOTIFICATION_URL); if (attr == null) { debug.error("RemoveListenerRequest: missing attribute " + NOTIFICATION_URL); String objs[] = {NOTIFICATION_URL}; throw new PolicyEvaluationException(ResBundleUtils.rbName, "missing_attribute", objs, null); } removeListenerReq.setNotificationURL(attr); return removeListenerReq; }
/** * Returns a <code>PolicyRequest</code> object constructed from a XML. * * @param pNode the XML DOM node for the <code>PolicyRequest</code> object. * @return constructed <code>PolicyRequest</code> object */ public static PolicyRequest parseXML(Node pNode) throws PolicyEvaluationException { PolicyRequest preq = new PolicyRequest(); String attr = XMLUtils.getNodeAttributeValue(pNode, APP_SSOTOKEN); if (attr == null) { debug.error("PolicyRequestparseXML(Node): missing attribute " + APP_SSOTOKEN); String objs[] = {APP_SSOTOKEN}; throw new PolicyEvaluationException(ResBundleUtils.rbName, "missing_attribute", objs, null); } preq.setAppSSOToken(attr); attr = XMLUtils.getNodeAttributeValue(pNode, REQUEST_ID); if (attr == null) { debug.error("PolicyRequest.parseXML(Node): missing attribute " + REQUEST_ID); String objs[] = {REQUEST_ID}; throw new PolicyEvaluationException(ResBundleUtils.rbName, "missing_attribute", objs, null); } preq.setRequestId(attr); Node node = XMLUtils.getChildNode(pNode, GET_RESOURCE_RESULTS); if (node != null) { ResourceResultRequest resourceResultReq = null; try { resourceResultReq = ResourceResultRequest.parseXML(node); } catch (PolicyEvaluationException pe) { throw new PolicyEvaluationException(pe, preq.getRequestId()); } preq.setResourceResultRequest(resourceResultReq); preq.setMethodID(POLICY_REQUEST_GET_RESOURCE_RESULTS); return preq; } node = XMLUtils.getChildNode(pNode, ADD_POLICY_LISTENER); if (node != null) { PolicyListenerRequest plr = null; try { plr = PolicyListenerRequest.parseXML(node); } catch (PolicyEvaluationException pe) { throw new PolicyEvaluationException(pe, preq.getRequestId()); } preq.setPolicyListenerRequest(plr); preq.setMethodID(POLICY_REQUEST_ADD_POLICY_LISTENER); return preq; } node = XMLUtils.getChildNode(pNode, REMOVE_POLICY_LISTENER); if (node != null) { RemoveListenerRequest rmListenerReq = null; try { rmListenerReq = RemoveListenerRequest.parseXML(node); } catch (PolicyEvaluationException pe) { throw new PolicyEvaluationException(pe, preq.getRequestId()); } preq.setRemoveListenerRequest(rmListenerReq); preq.setMethodID(POLICY_REQUEST_REMOVE_POLICY_LISTENER); return preq; } node = XMLUtils.getChildNode(pNode, ADVICES_HANDLEABLE_BY_AM_REQUEST); if (node != null) { preq.setAdvicesHandleableByAMRequest(new AdvicesHandleableByAMRequest()); preq.setMethodID(POLICY_REQUEST_ADVICES_HANDLEABLE_BY_AM_REQUEST); return preq; } /* * We reach here, there is no valid method name specified in * the xml docuemnt. Throw exception. */ debug.error("PolicyRequest: invalid method specified"); throw new PolicyEvaluationException( ResBundleUtils.rbName, "invalid_policy_request_method", null, null); }