Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.XmlWriter


    public String generate( List<PropFindResponse> propFindResponses ) {
        ByteArrayOutputStream responseOutput = new ByteArrayOutputStream();
        Map<String, String> mapOfNamespaces = helper.findNameSpaces( propFindResponses );
        ByteArrayOutputStream generatedXml = new ByteArrayOutputStream();
        XmlWriter writer = new XmlWriter( generatedXml );
        writer.writeXMLHeader();
        writer.open(WebDavProtocol.NS_DAV.getPrefix() ,"multistatus" + helper.generateNamespaceDeclarations( mapOfNamespaces ) );
        writer.newLine();
        helper.appendResponses( writer, propFindResponses, mapOfNamespaces );
        writer.close(WebDavProtocol.NS_DAV.getPrefix(),"multistatus" );
        writer.flush();
//        log.debug( generatedXml.toString() );
        helper.write( generatedXml, responseOutput );
        try {
            return responseOutput.toString( "UTF-8" );
        } catch( UnsupportedEncodingException ex ) {
View Full Code Here


    private final Helper helper = new Helper();

    public String generateXml(List<SchedulingResponseItem> respItems) throws UnsupportedEncodingException {
        log.trace("respondWithSchedulingResults: " + respItems.size());
        ByteArrayOutputStream generatedXml = new ByteArrayOutputStream();
        XmlWriter writer = new XmlWriter(generatedXml);
        writer.writeXMLHeader();
        writer.open(WebDavProtocol.NS_DAV.getPrefix(), "schedule-response " + helper.generateNamespaceDeclarations());
        writer.newLine();
        for (SchedulingResponseItem resp : respItems) {
            Element elResp = writer.begin("C", "response");
            Element elRecip = elResp.begin("C", "recipient");
            elRecip.begin("D", "href").writeText(resp.getRecipient(), false).close();
            elRecip.close();
            StatusResponse stat = resp.getStatus();
            elRecip.begin(CALDAV_PREFIX, "request-status").writeText(stat.code + ";" + stat.description, false).close();
            if (resp.getiCalText() != null) {
                elRecip.begin(CALDAV_PREFIX, "calendar-data").writeText(resp.getiCalText(), false).close();
            }
            elResp.close();
        }

        writer.close(WebDavProtocol.NS_DAV.getPrefix(), "multistatus");
        writer.flush();
//        log.debug( generatedXml.toString() );
        return generatedXml.toString("UTF-8");

    }
View Full Code Here

        private OutputStream out;

        FckGetParams( OutputStream out, Map<String, String> params ) {
            super( params );
            this.out = out;
            writer = new XmlWriter( out );
            command = params.get( "Command" );
            resourceType = params.get( "Type" );
            sFolder = params.get( "CurrentFolder" );
            newFolderName = params.get( "NewFolderName" );
            if( sFolder != null ) {
View Full Code Here

  public void testWriteValue() {
    SupportedLocks locks = new SupportedLocks();
   
   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XmlWriter xmlWriter = new XmlWriter(out);
    LockInfo lockInfo = new LockInfo(LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.READ, null, LockInfo.LockDepth.ZERO);
    LockTimeout lockTimeout = new LockTimeout(1000l);
    LockToken token = new LockToken("abc123", lockInfo, lockTimeout);
    Map<String,String> prefixes = new HashMap<String, String>();
   
    valueWriter.writeValue(xmlWriter, "uri", "ns", "aName", locks, "/test", prefixes);
   
    xmlWriter.flush();
    String xml = out.toString();
    System.out.println(xml);
    System.out.println("---------------------------------");   
   
    // Should look like this:
View Full Code Here

    assertTrue(valueWriter.supports(null, null, LockToken.class));
  }

  public void testWriteValue() {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XmlWriter xmlWriter = new XmlWriter(out);
    LockInfo lockInfo = new LockInfo(LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.READ, null, LockInfo.LockDepth.ZERO);
    LockTimeout lockTimeout = new LockTimeout(1000l);
    LockToken token = new LockToken("abc123", lockInfo, lockTimeout);
    Map<String,String> prefixes = new HashMap<String, String>();
   
    valueWriter.writeValue(xmlWriter, "ns", "pre", "lock", token, "/test", prefixes);
   
    xmlWriter.flush();
    String xml = out.toString();
    System.out.println(xml);
    System.out.println("---------------------------------");
   
    // Should look like this:
View Full Code Here

    public void responseMultiStatus( Resource resource, Response response, Request request, List<HrefStatus> statii ) {
        response.setStatus( Response.Status.SC_MULTI_STATUS );
        response.setDateHeader( new Date() );
        response.setContentTypeHeader( Response.XML );

        XmlWriter writer = new XmlWriter( response.getOutputStream() );
        writer.writeXMLHeader();
        writer.open( "multistatus xmlns:D" + "=\"" + WebDavProtocol.NS_DAV + ":\"" ); // only single namespace for this method
        writer.newLine();
        for( HrefStatus status : statii ) {
            XmlWriter.Element elResponse = writer.begin( "response" ).open();
            writer.writeProperty( "", "href", status.href );
            writer.writeProperty( "", "status", status.status.code + "" );
            elResponse.close();
        }
        writer.close( "multistatus" );
        writer.flush();

    }
View Full Code Here

   */
  public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException {
    String subpath = getFile().getCanonicalPath().substring(factory.getRoot().getCanonicalPath().length()).replace('\\', '/');
    String uri = subpath;
    //String uri = "/" + factory.getContextPath() + subpath;
    XmlWriter w = new XmlWriter(out);
    w.open("html");
    w.open("head");
    w.writeText(""
        + "<script type=\"text/javascript\" language=\"javascript1.1\">\n"
        + "    var fNewDoc = false;\n"
        + "  </script>\n"
        + "  <script LANGUAGE=\"VBSCRIPT\">\n"
        + "    On Error Resume Next\n"
        + "    Set EditDocumentButton = CreateObject(\"SharePoint.OpenDocuments.3\")\n"
        + "    fNewDoc = IsObject(EditDocumentButton)\n"
        + "  </script>\n"
        + "  <script type=\"text/javascript\" language=\"javascript1.1\">\n"
        + "    var L_EditDocumentError_Text = \"The edit feature requires a SharePoint-compatible application and Microsoft Internet Explorer 4.0 or greater.\";\n"
        + "    var L_EditDocumentRuntimeError_Text = \"Sorry, couldnt open the document.\";\n"
        + "    function editDocument(strDocument) {\n"
        + "      if (fNewDoc) {\n"
        + "        if (!EditDocumentButton.EditDocument(strDocument)) {\n"
        + "          alert(L_EditDocumentRuntimeError_Text); \n"
        + "        }\n"
        + "      } else { \n"
        + "        alert(L_EditDocumentError_Text); \n"
        + "      }\n"
        + "    }\n"
        + "  </script>\n");



    w.close("head");
    w.open("body");
    w.begin("h1").open().writeText(this.getName()).close();
    w.open("table");
    for (Resource r : getChildren()) {
      w.open("tr");

      w.open("td");
      String path = buildHref(uri, r.getName());
      w.begin("a").writeAtt("href", path).open().writeText(r.getName()).close();

      w.begin("a").writeAtt("href", "#").writeAtt("onclick", "editDocument('" + path + "')").open().writeText("(edit with office)").close();

      w.close("td");

      w.begin("td").open().writeText(r.getModifiedDate() + "").close();
      w.close("tr");
    }
    w.close("table");
    w.close("body");
    w.close("html");
    w.flush();
  }
View Full Code Here

   * @throws NotAuthorizedException the not authorized exception
   */
  public void sendContent( OutputStream out, Range range, Map<String, String> params, String contentType ) throws IOException, NotAuthorizedException {
    String subpath = getRealFile().getCanonicalPath().substring( factory.getRoot().getCanonicalPath().length() ).replace( '\\', '/' );
    String uri = "/" + factory.getContextPath() + subpath;
    XmlWriter w = new XmlWriter( out );
    w.open( "html" );
    w.open( "body" );
    w.begin( "h1" ).open().writeText( this.getName() ).close();
    w.open( "table" );
    for( Resource r : getChildren() ) {
      w.open( "tr" );

      w.open( "td" );
      w.begin( "a" ).writeAtt( "href", uri + "/" + r.getName() ).open().writeText( r.getName() ).close();
      w.close( "td" );

      w.begin( "td" ).open().writeText( r.getModifiedDate() + "" ).close();
      w.close( "tr" );
    }
    w.close( "table" );
    w.close( "body" );
    w.close( "html" );
    w.flush();
  }
View Full Code Here

  @Override
  public void sendContent( OutputStream out, Range range, Map<String, String> params, String contentType ) throws IOException, NotAuthorizedException {
    String subpath = realFile.getCanonicalPath().substring( factory.getRoot().getCanonicalPath().length() ).replace( '\\', '/' );
    String uri = "/" + factory.getContextPath() + subpath;
    XmlWriter w = new XmlWriter( out );
    w.open( "html" );
    w.open( "body" );
    w.begin( "h1" ).open().writeText( this.getName() ).close();
    w.open( "table" );
    for( Resource r : getChildren() ) {
      w.open( "tr" );

      w.open( "td" );
      w.begin( "a" ).writeAtt( "href", uri + "/" + r.getName() ).open().writeText( r.getName() ).close();
      w.close( "td" );

      w.begin( "td" ).open().writeText( r.getModifiedDate() + "" ).close();
      w.close( "tr" );
    }
    w.close( "table" );
    w.close( "body" );
    w.close( "html" );
    w.flush();
  }
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.XmlWriter

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.