use of org.apache.airavata.registry.cpi.ReplicaCatalogException in project airavata by apache.
the class ReplicaCatalogImpl method updateReplicaLocation.
@Override
public boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.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;
}
use of org.apache.airavata.registry.cpi.ReplicaCatalogException in project airavata by apache.
the class ReplicaCatalogImpl method createDataProduct.
private String createDataProduct(DataProductModel productModel) throws ReplicaCatalogException {
DataProduct dataProduct = ThriftDataModelConversion.getDataProduct(productModel);
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
em.persist(dataProduct);
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 dataProduct.getProductUri();
}
use of org.apache.airavata.registry.cpi.ReplicaCatalogException in project airavata by apache.
the class ReplicaCatalogImpl method getParentDataProduct.
@Override
public DataProductModel getParentDataProduct(String productUri) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
DataProduct dataProduct = em.find(DataProduct.class, productUri);
return ThriftDataModelConversion.getDataProductModel(dataProduct.getParentDataProduct());
} 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();
}
}
}
use of org.apache.airavata.registry.cpi.ReplicaCatalogException in project airavata by apache.
the class ReplicaCatalogImpl method getReplicaLocation.
@Override
public DataReplicaLocationModel getReplicaLocation(String replicaId) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.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();
}
}
}
use of org.apache.airavata.registry.cpi.ReplicaCatalogException in project airavata by apache.
the class ReplicaCatalogImpl method removeDataProduct.
@Override
public boolean removeDataProduct(String productUri) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
DataProduct dataProduct = em.find(DataProduct.class, productUri);
if (dataProduct == null)
return false;
em.getTransaction().begin();
em.remove(dataProduct);
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;
}
Aggregations