Package org.cipango.kaleo.xcap.dao

Examples of org.cipango.kaleo.xcap.dao.XmlResource


    */
  }
 
  public void testValid() throws Exception {
    XcapResourceImpl resource = _xcapService.getResource(new XcapUri(VALID_PRES_RULES_URI, "/"), false, HEAD, null);
    XmlResource xmlResource = resource.getSelectedResource();

    log.info("Selected node:\n" + new String(xmlResource.getBytes()));
    assertEquals(EXPECTED_RESULT,  new String(xmlResource.getBytes()));
    assertEquals("thomas@cipango.org", resource.getXcapUri().getUser());
  }
View Full Code Here


    assertEquals("thomas@cipango.org", resource.getXcapUri().getUser());
  }
 
  public void testValid2() throws Exception {
    XcapResourceImpl resource = _xcapService.getResource(new XcapUri(VALID_PRES_RULES_URI_3, "/"), false, HEAD, null);
    XmlResource xmlResource = resource.getSelectedResource();
    log.info("Selected node:\n" + new String(xmlResource.getBytes()));
    assertEquals("allow",  xmlResource.getDom().getFirstChild().getNodeValue());
  }
View Full Code Here

    assertEquals("allow",  xmlResource.getDom().getFirstChild().getNodeValue());
  }
 
  public void testGetAttribute() throws Exception {
    XcapResourceImpl resource = _xcapService.getResource(new XcapUri(GET_ATTRIBUTE, "/"), false, HEAD, null);
    XmlResource xmlResource = resource.getSelectedResource();
    //log.info("Selected attribute:\n" + xmlResource.getContent());
    assertEquals("a", ((Attr) xmlResource.getDom()).getNodeValue());
  }
View Full Code Here

    XcapResourceImpl resource = new XcapResourceImpl();

    resource.setXcapUri(xcapUri);
    resource.setProcessor(processor);

    XmlResource xmlResource = _dao.getDocument(xcapUri, isPut && !xcapUri.hasNodeSeparator());
   
    if (xmlResource == null)
    {
      if (isPut)
      {
        locatingParent(xcapUri, requestUrlHead);
        resource.setCreation(true);
        return resource;
      }
      else
      {
        XcapException e = new XcapException("Resource: "
            + xcapUri.getDocumentSelector() + " not found",
            HttpServletResponse.SC_NOT_FOUND);
        e.setLevel(Level.INFO);
        throw e;
      }
    }
    resource.setDocument(xmlResource);
    // TODO check rootDirectory is in parent dir.

    // TODO authenticate & authorization

    if (_validateOnGet)
    {
      try
      {
        XcapUtil.validate(document, processor.getXsdSchema());
      }
      catch (XcapException e)
      {
        _log.warn("Unable to validated document:" + e.getMessage(), e);
      }
    }

    if (resource.isAllDocument())
      return resource;
   

    String nodeSelector = XcapUtil.insertDefaultNamespace(xcapUri
        .getNodeSelector(), processor.getDefaultNamespacePrefix());

    if (_log.isDebugEnabled())
      _log.debug("select node " + nodeSelector + " in "
          + xcapUri.getDocumentSelector());

    if (requestNamespaceContext == null)
      requestNamespaceContext = new HashMap<String, String>();
    requestNamespaceContext.putAll(processor.getNamespaceContext());

    resource.setNamespaceContext(requestNamespaceContext);
   
    XmlResource xmlResource2 = _dao.getNode(resource, nodeSelector);

    if (xmlResource2 == null)
    {
      if (isPut)
      {
View Full Code Here

    }
  }

  private String getFirstExistNodeAncestor(XcapResource resource, String nodeSelector) throws XcapException
  {
    XmlResource xmlResource = _dao.getNode(resource, nodeSelector);
    if (xmlResource != null)
      return nodeSelector;
    else
    {
      int index = nodeSelector.lastIndexOf('/');
View Full Code Here

      response.getOutputStream().write(
          resource.getDocument().getBytes());
    }
    else
    {
      XmlResource selectedResource = resource.getSelectedResource();
      switch (resource.getNodeType())
      {
      case ATTRIBUTE:
        response.getOutputStream().write(((Attr) selectedResource.getDom()).getValue().getBytes());
        break;
      case ELEMENT:
        response.getOutputStream().write(selectedResource.getBytes());
        break;
      case NAMESPACE:     
        Node node = selectedResource.getDom();
        String prefix = "<" + node.getNodeName() + " ";
        response.getOutputStream().write(prefix.getBytes());
        response.getOutputStream().write(node.getNamespaceURI().getBytes());
        response.getOutputStream().write("/>".getBytes());
        break;
View Full Code Here

    try
    {
      // boolean match =
      // resource.getSelectedNode().matches(resource.getNodeSelector());
     
      XmlResource xmlResource = _dao.getNode(resource);
      boolean valid = false;
      if (xmlResource == null)
      {
        valid = resource.getAction().equals(DELETE);
      }
      else
      {
        Node node = xmlResource.getDom();
        valid = node.equals(resource.getSelectedResource().getDom())
            && resource.getAction().equals(PUT);
      }
      if (!valid)
      {
View Full Code Here

TOP

Related Classes of org.cipango.kaleo.xcap.dao.XmlResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.