Package org.jclouds.openstack.swift.v1.domain

Examples of org.jclouds.openstack.swift.v1.domain.SwiftObject$Builder


   private String name = getClass().getSimpleName();
   private String containerName = getClass().getSimpleName() + "Container";

   public void signForPublicAccess() throws Exception {
      for (String regionId : api.getConfiguredRegions()) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);

         long expires = System.currentTimeMillis() / 1000 + 5;
         String signature = TemporaryUrlSigner.checkApiEvery(api.getAccountApiForRegion(regionId), 5)
               .sign("GET", object.getUri().getPath(), expires);

         URI signed = URI.create(format("%s?temp_url_sig=%s&temp_url_expires=%s", object.getUri(), signature, expires));

         InputStream publicStream = signed.toURL().openStream();
         assertEquals(Strings2.toStringAndClose(publicStream), "swifty");

         // let it expire
View Full Code Here


   private void getObject() {
      System.out.format("Get Object%n");

      ObjectApi objectApi = cloudFiles.getObjectApiForRegionAndContainer(REGION, CONTAINER);
      SwiftObject object = objectApi.get("uploadObjectFromFile.txt", GetOptions.NONE);

      System.out.format("  %s%n", object);
   }
View Full Code Here

      for (String regionId : regions) {
         assertNotNull(api.getContainerApiForRegion(regionId).create(containerName));
         assertNotNull(api.getObjectApiForRegionAndContainer(regionId, containerName).put(objectName, PAYLOAD));

         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(objectName);
         assertEquals(object.getName(), objectName);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");

         api.getObjectApiForRegionAndContainer(regionId, containerName).delete(objectName);
         api.getContainerApiForRegion(regionId).deleteIfEmpty(containerName);
      }
   }
View Full Code Here

         ObjectApi srcApi = api.getObjectApiForRegionAndContainer(regionId, sourceContainer);
         ObjectApi destApi = api.getObjectApiForRegionAndContainer(regionId, destinationContainer);

         // Create source object
         assertNotNull(srcApi.put(sourceObjectName, PAYLOAD));
         SwiftObject sourceObject = srcApi.get(sourceObjectName);
         checkObject(sourceObject);

         // Create the destination object
         assertNotNull(destApi.put(destinationObject, PAYLOAD));
         SwiftObject object = destApi.get(destinationObject);
         checkObject(object);

         // check the copy operation
         assertTrue(destApi.copy(destinationObject, sourceContainer, sourceObjectName));
         assertNotNull(destApi.get(destinationObject));

         // now get a real SwiftObject
         SwiftObject destSwiftObject = destApi.get(destinationObject);
         assertEquals(toStringAndClose(destSwiftObject.getPayload().openStream()), "swifty");

         // test exception thrown on bad source name
         try {
            destApi.copy(destinationObject, badSource, sourceObjectName);
            fail("Expected CopyObjectException");
View Full Code Here

      }
   }

   public void testMetadata() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);
         assertEquals(object.getName(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");
      }
   }
View Full Code Here

         ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, containerName);

         Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
         assertTrue(objectApi.updateMetadata(name, meta));

         SwiftObject object = objectApi.get(name);
         for (Entry<String, String> entry : meta.entrySet()) {
            // note keys are returned in lower-case!
            assertEquals(object.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue(),
                  object + " didn't have metadata: " + entry);
         }
      }
   }
View Full Code Here

      }
   }

   public void testGet() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name, GetOptions.NONE);
         assertEquals(object.getName(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");
      }
   }
View Full Code Here

      }
   }

   public void testPrivateByDefault() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);
         try {
            object.getUri().toURL().openStream();
            fail("shouldn't be able to access " + object);
         } catch (IOException expected) {
         }
      }
   }
View Full Code Here

      }
   }

   public void testGetOptions() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name, tail(1));
         assertEquals(object.getName(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "y");
      }
   }
View Full Code Here

   }

   public void testListOptions() throws Exception {
      String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName)
               .list(marker(lexicographicallyBeforeName)).get(0);
         assertEquals(object.getName(), name);
         checkObject(object);
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.swift.v1.domain.SwiftObject$Builder

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.