Package org.jclouds.io

Examples of org.jclouds.io.Payload.openStream()


         // exercise create data object with none cdmi put with payload string.
         value = "Hello CDMI World non-cdmi String";
         dataNonCDMIContentTypeApi.create(dataObjectNameIn, value);
         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn);
         assertNotNull(payloadOut);
         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value);

         payloadIn = newPayload(value);
         payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata()
                  .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build()));
         dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn);
View Full Code Here


                  .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build()));
         dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn);

         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn);
         assertNotNull(payloadOut);
         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value);

         dataObject = dataNonCDMIContentTypeApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), "/" + containerName);
View Full Code Here

         assertEquals(dataObject.getObjectType(), "application/cdmi-object");
         assertEquals(dataObject.getParentURI(), "/" + containerName);
         assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true);
         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn);
         assertNotNull(payloadOut);
         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value);

         dataNonCDMIContentTypeApi.delete(dataObjectNameIn);
         assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false);

         // exercise create data object with none cdmi put with payload file.
View Full Code Here

         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn);
         assertNotNull(payloadOut);
         // assertEquals(Strings2.toString(payloadOut), value);
         // byte[] _bytes = ByteStreams.toByteArray(payloadOut);
         tmpFileOut = new File(Files.createTempDir(), "temp.txt");
         is = payloadOut.openStream();
         try {
            Files.asByteSink(tmpFileOut).writeFrom(is);
         } finally {
            Closeables.closeQuietly(is);
         }
View Full Code Here

         System.out.println(containerApi.get(containerName));
         // note dataApi.get when the data object is not a string
         payloadOut = dataNonCDMIContentTypeApi.getValue(inFile.getName());
         assertNotNull(payloadOut);
         tmpFileOut = new File(Files.createTempDir(), "temp.jpg");
         is = payloadOut.openStream();
         try {
            Files.asByteSink(tmpFileOut).writeFrom(is);
         } finally {
            Closeables.closeQuietly(is);
         }
View Full Code Here

         dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn);
         System.out.println(containerApi.get(containerName));
         payloadOut = dataNonCDMIContentTypeApi.getValue(inFile.getName());
         assertNotNull(payloadOut);
         tmpFileOut = new File(Files.createTempDir(), "temp.jpg");
         is = payloadOut.openStream();
         try {
            Files.asByteSink(tmpFileOut).writeFrom(is);
         } finally {
            Closeables.closeQuietly(is);
         }
View Full Code Here

                  .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build()));
         dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn);

         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=0-10");
         assertNotNull(payloadOut);
         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value.substring(0, 11));
         assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(11));

         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=11-20");
         assertNotNull(payloadOut);
         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value.substring(11, 21));
View Full Code Here

         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value.substring(0, 11));
         assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(11));

         payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=11-20");
         assertNotNull(payloadOut);
         assertEquals(Strings2.toStringAndClose(payloadOut.openStream()), value.substring(11, 21));
         assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(10));

         dataNonCDMIContentTypeApi.delete(dataObjectNameIn);
         assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false);
View Full Code Here

            throw new EntityNotFoundException( entityReference );
        }
        InputStream input = null;
        try
        {
            input = payload.openStream();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Inputs.byteBuffer( input, 4096 ).transferTo( Outputs.byteBuffer( baos ) );
            return new StringReader( baos.toString( "UTF-8" ) );
        }
        catch( IOException ex )
View Full Code Here

                                    throw new EntityNotFoundException( parseEntityReference( stored.getName() ) );
                                }
                                InputStream input = null;
                                try
                                {
                                    input = payload.openStream();
                                    receiver.receive( new InputStreamReader( input, "UTF-8" ) );
                                }
                                finally
                                {
                                    if( input != null )
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.