Package org.wymiwyg.wrhapi.util

Examples of org.wymiwyg.wrhapi.util.MessageBody2Read


        }
      } else {
        // login
        if (!loginValid(username, password)) {
          response.setResponseStatus(ResponseStatus.FORBIDDEN);
          response.setBody(new MessageBody2Read() {

            public ReadableByteChannel read() throws IOException {
              return Channels
                  .newChannel(new ByteArrayInputStream(
                      "LOGIN INVALID".getBytes()));
View Full Code Here


            final Literal literaInfoBit = (Literal) infoBitNode;
            infoDiscoBitURIs.put(infoDiscoResource.getURI(),
                new InfoBit() {

                  public MessageBody getContent() {
                    return new MessageBody2Read() {

                      public ReadableByteChannel read()
                          throws IOException {
                        // TODO Auto-generated method
                        // stub
                        return Channels
                            .newChannel(new ByteArrayInputStream(
                                literaInfoBit
                                    .getString()
                                    .getBytes(
                                        "utf-8")));
                      }

                    };
                  }

                  public String getMimeTypeString() {
                    return "application/xhtml+xml";
                  }

                });
          } else {
            final Resource literaInfoBit = (Resource) infoBitNode;
            infoDiscoBitURIs.put(infoDiscoResource.getURI(),
                new InfoBit() {

                  public MessageBody getContent() {
                    return new MessageBody2Read() {

                      public ReadableByteChannel read()
                          throws IOException {
                        // TODO Auto-generated method
                        // stub
View Full Code Here

      //log.info("getting stream from"+fileName+" in "+pathNode+"("+resultNode+")");
      dataInputStream = resultNode.getInputStream();
    } catch (IOException e) {
      throw new HandlerException(e);
    }
    response.setBody(new MessageBody2Read() {

      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(dataInputStream);
      }
     
View Full Code Here

        storeView.revokeGraph(origGraph);
        storeView.assertGraph(new FCAGraphImpl(editableModel));
      }

    });
    response.setBody(new MessageBody2Read() {
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(PutInfoBitHandler.class.getResourceAsStream("put-info-bit-response.xhtml"));
      }
    });
View Full Code Here

        }
        throw new RuntimeException(e);
      } catch (AccessControlException e) {
        response.setResponseStatus(ResponseStatus.FORBIDDEN);
        log.info(e);
        response.setBody(new MessageBody2Read() {
 
          public ReadableByteChannel read() throws IOException {
            return Channels.newChannel(new ByteArrayInputStream("ACCESS DENIED".getBytes()));
          }
         
View Full Code Here

    uri.setQuery("name="+queryParam);
    request.setRequestURI(uri);
    String[] headervalues = new String[1];
    headervalues[0]="text/plain";
    request.setHeader(HeaderName.CONTENT_TYPE, headervalues);
    MessageBody messageBody = new MessageBody2Read() {

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(new ByteArrayInputStream(bodyString.getBytes()));
      }
View Full Code Here

    uri.setPath("/reader");
    request.setRequestURI(uri);
    request.setMethod(Method.POST);
    String[] type = {TEST_BLA_TYPE};
    request.setHeader(HeaderName.CONTENT_TYPE, type);
    request.setMessageBody(new MessageBody2Read() {

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(new ByteArrayInputStream("body".getBytes()));
      }
View Full Code Here

        new HidingWriter(), new MyResource());
    Request requestMock = EasyMock.createNiceMock(Request.class);
    final Response responseMock = EasyMock.createNiceMock(Response.class);
   
    makeThreadSafe(responseMock, true);
    final MessageBody body = new MessageBody2Read() {

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(new ByteArrayInputStream(hiddenEntity.getBytes()));
      }
View Full Code Here

    response.setResponseStatus(ResponseStatus.UNAUTHORIZED);
    response.addHeader(HeaderName.WWW_AUTHENTICATE,
        "Basic realm=\"Clerezza Platform authentication needed\"");
    final java.io.InputStream pipedIn = new ByteArrayInputStream(message.getBytes());
    response.setHeader(HeaderName.CONTENT_LENGTH, message.getBytes().length);
    response.setBody(new MessageBody2Read() {

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(pipedIn);
      }
View Full Code Here

    // Serialize testObj
    final ByteArrayOutputStream bous = new ByteArrayOutputStream();
    ObjectOutput out = new ObjectOutputStream(bous);
    out.writeObject(testObj);
    out.close();
    MessageBody body = new MessageBody2Read() {

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(new ByteArrayInputStream(bous.toByteArray()));
      }
View Full Code Here

TOP

Related Classes of org.wymiwyg.wrhapi.util.MessageBody2Read

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.