Search in sources :

Example 11 with UnsupportedDataGridFeatureException

use of com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException in project metalnx-web by irods-contrib.

the class SpecQueryServiceImpl method searchByMetadata.

@Override
public SpecificQueryResultSet searchByMetadata(List<DataGridMetadataSearch> metadataSearch, String zone, boolean searchAgainstColls, DataGridPageContext pageContext, int offset, int limit) throws DataGridConnectionRefusedException, JargonException {
    SpecificQueryAO specificQueryAO = null;
    SpecificQuery specQuery = null;
    SpecificQueryResultSet queryResultSet = null;
    String userSQLAlias = "metalnxUserQuery_" + System.currentTimeMillis();
    try {
        specificQueryAO = adminServices.getSpecificQueryAO();
        ClientHints clientHints = this.irodsServices.getEnvironmentalInfoAO().retrieveClientHints(false);
        SpecificQueryProvider provider = specificQueryProviderFactory.instance(clientHints.whatTypeOfIcatIsIt());
        String query = provider.buildSpecificQueryForMetadataSearch(metadataSearch, zone, searchAgainstColls);
        // Creating Specific Query instance
        SpecificQueryDefinition queryDef = new SpecificQueryDefinition();
        queryDef.setAlias(userSQLAlias);
        queryDef.setSql(query);
        // Creating spec query on iRODS
        specificQueryAO.addSpecificQuery(queryDef);
        specQuery = SpecificQuery.instanceWithNoArguments(userSQLAlias, 0, zone);
        logger.info("Specific query: {}", query.toString());
        queryResultSet = specificQueryAO.executeSpecificQueryUsingAlias(specQuery, 99999, 0);
    } catch (JargonException e) {
        logger.error("Could not get specific query: ", e);
        throw e;
    } catch (JargonQueryException e) {
        logger.error("Could not get specific query: ", e);
        throw new JargonException(e);
    } catch (UnsupportedDataGridFeatureException e) {
        logger.error("Could not get specific query: ", e);
        throw new JargonException(e);
    } finally {
        try {
            // after running the user specific query, we need to remove from the database
            specificQueryAO.removeSpecificQueryByAlias(userSQLAlias);
        } catch (JargonException e) {
            logger.error("Could not remove specific query {}: ", userSQLAlias, e.getMessage());
        }
    }
    return queryResultSet;
}
Also used : UnsupportedDataGridFeatureException(com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException) JargonQueryException(org.irods.jargon.core.query.JargonQueryException) SpecificQueryProvider(com.emc.metalnx.services.irods.utils.SpecificQueryProvider) JargonException(org.irods.jargon.core.exception.JargonException) ClientHints(org.irods.jargon.core.pub.domain.ClientHints) SpecificQueryResultSet(org.irods.jargon.core.query.SpecificQueryResultSet) SpecificQuery(org.irods.jargon.core.query.SpecificQuery) SpecificQueryAO(org.irods.jargon.core.pub.SpecificQueryAO) SpecificQueryDefinition(org.irods.jargon.core.pub.domain.SpecificQueryDefinition)

Aggregations

UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)11 JargonException (org.irods.jargon.core.exception.JargonException)8 SpecificQueryResultSet (org.irods.jargon.core.query.SpecificQueryResultSet)8 SpecificQueryProvider (com.emc.metalnx.services.irods.utils.SpecificQueryProvider)7 SpecificQueryAO (org.irods.jargon.core.pub.SpecificQueryAO)7 ClientHints (org.irods.jargon.core.pub.domain.ClientHints)7 SpecificQueryDefinition (org.irods.jargon.core.pub.domain.SpecificQueryDefinition)7 SpecificQuery (org.irods.jargon.core.query.SpecificQuery)7 JargonQueryException (org.irods.jargon.core.query.JargonQueryException)5 ArrayList (java.util.ArrayList)4 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)3 DataGridTicket (com.emc.metalnx.core.domain.entity.DataGridTicket)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ConnectException (java.net.ConnectException)1 HashMap (java.util.HashMap)1 ResponseEntity (org.springframework.http.ResponseEntity)1