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

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


      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi api = cdmiContext.getApi().getApi();

      Logger.getAnonymousLogger().info("create: " + pContainerName);

      Container container = api.create(pContainerName, pCreateContainerOptions);
      assertNotNull(container);
      try {
         System.out.println(container);
         Logger.getAnonymousLogger().info("get: " + pContainerName);
         container = api.get(pContainerName);
         assertNotNull(container);
         System.out.println(container);
         assertEquals(container.getObjectType(), ObjectTypes.CONTAINER);
         assertNotNull(container.getObjectID());
         assertNotNull(container.getObjectName());
         assertEquals(container.getObjectName(), pContainerName);
         assertEquals(container.getParentURI(), "/");
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);
         System.out.println("Children: " + container.getChildren());
         assertNotNull(container.getMetadata());
         System.out.println("Raw metadata: " + container.getMetadata());
         for (Map.Entry<String, JsonBall> entry : container.getMetadata().entrySet()) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
         }
         assertNotNull(container.getUserMetadata());
         Map<String, String> pContainerMetaDataOut = container.getUserMetadata();
         for (Map.Entry<String, String> entry : pContainerMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(pContainerMetaDataOut.containsKey(key), true);
            assertEquals(pContainerMetaDataOut.get(key), entry.getValue());
         }
         System.out.println("UserMetaData: " + container.getUserMetadata());
         assertNotNull(container.getSystemMetadata());
         System.out.println("SystemMetaData: " + container.getSystemMetadata());
         assertNotNull(container.getACLMetadata());
         List<Map<String, String>> aclMetadataOut = container.getACLMetadata();
         System.out.println("ACLMetaData: ");
         for (Map<String, String> aclMap : aclMetadataOut) {
            System.out.println(aclMap);
         }
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), true);
         container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI"));
         assertNotNull(container);
         assertEquals(container.getParentURI(), "/");
         System.out.println(container);

         container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI").field("objectName"));
         assertNotNull(container);
         assertEquals(container.getParentURI(), "/");
         assertEquals(container.getObjectName(), pContainerName);

         container = api.get(pContainerName, ContainerQueryParams.Builder.metadata());
         assertNotNull(container);
         pContainerMetaDataOut = container.getUserMetadata();
         for (Map.Entry<String, String> entry : pContainerMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(pContainerMetaDataOut.containsKey(key), true);
            assertEquals(pContainerMetaDataOut.get(key), entry.getValue());
         }
         System.out.println(container);

         System.out.println("GetContainerOptions.Builder.metadata(cdmi_acl)");
         container = api.get(pContainerName, ContainerQueryParams.Builder.metadata("cdmi_acl"));
         assertNotNull(container);
         System.out.println(container);
         assertNotNull(container.getACLMetadata());
         assertEquals(container.getACLMetadata().size(), 3);

         System.out.println("adding containers to container");
         String firstParentURI = api.get(pContainerName).getObjectName();
         for (int i = 0; i < 10; i++) {
            container = api.create(firstParentURI + "childcontainer" + i + "/");
            assertNotNull(container);
            assertEquals(container.getParentURI(), pContainerName);
            assertEquals(container.getObjectName(), "childcontainer" + i + "/");
            container = api.create(container.getParentURI() + container.getObjectName() + "grandchild/",
                     pCreateContainerOptions);
            assertEquals(container.getParentURI(), pContainerName + "childcontainer" + i + "/");
            assertEquals(container.getObjectName(), "grandchild" + "/");
            container = api.get(container.getParentURI(), ContainerQueryParams.Builder.children());
            assertEquals(container.getChildren().contains("grandchild" + "/"), true);
         }
         container = api.get(pContainerName, ContainerQueryParams.Builder.children());
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 10);
         container = api.get(pContainerName, ContainerQueryParams.Builder.children(0, 3));
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 4);

         container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI").field("objectName")
                  .children().metadata());
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 10);
         assertEquals(container.getParentURI(), "/");
         assertEquals(container.getObjectName(), pContainerName);
         assertEquals(container.getParentURI(), "/");
         assertEquals(container.getACLMetadata().size(), 3);
         for (String childName : container.getChildren()) {
            api.delete(container.getObjectName() + childName);
         }
         assertEquals(api.get(pContainerName, ContainerQueryParams.Builder.children()).getChildren().isEmpty(), true);

      } finally {
         Logger.getAnonymousLogger().info("delete: " + pContainerName);
         api.delete(pContainerName);
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), false);
      }

   }
View Full Code Here


      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi containerApi = cdmiContext.getApi().getApi();
      DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName);
      Logger.getAnonymousLogger().info("create: " + containerName);
      Container container = containerApi.create(containerName, pCreateContainerOptions);
      try {
         assertNotNull(container);
         System.out.println(container);
         container = containerApi.get(containerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);

         // exercise create data object with value mimetype and metadata
         value = "Hello CDMI data object with value mimetype and metadata";
         pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain")
                  .metadata(pDataObjectMetaDataIn);
View Full Code Here

      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi containerApi = cdmiContext.getApi().getApi();
      DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName);
      Logger.getAnonymousLogger().info("create: " + containerName);
      Container container = containerApi.create(containerName, pCreateContainerOptions);
      try {
         assertNotNull(container);
         System.out.println(container);
         container = containerApi.get(containerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);

         // exercise create data object with value mimetype and metadata
         value = "Hello CDMI data object with value mimetype and metadata";
         pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain")
                  .metadata(pDataObjectMetaDataIn);
         dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions);
         assertNotNull(dataObject);
         dataObject = dataApi.get(dataObjectNameIn);
         assertNotNull(dataObject);
         System.out.println(dataObject);
         System.out.println("value: " + dataObject.getValueAsString());
         assertEquals(dataObject.getMimetype(), "text/plain");
         assertEquals(dataObject.getValueAsString(), value);
         dataObjectMetaDataOut = dataObject.getUserMetadata();
         assertNotNull(dataObjectMetaDataOut);
         for (Map.Entry<String, String> entry : pDataObjectMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(dataObjectMetaDataOut.containsKey(key), true);
            assertEquals(dataObjectMetaDataOut.get(key), entry.getValue());
         }
         assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);
         assertEquals(dataObject.getObjectType(), "application/cdmi-object");
         assertEquals(dataObject.getParentURI(), "/" + containerName);
         assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true);

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")
                  .field("objectName"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")
                  .field("objectName").field("mimetype"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);
         assertEquals(dataObject.getMimetype(), "text/plain");

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")
                  .field("objectName").field("mimetype").metadata());
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);
         assertEquals(dataObject.getMimetype(), "text/plain");
         dataObjectMetaDataOut = dataObject.getUserMetadata();
         assertNotNull(dataObjectMetaDataOut);
         for (Map.Entry<String, String> entry : pDataObjectMetaDataIn.entrySet()) {
View Full Code Here

      ContainerApi containerApi = cdmiContext.getApi().getApi();
      DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName);
      DataNonCDMIContentTypeApi dataNonCDMIContentTypeApi = cdmiContext.getApi()
               .getDataNonCDMIContentTypeApiForContainer(containerName);
      Logger.getAnonymousLogger().info("create: " + containerName);
      Container container = containerApi.create(containerName, pCreateContainerOptions);
      try {

         assertNotNull(container);
         System.out.println(container);
         container = containerApi.get(containerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);

         // 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);
View Full Code Here

      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi api = cdmiContext.getApi().getApi();

      Logger.getAnonymousLogger().info("create: " + pContainerName);

      Container container = api.create(pContainerName, pCreateContainerOptions);
      assertNotNull(container);
      try {
         System.out.println(container);
         Logger.getAnonymousLogger().info("get: " + pContainerName);
         container = api.get(pContainerName);
         assertNotNull(container);
         System.out.println(container);
         assertEquals(container.getObjectType(), ObjectTypes.CONTAINER);
         assertNotNull(container.getObjectID());
         assertNotNull(container.getObjectName());
         assertEquals(container.getObjectName(), pContainerName);
         assertEquals(container.getParentURI(), "/");
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);
         System.out.println("Children: " + container.getChildren());
         assertNotNull(container.getMetadata());
         System.out.println("Raw metadata: " + container.getMetadata());
         for (Map.Entry<String, JsonBall> entry : container.getMetadata().entrySet()) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
         }
         assertNotNull(container.getUserMetadata());
         Map<String, String> pContainerMetaDataOut = container.getUserMetadata();
         for (Map.Entry<String, String> entry : pContainerMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(pContainerMetaDataOut.containsKey(key), true);
            assertEquals(pContainerMetaDataOut.get(key), entry.getValue());
         }
         System.out.println("UserMetaData: " + container.getUserMetadata());
         assertNotNull(container.getSystemMetadata());
         System.out.println("SystemMetaData: " + container.getSystemMetadata());
         assertNotNull(container.getACLMetadata());
         assertEquals(container.getACLMetadata().size(), 3);
         List<Map<String, String>> aclMetadataOut = container.getACLMetadata();
         System.out.println("ACLMetaData: ");
         for (Map<String, String> aclMap : aclMetadataOut) {
            System.out.println(aclMap);
         }
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), true);
         System.out.println("adding containers to container");
         String firstParentURI = api.get(pContainerName).getObjectName();
         for (int i = 0; i < 10; i++) {
            // container = api.create(firstParentURI+"childcontainer"+i+"/");
            container = api.create(pContainerName + "childcontainer" + i + "/");
            assertNotNull(container);
            System.out.println(container);
            assertEquals(container.getParentURI(), pContainerName);
            assertEquals(container.getObjectName(), "childcontainer" + i + "/");
            container = api.create(container.getParentURI() + container.getObjectName() + "grandchild/");
            assertEquals(container.getParentURI(), pContainerName + "childcontainer" + i + "/");
            assertEquals(container.getObjectName(), "grandchild/");
            System.out.println(container);
         }
         container = api.get(pContainerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 10);

      } finally {
         Logger.getAnonymousLogger().info("delete: " + pContainerName);
         api.delete(pContainerName);
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), false);
      }

   }
View Full Code Here

      ContainerApi containerApi = cdmiContext.getApi().getApi();
      DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName);
      DataNonCDMIContentTypeApi dataNonCDMIContentTypeApi = cdmiContext.getApi()
               .getDataNonCDMIContentTypeApiForContainer(containerName);
      Logger.getAnonymousLogger().info("create: " + containerName);
      Container container = containerApi.create(containerName, pCreateContainerOptions);
      try {

         assertNotNull(container);
         System.out.println(container);
         container = containerApi.get(containerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);

         // 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);
View Full Code Here

      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi containerApi = cdmiContext.getApi().getApi();
      DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName);
      Logger.getAnonymousLogger().info("create: " + containerName);
      Container container = containerApi.create(containerName, pCreateContainerOptions);
      try {
         assertNotNull(container);
         System.out.println(container);
         container = containerApi.get(containerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);

         // exercise create data object with value mimetype and metadata
         value = "Hello CDMI data object with value mimetype and metadata";
         pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain")
                  .metadata(pDataObjectMetaDataIn);
View Full Code Here

      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi containerApi = cdmiContext.getApi().getApi();
      DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName);
      Logger.getAnonymousLogger().info("create: " + containerName);
      Container container = containerApi.create(containerName, pCreateContainerOptions);
      try {
         assertNotNull(container);
         System.out.println(container);
         container = containerApi.get(containerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);

         // exercise create data object with value mimetype and metadata
         value = "Hello CDMI data object with value mimetype and metadata";
         pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain")
                  .metadata(pDataObjectMetaDataIn);
         dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions);
         assertNotNull(dataObject);
         dataObject = dataApi.get(dataObjectNameIn);
         assertNotNull(dataObject);
         System.out.println(dataObject);
         System.out.println("value: " + dataObject.getValueAsString());
         assertEquals(dataObject.getMimetype(), "text/plain");
         assertEquals(dataObject.getValueAsString(), value);
         dataObjectMetaDataOut = dataObject.getUserMetadata();
         assertNotNull(dataObjectMetaDataOut);
         for (Map.Entry<String, String> entry : pDataObjectMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(dataObjectMetaDataOut.containsKey(key), true);
            assertEquals(dataObjectMetaDataOut.get(key), entry.getValue());
         }
         assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);
         assertEquals(dataObject.getObjectType(), "application/cdmi-object");
         assertEquals(dataObject.getParentURI(), "/" + containerName);
         assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true);

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")
                  .field("objectName"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")
                  .field("objectName").field("mimetype"));
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);
         assertEquals(dataObject.getMimetype(), "text/plain");

         dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")
                  .field("objectName").field("mimetype").metadata());
         assertNotNull(dataObject);
         System.out.println(dataObject);
         assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName());
         assertEquals(dataObject.getObjectName(), dataObjectNameIn);
         assertEquals(dataObject.getMimetype(), "text/plain");
         dataObjectMetaDataOut = dataObject.getUserMetadata();
         assertNotNull(dataObjectMetaDataOut);
         for (Map.Entry<String, String> entry : pDataObjectMetaDataIn.entrySet()) {
View Full Code Here

      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi api = cdmiContext.getApi().getApi();

      Logger.getAnonymousLogger().info("create: " + pContainerName);

      Container container = api.create(pContainerName, pCreateContainerOptions);
      assertNotNull(container);
      try {
         System.out.println(container);
         Logger.getAnonymousLogger().info("get: " + pContainerName);
         container = api.get(pContainerName);
         assertNotNull(container);
         System.out.println(container);
         assertEquals(container.getObjectType(), ObjectTypes.CONTAINER);
         assertNotNull(container.getObjectID());
         assertNotNull(container.getObjectName());
         assertEquals(container.getObjectName(), pContainerName);
         assertEquals(container.getParentURI(), "/");
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);
         System.out.println("Children: " + container.getChildren());
         assertNotNull(container.getMetadata());
         System.out.println("Raw metadata: " + container.getMetadata());
         for (Map.Entry<String, JsonBall> entry : container.getMetadata().entrySet()) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
         }
         assertNotNull(container.getUserMetadata());
         Map<String, String> pContainerMetaDataOut = container.getUserMetadata();
         for (Map.Entry<String, String> entry : pContainerMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(pContainerMetaDataOut.containsKey(key), true);
            assertEquals(pContainerMetaDataOut.get(key), entry.getValue());
         }
         System.out.println("UserMetaData: " + container.getUserMetadata());
         assertNotNull(container.getSystemMetadata());
         System.out.println("SystemMetaData: " + container.getSystemMetadata());
         assertNotNull(container.getACLMetadata());
         assertEquals(container.getACLMetadata().size(), 3);
         List<Map<String, String>> aclMetadataOut = container.getACLMetadata();
         System.out.println("ACLMetaData: ");
         for (Map<String, String> aclMap : aclMetadataOut) {
            System.out.println(aclMap);
         }
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), true);
         System.out.println("adding containers to container");
         String firstParentURI = api.get(pContainerName).getObjectName();
         for (int i = 0; i < 10; i++) {
            // container = api.create(firstParentURI+"childcontainer"+i+"/");
            container = api.create(pContainerName + "childcontainer" + i + "/");
            assertNotNull(container);
            System.out.println(container);
            assertEquals(container.getParentURI(), pContainerName);
            assertEquals(container.getObjectName(), "childcontainer" + i + "/");
            container = api.create(container.getParentURI() + container.getObjectName() + "grandchild/");
            assertEquals(container.getParentURI(), pContainerName + "childcontainer" + i + "/");
            assertEquals(container.getObjectName(), "grandchild/");
            System.out.println(container);
         }
         container = api.get(pContainerName);
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 10);

      } finally {
         Logger.getAnonymousLogger().info("delete: " + pContainerName);
         api.delete(pContainerName);
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), false);
      }

   }
View Full Code Here

      CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn);
      ContainerApi api = cdmiContext.getApi().getApi();

      Logger.getAnonymousLogger().info("create: " + pContainerName);

      Container container = api.create(pContainerName, pCreateContainerOptions);
      assertNotNull(container);
      try {
         System.out.println(container);
         Logger.getAnonymousLogger().info("get: " + pContainerName);
         container = api.get(pContainerName);
         assertNotNull(container);
         System.out.println(container);
         assertEquals(container.getObjectType(), ObjectTypes.CONTAINER);
         assertNotNull(container.getObjectID());
         assertNotNull(container.getObjectName());
         assertEquals(container.getObjectName(), pContainerName);
         assertEquals(container.getParentURI(), "/");
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().isEmpty(), true);
         System.out.println("Children: " + container.getChildren());
         assertNotNull(container.getMetadata());
         System.out.println("Raw metadata: " + container.getMetadata());
         for (Map.Entry<String, JsonBall> entry : container.getMetadata().entrySet()) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
         }
         assertNotNull(container.getUserMetadata());
         Map<String, String> pContainerMetaDataOut = container.getUserMetadata();
         for (Map.Entry<String, String> entry : pContainerMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(pContainerMetaDataOut.containsKey(key), true);
            assertEquals(pContainerMetaDataOut.get(key), entry.getValue());
         }
         System.out.println("UserMetaData: " + container.getUserMetadata());
         assertNotNull(container.getSystemMetadata());
         System.out.println("SystemMetaData: " + container.getSystemMetadata());
         assertNotNull(container.getACLMetadata());
         List<Map<String, String>> aclMetadataOut = container.getACLMetadata();
         System.out.println("ACLMetaData: ");
         for (Map<String, String> aclMap : aclMetadataOut) {
            System.out.println(aclMap);
         }
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), true);
         container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI"));
         assertNotNull(container);
         assertEquals(container.getParentURI(), "/");
         System.out.println(container);

         container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI").field("objectName"));
         assertNotNull(container);
         assertEquals(container.getParentURI(), "/");
         assertEquals(container.getObjectName(), pContainerName);

         container = api.get(pContainerName, ContainerQueryParams.Builder.metadata());
         assertNotNull(container);
         pContainerMetaDataOut = container.getUserMetadata();
         for (Map.Entry<String, String> entry : pContainerMetaDataIn.entrySet()) {
            String key = entry.getKey();
            assertEquals(pContainerMetaDataOut.containsKey(key), true);
            assertEquals(pContainerMetaDataOut.get(key), entry.getValue());
         }
         System.out.println(container);

         System.out.println("GetContainerOptions.Builder.metadata(cdmi_acl)");
         container = api.get(pContainerName, ContainerQueryParams.Builder.metadata("cdmi_acl"));
         assertNotNull(container);
         System.out.println(container);
         assertNotNull(container.getACLMetadata());
         assertEquals(container.getACLMetadata().size(), 3);

         System.out.println("adding containers to container");
         String firstParentURI = api.get(pContainerName).getObjectName();
         for (int i = 0; i < 10; i++) {
            container = api.create(firstParentURI + "childcontainer" + i + "/");
            assertNotNull(container);
            assertEquals(container.getParentURI(), pContainerName);
            assertEquals(container.getObjectName(), "childcontainer" + i + "/");
            container = api.create(container.getParentURI() + container.getObjectName() + "grandchild/",
                     pCreateContainerOptions);
            assertEquals(container.getParentURI(), pContainerName + "childcontainer" + i + "/");
            assertEquals(container.getObjectName(), "grandchild" + "/");
            container = api.get(container.getParentURI(), ContainerQueryParams.Builder.children());
            assertEquals(container.getChildren().contains("grandchild" + "/"), true);
         }
         container = api.get(pContainerName, ContainerQueryParams.Builder.children());
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 10);
         container = api.get(pContainerName, ContainerQueryParams.Builder.children(0, 3));
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 4);

         container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI").field("objectName")
                  .children().metadata());
         assertNotNull(container);
         assertNotNull(container.getChildren());
         assertEquals(container.getChildren().size(), 10);
         assertEquals(container.getParentURI(), "/");
         assertEquals(container.getObjectName(), pContainerName);
         assertEquals(container.getParentURI(), "/");
         assertEquals(container.getACLMetadata().size(), 3);
         for (String childName : container.getChildren()) {
            api.delete(container.getObjectName() + childName);
         }
         assertEquals(api.get(pContainerName, ContainerQueryParams.Builder.children()).getChildren().isEmpty(), true);

      } finally {
         Logger.getAnonymousLogger().info("delete: " + pContainerName);
         api.delete(pContainerName);
         container = api.get("/");
         System.out.println("root container: " + container);
         assertEquals(container.getChildren().contains(pContainerName), false);
      }

   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.swift.v1.domain.Container$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.