http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/DataCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/DataCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/DataCatalogImpl.java deleted file mode 100644 index 80bf14f..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/DataCatalogImpl.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.replica.catalog.impl; - -import org.apache.airavata.model.data.resource.DataReplicaLocationModel; -import org.apache.airavata.model.data.resource.DataResourceModel; -import org.apache.airavata.registry.core.replica.catalog.model.DataReplicaLocation; -import org.apache.airavata.registry.core.replica.catalog.model.DataResource; -import org.apache.airavata.registry.core.replica.catalog.utils.DataCatalogJPAUtils; -import org.apache.airavata.registry.core.replica.catalog.utils.ThriftDataModelConversion; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.apache.airavata.registry.cpi.DataCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class DataCatalogImpl implements DataCatalog { - - private final static Logger logger = LoggerFactory.getLogger(DataCatalogImpl.class); - - @Override - public String publishResource(DataResourceModel resourceModel) throws DataCatalogException { - String resourceId = UUID.randomUUID().toString(); - resourceModel.setResourceId(resourceId); - if(resourceModel.getDataReplicaLocations() != null){ - resourceModel.getDataReplicaLocations().stream().forEach(r-> { - r.setResourceId(resourceId); - r.setReplicaId(UUID.randomUUID().toString()); - }); - } - resourceModel.setCreationTime(System.currentTimeMillis()); - resourceModel.setLastModifiedTime(System.currentTimeMillis()); - DataResource dataResource = ThriftDataModelConversion.getDataResource(resourceModel); - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - em.persist(dataResource); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return resourceId; - } - - @Override - public boolean removeResource(String resourceId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceId); - if(dataResource == null) - return false; - em.getTransaction().begin(); - em.remove(dataResource); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public boolean updateResource(DataResourceModel resourceModel) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceModel.getResourceId()); - if(dataResource == null) - return false; - em.getTransaction().begin(); - resourceModel.setCreationTime(dataResource.getCreationTime().getTime()); - resourceModel.setLastModifiedTime(System.currentTimeMillis()); - em.merge(ThriftDataModelConversion.getUpdatedDataResource(resourceModel, dataResource)); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public DataResourceModel getResource(String resourceId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceId); - return ThriftDataModelConversion.getDataResourceModel(dataResource); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public String publishReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataCatalogException { - String replicaId = UUID.randomUUID().toString(); - dataReplicaLocationModel.setReplicaId(replicaId); - dataReplicaLocationModel.setCreationTime(System.currentTimeMillis()); - dataReplicaLocationModel.setLastModifiedTime(System.currentTimeMillis()); - DataReplicaLocation replicaLocation = ThriftDataModelConversion.getDataReplicaLocation(dataReplicaLocationModel); - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - em.persist(replicaLocation); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return replicaId; - } - - @Override - public boolean removeReplicaLocation(String replicaId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataReplicaLocation replicaLocation = em.find(DataReplicaLocation.class, replicaId); - if(replicaLocation == null) - return false; - em.getTransaction().begin(); - em.remove(replicaLocation); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataReplicaLocation dataReplicaLocation = em.find(DataReplicaLocation.class, dataReplicaLocationModel.getReplicaId()); - if(dataReplicaLocation == null) - return false; - em.getTransaction().begin(); - dataReplicaLocationModel.setCreationTime(dataReplicaLocation.getCreationTime().getTime()); - dataReplicaLocationModel.setLastModifiedTime(System.currentTimeMillis()); - em.merge(ThriftDataModelConversion.getUpdatedDataReplicaLocation(dataReplicaLocationModel, dataReplicaLocation)); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public DataReplicaLocationModel getReplicaLocation(String replicaId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataReplicaLocation replicaLocation = em.find(DataReplicaLocation.class, replicaId); - return ThriftDataModelConversion.getDataReplicaLocationModel(replicaLocation); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceId); - if(dataResource == null) - return null; - ArrayList<DataReplicaLocationModel> dataReplicaLocationModels = new ArrayList<>(); - dataResource.getDataReplicaLocations().stream().forEach(rl->dataReplicaLocationModels - .add(ThriftDataModelConversion.getDataReplicaLocationModel(rl))); - return dataReplicaLocationModels; - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java new file mode 100644 index 0000000..3c9227e --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/impl/ReplicaCatalogImpl.java @@ -0,0 +1,278 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.replica.catalog.impl; + +import org.apache.airavata.model.data.resource.DataReplicaLocationModel; +import org.apache.airavata.model.data.resource.DataResourceModel; +import org.apache.airavata.registry.core.replica.catalog.model.DataReplicaLocation; +import org.apache.airavata.registry.core.replica.catalog.model.DataResource; +import org.apache.airavata.registry.core.replica.catalog.utils.DataCatalogJPAUtils; +import org.apache.airavata.registry.core.replica.catalog.utils.ThriftDataModelConversion; +import org.apache.airavata.registry.cpi.ReplicaCatalog; +import org.apache.airavata.registry.cpi.ReplicaCatalogException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ReplicaCatalogImpl implements ReplicaCatalog { + + private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogImpl.class); + + @Override + public String publishResource(DataResourceModel resourceModel) throws ReplicaCatalogException { + String resourceId = UUID.randomUUID().toString(); + resourceModel.setResourceId(resourceId); + if(resourceModel.getDataReplicaLocations() != null){ + resourceModel.getDataReplicaLocations().stream().forEach(r-> { + r.setResourceId(resourceId); + r.setReplicaId(UUID.randomUUID().toString()); + }); + } + resourceModel.setCreationTime(System.currentTimeMillis()); + resourceModel.setLastModifiedTime(System.currentTimeMillis()); + DataResource dataResource = ThriftDataModelConversion.getDataResource(resourceModel); + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + em.persist(dataResource); + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return resourceId; + } + + @Override + public boolean removeResource(String resourceId) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataResource dataResource = em.find(DataResource.class, resourceId); + if(dataResource == null) + return false; + em.getTransaction().begin(); + em.remove(dataResource); + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return true; + } + + @Override + public boolean updateResource(DataResourceModel resourceModel) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataResource dataResource = em.find(DataResource.class, resourceModel.getResourceId()); + if(dataResource == null) + return false; + em.getTransaction().begin(); + resourceModel.setCreationTime(dataResource.getCreationTime().getTime()); + resourceModel.setLastModifiedTime(System.currentTimeMillis()); + em.merge(ThriftDataModelConversion.getUpdatedDataResource(resourceModel, dataResource)); + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return true; + } + + @Override + public DataResourceModel getResource(String resourceId) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataResource dataResource = em.find(DataResource.class, resourceId); + return ThriftDataModelConversion.getDataResourceModel(dataResource); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public String publishReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException { + String replicaId = UUID.randomUUID().toString(); + dataReplicaLocationModel.setReplicaId(replicaId); + dataReplicaLocationModel.setCreationTime(System.currentTimeMillis()); + dataReplicaLocationModel.setLastModifiedTime(System.currentTimeMillis()); + DataReplicaLocation replicaLocation = ThriftDataModelConversion.getDataReplicaLocation(dataReplicaLocationModel); + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + em.persist(replicaLocation); + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return replicaId; + } + + @Override + public boolean removeReplicaLocation(String replicaId) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataReplicaLocation replicaLocation = em.find(DataReplicaLocation.class, replicaId); + if(replicaLocation == null) + return false; + em.getTransaction().begin(); + em.remove(replicaLocation); + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return true; + } + + @Override + public boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataReplicaLocation dataReplicaLocation = em.find(DataReplicaLocation.class, dataReplicaLocationModel.getReplicaId()); + if(dataReplicaLocation == null) + return false; + em.getTransaction().begin(); + dataReplicaLocationModel.setCreationTime(dataReplicaLocation.getCreationTime().getTime()); + dataReplicaLocationModel.setLastModifiedTime(System.currentTimeMillis()); + em.merge(ThriftDataModelConversion.getUpdatedDataReplicaLocation(dataReplicaLocationModel, dataReplicaLocation)); + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return true; + } + + @Override + public DataReplicaLocationModel getReplicaLocation(String replicaId) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataReplicaLocation replicaLocation = em.find(DataReplicaLocation.class, replicaId); + return ThriftDataModelConversion.getDataReplicaLocationModel(replicaLocation); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws ReplicaCatalogException { + EntityManager em = null; + try { + em = DataCatalogJPAUtils.getEntityManager(); + DataResource dataResource = em.find(DataResource.class, resourceId); + if(dataResource == null) + return null; + ArrayList<DataReplicaLocationModel> dataReplicaLocationModels = new ArrayList<>(); + dataResource.getDataReplicaLocations().stream().forEach(rl->dataReplicaLocationModels + .add(ThriftDataModelConversion.getDataReplicaLocationModel(rl))); + return dataReplicaLocationModels; + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ReplicaCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/DataCatalogTest.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/DataCatalogTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/DataCatalogTest.java deleted file mode 100644 index 80138a4..0000000 --- a/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/DataCatalogTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.replica.catalog; - -import org.apache.airavata.replica.catalog.util.Initialize; -import org.apache.airavata.model.data.resource.DataReplicaLocationModel; -import org.apache.airavata.model.data.resource.DataResourceModel; -import org.apache.airavata.model.data.resource.ReplicaLocationCategory; -import org.apache.airavata.model.data.resource.ReplicaPersistentType; -import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.apache.airavata.registry.cpi.DataCatalogException; -import org.junit.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; - -public class DataCatalogTest { - private final static Logger logger = LoggerFactory.getLogger(DataCatalogTest.class); - private static Initialize initialize; - private static DataCatalog datacatalog; - private static DataResourceModel dataResourceModel; - private static DataReplicaLocationModel replicaLocationModel; - - @BeforeClass - public static void setUp() { - try { - System.out.println("********** SET UP ************"); - initialize = new Initialize("replicacatalog-derby.sql"); - initialize.initializeDB(); - datacatalog = RegistryFactory.getDataCatalog(); - dataResourceModel = new DataResourceModel(); - dataResourceModel.setResourceName("test-file.txt"); - HashMap<String, String> resMetadata = new HashMap<>(); - resMetadata.put("name", "name"); - dataResourceModel.setResourceMetadata(resMetadata); - - replicaLocationModel = new DataReplicaLocationModel(); - replicaLocationModel.setReplicaName("1-st-replica"); - replicaLocationModel.setReplicaLocationCategory(ReplicaLocationCategory.COMPUTE_RESOURCE); - replicaLocationModel.setReplicaPersistentType(ReplicaPersistentType.PERSISTENT); - HashMap<String, String> rMetadata = new HashMap<>(); - rMetadata.put("name", "name"); - replicaLocationModel.setReplicaMetadata(rMetadata); - ArrayList<String> dataLocations = new ArrayList<>(); - dataLocations.add("scp://g75.iu.xsede.org:/var/www/portal/experimentData/test-file.txt"); - replicaLocationModel.setDataLocations(dataLocations); - - dataResourceModel.addToDataReplicaLocations(replicaLocationModel); - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - } - } - - @AfterClass - public static void tearDown() throws Exception { - System.out.println("********** TEAR DOWN ************"); - initialize.stopDerbyServer(); - } - - @Test - public void testPublishDataResource(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - org.junit.Assert.assertNotNull(resourceId); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testRemoveDataResource(){ - try { - boolean result = datacatalog.removeResource("234234234"); - Assert.assertFalse(result); - String resourceId = datacatalog.publishResource(dataResourceModel); - Assert.assertNotNull(resourceId); - result = datacatalog.removeResource(resourceId); - Assert.assertTrue(result); - result = datacatalog.removeResource(resourceId); - Assert.assertFalse(result); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetDataResource(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - Assert.assertNotNull(resourceId); - DataResourceModel persistedCopy = datacatalog.getResource(resourceId); - Assert.assertNotNull(persistedCopy); - Assert.assertTrue(persistedCopy.getDataReplicaLocations().size()==1); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testUpdateDataResource(){ - try { - dataResourceModel.setResourceId(UUID.randomUUID().toString()); - boolean result = datacatalog.updateResource(dataResourceModel); - Assert.assertFalse(result); - datacatalog.publishResource(dataResourceModel); - dataResourceModel.setResourceName("updated-name"); - datacatalog.updateResource(dataResourceModel); - dataResourceModel = datacatalog.getResource(dataResourceModel.getResourceId()); - Assert.assertTrue(dataResourceModel.getResourceName().equals("updated-name")); - Assert.assertTrue(dataResourceModel.getResourceMetadata().size()==1); - dataResourceModel.getResourceMetadata().put("name2","name2"); - datacatalog.updateResource(dataResourceModel); - dataResourceModel = datacatalog.getResource(dataResourceModel.getResourceId()); - Assert.assertTrue(dataResourceModel.getResourceMetadata().size()==2); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testPublishReplicaLocation(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); - Assert.assertNotNull(replicaId);; - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testRemoveReplicaLocation(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); - boolean result = datacatalog.removeReplicaLocation(replicaId); - Assert.assertTrue(result); - result = datacatalog.removeReplicaLocation(replicaLocationModel.getReplicaId()); - Assert.assertFalse(result); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetReplicaLocation(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); - DataReplicaLocationModel persistedCopy = datacatalog.getReplicaLocation(replicaId); - Assert.assertNotNull(persistedCopy); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testUpdateReplicaLocation(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); - DataReplicaLocationModel persistedCopy = datacatalog.getReplicaLocation(replicaId); - persistedCopy.setReplicaDescription("updated-description"); - datacatalog.updateReplicaLocation(persistedCopy); - persistedCopy = datacatalog.getReplicaLocation(replicaId); - Assert.assertTrue(persistedCopy.getReplicaDescription().equals("updated-description")); - Assert.assertEquals(persistedCopy.getReplicaLocationCategory(), replicaLocationModel.getReplicaLocationCategory()); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetAllReplicaLocations(){ - try { - String resourceId = datacatalog.publishResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - datacatalog.publishReplicaLocation(replicaLocationModel); - List<DataReplicaLocationModel> replicaLocationModelList = datacatalog.getAllReplicaLocations(resourceId); - Assert.assertNotNull(replicaLocationModelList.get(0).getReplicaId()); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogTest.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogTest.java new file mode 100644 index 0000000..2f60328 --- /dev/null +++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogTest.java @@ -0,0 +1,221 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.replica.catalog; + +import org.apache.airavata.replica.catalog.util.Initialize; +import org.apache.airavata.model.data.resource.DataReplicaLocationModel; +import org.apache.airavata.model.data.resource.DataResourceModel; +import org.apache.airavata.model.data.resource.ReplicaLocationCategory; +import org.apache.airavata.model.data.resource.ReplicaPersistentType; +import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; +import org.apache.airavata.registry.cpi.ReplicaCatalog; +import org.apache.airavata.registry.cpi.ReplicaCatalogException; +import org.junit.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +public class ReplicaCatalogTest { + private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogTest.class); + private static Initialize initialize; + private static ReplicaCatalog datacatalog; + private static DataResourceModel dataResourceModel; + private static DataReplicaLocationModel replicaLocationModel; + + @BeforeClass + public static void setUp() { + try { + System.out.println("********** SET UP ************"); + initialize = new Initialize("replicacatalog-derby.sql"); + initialize.initializeDB(); + datacatalog = RegistryFactory.getReplicaCatalog(); + dataResourceModel = new DataResourceModel(); + dataResourceModel.setResourceName("test-file.txt"); + HashMap<String, String> resMetadata = new HashMap<>(); + resMetadata.put("name", "name"); + dataResourceModel.setResourceMetadata(resMetadata); + + replicaLocationModel = new DataReplicaLocationModel(); + replicaLocationModel.setReplicaName("1-st-replica"); + replicaLocationModel.setReplicaLocationCategory(ReplicaLocationCategory.COMPUTE_RESOURCE); + replicaLocationModel.setReplicaPersistentType(ReplicaPersistentType.PERSISTENT); + HashMap<String, String> rMetadata = new HashMap<>(); + rMetadata.put("name", "name"); + replicaLocationModel.setReplicaMetadata(rMetadata); + ArrayList<String> dataLocations = new ArrayList<>(); + dataLocations.add("scp://g75.iu.xsede.org:/var/www/portal/experimentData/test-file.txt"); + replicaLocationModel.setDataLocations(dataLocations); + + dataResourceModel.addToDataReplicaLocations(replicaLocationModel); + } catch (ReplicaCatalogException e) { + logger.error(e.getMessage(), e); + } + } + + @AfterClass + public static void tearDown() throws Exception { + System.out.println("********** TEAR DOWN ************"); + initialize.stopDerbyServer(); + } + + @Test + public void testPublishDataResource(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + org.junit.Assert.assertNotNull(resourceId); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testRemoveDataResource(){ + try { + boolean result = datacatalog.removeResource("234234234"); + Assert.assertFalse(result); + String resourceId = datacatalog.publishResource(dataResourceModel); + Assert.assertNotNull(resourceId); + result = datacatalog.removeResource(resourceId); + Assert.assertTrue(result); + result = datacatalog.removeResource(resourceId); + Assert.assertFalse(result); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testGetDataResource(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + Assert.assertNotNull(resourceId); + DataResourceModel persistedCopy = datacatalog.getResource(resourceId); + Assert.assertNotNull(persistedCopy); + Assert.assertTrue(persistedCopy.getDataReplicaLocations().size()==1); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testUpdateDataResource(){ + try { + dataResourceModel.setResourceId(UUID.randomUUID().toString()); + boolean result = datacatalog.updateResource(dataResourceModel); + Assert.assertFalse(result); + datacatalog.publishResource(dataResourceModel); + dataResourceModel.setResourceName("updated-name"); + datacatalog.updateResource(dataResourceModel); + dataResourceModel = datacatalog.getResource(dataResourceModel.getResourceId()); + Assert.assertTrue(dataResourceModel.getResourceName().equals("updated-name")); + Assert.assertTrue(dataResourceModel.getResourceMetadata().size()==1); + dataResourceModel.getResourceMetadata().put("name2","name2"); + datacatalog.updateResource(dataResourceModel); + dataResourceModel = datacatalog.getResource(dataResourceModel.getResourceId()); + Assert.assertTrue(dataResourceModel.getResourceMetadata().size()==2); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testPublishReplicaLocation(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + replicaLocationModel.setResourceId(resourceId); + String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); + Assert.assertNotNull(replicaId);; + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testRemoveReplicaLocation(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + replicaLocationModel.setResourceId(resourceId); + String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); + boolean result = datacatalog.removeReplicaLocation(replicaId); + Assert.assertTrue(result); + result = datacatalog.removeReplicaLocation(replicaLocationModel.getReplicaId()); + Assert.assertFalse(result); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testGetReplicaLocation(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + replicaLocationModel.setResourceId(resourceId); + String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); + DataReplicaLocationModel persistedCopy = datacatalog.getReplicaLocation(replicaId); + Assert.assertNotNull(persistedCopy); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testUpdateReplicaLocation(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + replicaLocationModel.setResourceId(resourceId); + String replicaId = datacatalog.publishReplicaLocation(replicaLocationModel); + DataReplicaLocationModel persistedCopy = datacatalog.getReplicaLocation(replicaId); + persistedCopy.setReplicaDescription("updated-description"); + datacatalog.updateReplicaLocation(persistedCopy); + persistedCopy = datacatalog.getReplicaLocation(replicaId); + Assert.assertTrue(persistedCopy.getReplicaDescription().equals("updated-description")); + Assert.assertEquals(persistedCopy.getReplicaLocationCategory(), replicaLocationModel.getReplicaLocationCategory()); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testGetAllReplicaLocations(){ + try { + String resourceId = datacatalog.publishResource(dataResourceModel); + replicaLocationModel.setResourceId(resourceId); + datacatalog.publishReplicaLocation(replicaLocationModel); + List<DataReplicaLocationModel> replicaLocationModelList = datacatalog.getAllReplicaLocations(resourceId); + Assert.assertNotNull(replicaLocationModelList.get(0).getReplicaId()); + } catch (ReplicaCatalogException e) { + e.printStackTrace(); + Assert.fail(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalog.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalog.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalog.java deleted file mode 100644 index bc468d6..0000000 --- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalog.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.airavata.registry.cpi; - -import org.apache.airavata.model.data.resource.*; - -import java.util.List; - -public interface DataCatalog { - - String publishResource(DataResourceModel resource) throws DataCatalogException; - - boolean removeResource(String resourceId) throws DataCatalogException; - - boolean updateResource(DataResourceModel resource) throws DataCatalogException; - - DataResourceModel getResource(String resourceId) throws DataCatalogException; - - String publishReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataCatalogException; - - boolean removeReplicaLocation(String replicaId) throws DataCatalogException; - - boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataCatalogException; - - DataReplicaLocationModel getReplicaLocation(String replicaId) throws DataCatalogException; - - List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws DataCatalogException; -} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalogException.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalogException.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalogException.java deleted file mode 100644 index dbb0ee4..0000000 --- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/DataCatalogException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.airavata.registry.cpi; - -public class DataCatalogException extends Exception{ - private static final long serialVersionUID = -2849422320739447602L; - - public DataCatalogException(Throwable e) { - super(e); - } - - public DataCatalogException(String message) { - super(message, null); - } - - public DataCatalogException(String message, Throwable e) { - super(message, e); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java index e51389c..60531c8 100644 --- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java +++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java @@ -25,5 +25,5 @@ public interface Registry { public ExperimentCatalog getExperimentCatalog() throws RegistryException; public ExperimentCatalog getExperimentCatalog(String gatewayId, String username, String password) throws RegistryException; public AppCatalog getAppCatalog() throws RegistryException; - public DataCatalog getDataCatalog() throws RegistryException; + public ReplicaCatalog getReplicaCatalog() throws RegistryException; } http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalog.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalog.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalog.java new file mode 100644 index 0000000..fa9913b --- /dev/null +++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalog.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.airavata.registry.cpi; + +import org.apache.airavata.model.data.resource.*; + +import java.util.List; + +public interface ReplicaCatalog { + + String publishResource(DataResourceModel resource) throws ReplicaCatalogException; + + boolean removeResource(String resourceId) throws ReplicaCatalogException; + + boolean updateResource(DataResourceModel resource) throws ReplicaCatalogException; + + DataResourceModel getResource(String resourceId) throws ReplicaCatalogException; + + String publishReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException; + + boolean removeReplicaLocation(String replicaId) throws ReplicaCatalogException; + + boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException; + + DataReplicaLocationModel getReplicaLocation(String replicaId) throws ReplicaCatalogException; + + List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws ReplicaCatalogException; +} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalogException.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalogException.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalogException.java new file mode 100644 index 0000000..deec3a0 --- /dev/null +++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/ReplicaCatalogException.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.airavata.registry.cpi; + +public class ReplicaCatalogException extends Exception{ + private static final long serialVersionUID = -2849422320739447602L; + + public ReplicaCatalogException(Throwable e) { + super(e); + } + + public ReplicaCatalogException(String message) { + super(message, null); + } + + public ReplicaCatalogException(String message, Throwable e) { + super(message, e); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/pom.xml ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/pom.xml b/modules/replica-catalog/pom.xml deleted file mode 100644 index 4a46bcb..0000000 --- a/modules/replica-catalog/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>airavata</artifactId> - <groupId>org.apache.airavata</groupId> - <version>0.16-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>replica-catalog</artifactId> - <packaging>jar</packaging> - <name>Airavata Replica Catalog</name> - <url>http://airavata.apache.org/</url> - - <dependencies> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-data-models</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-registry-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-registry-cpi</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-commons</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-server-configuration</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.7</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalog.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalog.java b/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalog.java deleted file mode 100644 index 8272c45..0000000 --- a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalog.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.replica.catalog; - -import org.apache.airavata.model.data.resource.DataReplicaLocationModel; -import org.apache.airavata.model.data.resource.DataResourceModel; -import org.apache.airavata.registry.cpi.DataCatalogException; - -import java.util.List; - -public interface ReplicaCatalog { - - /** - * To create a new dataResourceModel. This is how the system comes to know about already - * existing resources - * @param dataResourceModel - * @return - */ - String publishResource(DataResourceModel dataResourceModel) throws ReplicaCatalogException; - - /** - * To remove a resource entry from the replica catalog - * @param resourceId - * @return - */ - boolean removeResource(String resourceId) throws ReplicaCatalogException; - - - /** - * To update an existing data resource model - * @param dataResourceModel - * @return - * @throws ReplicaCatalogException - */ - boolean updateResource(DataResourceModel dataResourceModel) throws ReplicaCatalogException; - - /** - * To retrieve a resource object providing the resourceId - * @param resourceId - * @return - */ - DataResourceModel getResource(String resourceId) throws ReplicaCatalogException; - - /** - * To create a new data replica location. This is how the system comes to know about already - * existing resources - * @param dataReplicaLocationModel - * @return - */ - String publishReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException; - - /** - * To remove a replica entry from the replica catalog - * @param replicaId - * @return - */ - boolean removeReplicaLocation(String replicaId) throws ReplicaCatalogException; - - /** - * To update an existing data replica model - * @param dataReplicaLocationModel - * @return - * @throws ReplicaCatalogException - */ - boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException; - - /** - * To retrieve a replica object providing the replicaId - * @param replicaId - * @return - */ - DataReplicaLocationModel getReplicaLocation(String replicaId) throws ReplicaCatalogException; - - /** - * To retrieve all the replica entries for a given resource id - * @param resourceId - * @return - * @throws DataCatalogException - */ - List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws ReplicaCatalogException; -} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogConstants.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogConstants.java b/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogConstants.java deleted file mode 100644 index cdc0fa5..0000000 --- a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogConstants.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.replica.catalog; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReplicaCatalogConstants { - private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogConstants.class); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogException.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogException.java b/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogException.java deleted file mode 100644 index aaa56f4..0000000 --- a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogException.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.airavata.replica.catalog; - -public class ReplicaCatalogException extends Exception{ - - public ReplicaCatalogException(Throwable e) { - super(e); - } - - public ReplicaCatalogException(String message) { - super(message, null); - } - - public ReplicaCatalogException(String message, Throwable e) { - super(message, e); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactory.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactory.java b/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactory.java deleted file mode 100644 index de661ca..0000000 --- a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.replica.catalog; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReplicaCatalogFactory { - private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogFactory.class); - - public static ReplicaCatalog getDataManager() throws ReplicaCatalogException { - return new ReplicaCatalogImpl(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogImpl.java b/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogImpl.java deleted file mode 100644 index e50a35c..0000000 --- a/modules/replica-catalog/src/main/java/org/apache/airavata/replica/catalog/ReplicaCatalogImpl.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.replica.catalog; - -import org.apache.airavata.model.data.resource.DataReplicaLocationModel; -import org.apache.airavata.model.data.resource.DataResourceModel; -import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.apache.airavata.registry.cpi.DataCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -public class ReplicaCatalogImpl implements ReplicaCatalog { - private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogImpl.class); - - private final DataCatalog dataCatalog; - - public ReplicaCatalogImpl() throws ReplicaCatalogException { - try { - this.dataCatalog = RegistryFactory.getDataCatalog(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - public ReplicaCatalogImpl(DataCatalog dataCatalog){ - this.dataCatalog = dataCatalog; - } - - /** - * To create a replica entry for an already existing file(s). This is how the system comes to know about already - * existing resources - * @param dataResourceModel - * @return - */ - @Override - public String publishResource(DataResourceModel dataResourceModel) throws ReplicaCatalogException { - try { - String resourceId = dataCatalog.publishResource(dataResourceModel); - return resourceId; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To remove a resource entry from the replica catalog - * @param resourceId - * @return - */ - @Override - public boolean removeResource(String resourceId) throws ReplicaCatalogException { - try { - boolean result = dataCatalog.removeResource(resourceId); - return result; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To update an existing data resource model - * @param dataResourceModel - * @return - * @throws ReplicaCatalogException - */ - @Override - public boolean updateResource(DataResourceModel dataResourceModel) throws ReplicaCatalogException { - try { - boolean result = dataCatalog.updateResource(dataResourceModel); - return result; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To retrieve a resource object providing the resourceId - * @param resourceId - * @return - */ - @Override - public DataResourceModel getResource(String resourceId) throws ReplicaCatalogException { - try { - DataResourceModel dataResource = dataCatalog.getResource(resourceId); - return dataResource; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To create a new data replica location. This is how the system comes to know about already - * existing resources - * - * @param dataReplicaLocationModel - * @return - */ - @Override - public String publishReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException { - try { - String replicaId = dataCatalog.publishReplicaLocation(dataReplicaLocationModel); - return replicaId; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To remove a replica entry from the replica catalog - * - * @param replicaId - * @return - */ - @Override - public boolean removeReplicaLocation(String replicaId) throws ReplicaCatalogException { - try { - boolean result = dataCatalog.removeReplicaLocation(replicaId); - return result; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To update an existing data replica model - * - * @param dataReplicaLocationModel - * @return - * @throws ReplicaCatalogException - */ - @Override - public boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException { - try { - boolean result = dataCatalog.updateReplicaLocation(dataReplicaLocationModel); - return result; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To retrieve a replica object providing the replicaId - * - * @param replicaId - * @return - */ - @Override - public DataReplicaLocationModel getReplicaLocation(String replicaId) throws ReplicaCatalogException { - try { - DataReplicaLocationModel dataReplicaLocationModel = dataCatalog.getReplicaLocation(replicaId); - return dataReplicaLocationModel; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } - - /** - * To retrieve all the replica entries for a given resource id - * - * @param resourceId - * @return - * @throws DataCatalogException - */ - @Override - public List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws ReplicaCatalogException { - try { - List<DataReplicaLocationModel> dataReplicaLocationModelList = dataCatalog.getAllReplicaLocations(resourceId); - return dataReplicaLocationModelList; - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - throw new ReplicaCatalogException(e); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactoryTest.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactoryTest.java b/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactoryTest.java deleted file mode 100644 index 7988e7f..0000000 --- a/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogFactoryTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.replica.catalog; - -import junit.framework.Assert; -import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.apache.airavata.registry.cpi.DataCatalogException; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReplicaCatalogFactoryTest { - private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogFactoryTest.class); - - @Test - public void testCreateDataManager() throws ReplicaCatalogException, DataCatalogException { - DataCatalog dataCatalog = RegistryFactory.getDataCatalog(); - ReplicaCatalog replicaCatalog = new ReplicaCatalogImpl(dataCatalog); - Assert.assertNotNull(replicaCatalog); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/098c2306/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogImplTest.java ---------------------------------------------------------------------- diff --git a/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogImplTest.java b/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogImplTest.java deleted file mode 100644 index 347b341..0000000 --- a/modules/replica-catalog/src/test/java/org/apache/airavata/replica/catalog/ReplicaCatalogImplTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.replica.catalog; - -import org.apache.airavata.replica.catalog.utils.AppCatInit; -import org.apache.airavata.replica.catalog.utils.DataCatInit; -import org.apache.airavata.model.data.resource.DataReplicaLocationModel; -import org.apache.airavata.model.data.resource.DataResourceModel; -import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class ReplicaCatalogImplTest { - private final static Logger logger = LoggerFactory.getLogger(ReplicaCatalogImplTest.class); - private static AppCatInit appCatInit; - private static DataCatInit dataCatInit; - private static ReplicaCatalog replicaCatalog; - private static DataResourceModel dataResourceModel; - private static DataReplicaLocationModel dataReplicaLocationModel; - - @BeforeClass - public static void setUp() { - try { - System.out.println("********** SET UP ************"); - appCatInit = new AppCatInit("appcatalog-derby.sql"); - appCatInit.initializeDB(); - dataCatInit = new DataCatInit("replicacatalog-derby.sql"); - dataCatInit.initializeDB(); - DataCatalog dataCatalog = RegistryFactory.getDataCatalog(); - replicaCatalog = new ReplicaCatalogImpl(dataCatalog); - dataResourceModel = new DataResourceModel(); - dataResourceModel.setResourceName("test-file.txt"); - dataReplicaLocationModel = new DataReplicaLocationModel(); - dataReplicaLocationModel.setReplicaName("1-st-replica"); - ArrayList<String> dataLocations = new ArrayList<>(); - dataLocations.add("scp://g75.iu.xsede.org:/var/www/portal/experimentData/test-file.txt"); - dataReplicaLocationModel.setDataLocations(dataLocations); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - } - - @AfterClass - public static void tearDown() throws Exception { - System.out.println("********** TEAR DOWN ************"); - dataCatInit.stopDerbyServer(); - } - - @Test - public void testPublishDataResource(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - org.junit.Assert.assertNotNull(resourceId); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testRemoveDataResource(){ - try { - boolean result = replicaCatalog.removeResource("234234234"); - Assert.assertFalse(result); - String resourceId = replicaCatalog.publishResource(dataResourceModel); - Assert.assertNotNull(resourceId); - result = replicaCatalog.removeResource(resourceId); - Assert.assertTrue(result); - result = replicaCatalog.removeResource(resourceId); - Assert.assertFalse(result); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetDataResource(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - Assert.assertNotNull(resourceId); - DataResourceModel persistedCopy = replicaCatalog.getResource(resourceId); - Assert.assertNotNull(persistedCopy); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testUpdateDataResource(){ - try { - dataResourceModel.setResourceId(UUID.randomUUID().toString()); - boolean result = replicaCatalog.updateResource(dataResourceModel); - Assert.assertFalse(result); - replicaCatalog.publishResource(dataResourceModel); - dataResourceModel.setResourceName("updated-name"); - replicaCatalog.updateResource(dataResourceModel); - dataResourceModel = replicaCatalog.getResource(dataResourceModel.getResourceId()); - Assert.assertTrue(dataResourceModel.getResourceName().equals("updated-name")); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testPublishReplicaLocation(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - dataReplicaLocationModel.setResourceId(resourceId); - String replicaId = replicaCatalog.publishReplicaLocation(dataReplicaLocationModel); - org.junit.Assert.assertNotNull(replicaId); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testRemoveReplicaLocation(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - dataReplicaLocationModel.setResourceId(resourceId); - String replicaId = replicaCatalog.publishReplicaLocation(dataReplicaLocationModel); - boolean result = replicaCatalog.removeReplicaLocation(replicaId); - Assert.assertTrue(result); - result = replicaCatalog.removeReplicaLocation(dataReplicaLocationModel.getReplicaId()); - Assert.assertFalse(result); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetReplicaLocation(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - dataReplicaLocationModel.setResourceId(resourceId); - String replicaId = replicaCatalog.publishReplicaLocation(dataReplicaLocationModel); - DataReplicaLocationModel persistedCopy = replicaCatalog.getReplicaLocation(replicaId); - Assert.assertNotNull(persistedCopy); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testUpdateReplicaLocation(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - dataReplicaLocationModel.setResourceId(resourceId); - String replicaId = replicaCatalog.publishReplicaLocation(dataReplicaLocationModel); - DataReplicaLocationModel persistedCopy = replicaCatalog.getReplicaLocation(replicaId); - persistedCopy.setReplicaDescription("updated-description"); - replicaCatalog.updateReplicaLocation(persistedCopy); - persistedCopy = replicaCatalog.getReplicaLocation(replicaId); - Assert.assertTrue(persistedCopy.getReplicaDescription().equals("updated-description")); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetAllReplicaLocations(){ - try { - String resourceId = replicaCatalog.publishResource(dataResourceModel); - dataReplicaLocationModel.setResourceId(resourceId); - String replicaId = replicaCatalog.publishReplicaLocation(dataReplicaLocationModel); - List<DataReplicaLocationModel> replicaLocationModelList = replicaCatalog.getAllReplicaLocations(resourceId); - Assert.assertTrue(replicaLocationModelList.get(0).getReplicaId().equals(replicaId)); - } catch (ReplicaCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } -} \ No newline at end of file
