Search in sources :

Example 6 with DataProductModel

use of org.apache.airavata.model.data.replica.DataProductModel in project airavata by apache.

the class ReplicaCatalogImpl method getChildDataProducts.

@Override
public List<DataProductModel> getChildDataProducts(String productUri) throws ReplicaCatalogException {
    EntityManager em = null;
    try {
        em = ReplicaCatalogJPAUtils.getEntityManager();
        DataProduct dataProduct = em.find(DataProduct.class, productUri);
        Collection<DataProduct> childProducts = dataProduct.getChildDataProducts();
        ArrayList<DataProductModel> returnModels = new ArrayList<>();
        childProducts.stream().forEach(cp -> {
            returnModels.add(ThriftDataModelConversion.getDataProductModel(cp));
        });
        return returnModels;
    } 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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) ArrayList(java.util.ArrayList) DataProduct(org.apache.airavata.registry.core.replica.catalog.model.DataProduct) ReplicaCatalogException(org.apache.airavata.registry.cpi.ReplicaCatalogException) ReplicaCatalogException(org.apache.airavata.registry.cpi.ReplicaCatalogException) DataProductModel(org.apache.airavata.model.data.replica.DataProductModel)

Example 7 with DataProductModel

use of org.apache.airavata.model.data.replica.DataProductModel in project airavata by apache.

the class RegistryServerHandler method getChildDataProducts.

@Override
public List<DataProductModel> getChildDataProducts(String productUri) throws RegistryServiceException, TException {
    try {
        dataCatalog = RegistryFactory.getReplicaCatalog();
        List<DataProductModel> dataProductModels = dataCatalog.getChildDataProducts(productUri);
        return dataProductModels;
    } catch (RegistryException e) {
        String msg = "Error in retreiving the child products for " + productUri + ".";
        logger.error(msg, e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage(msg + " More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) DataProductModel(org.apache.airavata.model.data.replica.DataProductModel)

Example 8 with DataProductModel

use of org.apache.airavata.model.data.replica.DataProductModel in project airavata by apache.

the class RegistryServerHandler method searchDataProductsByName.

@Override
public List<DataProductModel> searchDataProductsByName(String gatewayId, String userId, String productName, int limit, int offset) throws RegistryServiceException, TException {
    try {
        dataCatalog = RegistryFactory.getReplicaCatalog();
        List<DataProductModel> dataProductModels = dataCatalog.searchDataProductsByName(gatewayId, userId, productName, limit, offset);
        return dataProductModels;
    } catch (RegistryException e) {
        String msg = "Error in searching the data products for name " + productName + ".";
        logger.error(msg, e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage(msg + " More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) DataProductModel(org.apache.airavata.model.data.replica.DataProductModel)

Example 9 with DataProductModel

use of org.apache.airavata.model.data.replica.DataProductModel in project airavata by apache.

the class AiravataServerHandler method getParentDataProduct.

@Override
@SecurityCheck
public DataProductModel getParentDataProduct(AuthzToken authzToken, String productUri) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        DataProductModel result = regClient.getParentDataProduct(productUri);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        String msg = "Error in retreiving the parent data product for " + productUri + ".";
        logger.error(msg, e);
        AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage(msg + " More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) DataProductModel(org.apache.airavata.model.data.replica.DataProductModel) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Aggregations

DataProductModel (org.apache.airavata.model.data.replica.DataProductModel)9 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)6 AiravataException (org.apache.airavata.common.exception.AiravataException)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 TException (org.apache.thrift.TException)3 ArrayList (java.util.ArrayList)2 EntityManager (javax.persistence.EntityManager)2 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)2 RegistryService (org.apache.airavata.registry.api.RegistryService)2 DataProduct (org.apache.airavata.registry.core.replica.catalog.model.DataProduct)2 ReplicaCatalogException (org.apache.airavata.registry.cpi.ReplicaCatalogException)2 java.util (java.util)1 List (java.util.List)1 Query (javax.persistence.Query)1 MDCConstants (org.apache.airavata.common.logging.MDCConstants)1 MDCUtil (org.apache.airavata.common.logging.MDCUtil)1 AiravataUtils (org.apache.airavata.common.utils.AiravataUtils)1 ServerSettings (org.apache.airavata.common.utils.ServerSettings)1 ThriftUtils (org.apache.airavata.common.utils.ThriftUtils)1 ZkConstants (org.apache.airavata.common.utils.ZkConstants)1