Search in sources :

Example 11 with IRODSAccount

use of org.irods.jargon.core.connection.IRODSAccount in project metalnx-web by irods-contrib.

the class PreviewPreparationController method getPreview.

/**
 * Responds the preview/ request
 *
 * @param model
 * @return the collection management template
 * @throws DataGridConnectionRefusedException
 * @throws JargonException
 * @throws DataGridException
 */
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getPreview(final Model model, @RequestParam("path") final String path, RedirectAttributes redirectAttributes) throws DataGridException {
    logger.info("prepareForPreview for {} ::" + path);
    String mimeType = null;
    boolean permission = previewService.getPermission(path);
    if (permission) {
        try {
            IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();
            DataTypeResolutionService dataTypeResolutionService = dataTypeResolutionServiceFactory.instanceDataTypeResolutionService(irodsAccount);
            logger.info("dataTypeResolutionService created from factory:{}", dataTypeResolutionService);
            logger.info("doing quick check for mime type");
            mimeType = dataTypeResolutionService.quickMimeType(path);
            logger.info("mimetype:{}", mimeType);
            redirectAttributes.addAttribute("path", path);
            redirectAttributes.addAttribute("mimeType", mimeType);
            return "redirect:/preview/templateByMimeType";
        } catch (JargonException e) {
            logger.error("Could not retrieve data from path: {}", path, e);
            throw new DataGridException(e.getMessage());
        } catch (Exception e) {
            logger.error("general exception generating preview", e);
            throw new DataGridException(e.getLocalizedMessage());
        }
    } else {
        return "collections/preview :: noPermission";
    }
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) JargonException(org.irods.jargon.core.exception.JargonException) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException) DataTypeResolutionService(org.irods.jargon.extensions.datatyper.DataTypeResolutionService) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with IRODSAccount

use of org.irods.jargon.core.connection.IRODSAccount in project metalnx-web by irods-contrib.

the class CollectionServiceImplTest method testGetSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated.

@Test
public void testGetSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated() throws Exception {
    CollectionServiceImpl collectionService = new CollectionServiceImpl();
    IRODSServices irodsService = Mockito.mock(IRODSServices.class);
    AdminServices adminServices = Mockito.mock(AdminServices.class);
    IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
    EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem.getIRODSAccessObjectFactory().getEnvironmentalInfoAO(irodsAccount);
    CollectionAndDataObjectListAndSearchAO listAndSearchAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAndDataObjectListAndSearchAO(irodsAccount);
    SpecificQueryAO specificQueryAO = irodsFileSystem.getIRODSAccessObjectFactory().getSpecificQueryAO(irodsAccount);
    Mockito.when(irodsService.getEnvironmentalInfoAO()).thenReturn(environmentalInfoAO);
    Mockito.when(irodsService.getCollectionAndDataObjectListAndSearchAO()).thenReturn(listAndSearchAO);
    Mockito.when(adminServices.getSpecificQueryAO()).thenReturn(specificQueryAO);
    collectionService.setIrodsServices(irodsService);
    collectionService.setAdminServices(adminServices);
    List<DataGridCollectionAndDataObject> actual = collectionService.searchCollectionAndDataObjectsByName("textSearch");
    Assert.assertTrue("no recs returned", actual.size() > 1);
}
Also used : EnvironmentalInfoAO(org.irods.jargon.core.pub.EnvironmentalInfoAO) CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) AdminServices(com.emc.metalnx.services.interfaces.AdminServices) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) IRODSServices(com.emc.metalnx.services.interfaces.IRODSServices) SpecificQueryAO(org.irods.jargon.core.pub.SpecificQueryAO) Test(org.junit.Test)

Example 13 with IRODSAccount

use of org.irods.jargon.core.connection.IRODSAccount in project metalnx-web by irods-contrib.

the class SyncJobs method authenticateIRODSAccount.

private void authenticateIRODSAccount() throws JargonException {
    AuthResponse authResponse = null;
    if (this.irodsAccount == null) {
        // Getting iRODS protocol set
        IRODSAccount tempAccount = IRODSAccount.instance(irodsHost, Integer.parseInt(irodsPort), irodsJobUser, irodsJobPassword, "", irodsZone, "demoResc");
        tempAccount.setAuthenticationScheme(AuthScheme.findTypeByString(irodsAuthScheme));
        authResponse = irodsAccessObjectFactory.authenticateIRODSAccount(tempAccount);
        if (authResponse.isSuccessful()) {
            this.irodsAccount = authResponse.getAuthenticatedIRODSAccount();
        }
    }
}
Also used : IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) AuthResponse(org.irods.jargon.core.connection.auth.AuthResponse)

Example 14 with IRODSAccount

use of org.irods.jargon.core.connection.IRODSAccount in project metalnx-web by irods-contrib.

the class AdminServicesImpl method authenticateIRODSAccount.

private void authenticateIRODSAccount() throws JargonException {
    String host = configService.getIrodsHost();
    int port = Integer.parseInt(configService.getIrodsPort());
    String zone = configService.getIrodsZone();
    String user = configService.getIrodsJobUser();
    String password = configService.getIrodsJobPassword();
    String authScheme = configService.getIrodsAuthScheme();
    String resc = "demoResc";
    String homeDir = "";
    if (irodsAccount == null) {
        IRODSAccount tempAccount = IRODSAccount.instance(host, port, user, password, homeDir, zone, resc);
        tempAccount.setAuthenticationScheme(AuthScheme.findTypeByString(authScheme));
        AuthResponse authResponse = irodsAccessObjectFactory.authenticateIRODSAccount(tempAccount);
        if (authResponse.isSuccessful()) {
            irodsAccount = authResponse.getAuthenticatedIRODSAccount();
        }
    }
}
Also used : IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) AuthResponse(org.irods.jargon.core.connection.auth.AuthResponse)

Example 15 with IRODSAccount

use of org.irods.jargon.core.connection.IRODSAccount in project metalnx-web by irods-contrib.

the class SpecQueryServiceImplTest method testSearchByMetadataDataObjects.

@Test
public void testSearchByMetadataDataObjects() throws Exception {
    SpecQueryServiceImpl specQueryService = new SpecQueryServiceImpl();
    IRODSServices irodsService = Mockito.mock(IRODSServices.class);
    AdminServices adminServices = Mockito.mock(AdminServices.class);
    IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
    EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem.getIRODSAccessObjectFactory().getEnvironmentalInfoAO(irodsAccount);
    SpecificQueryAO specificQueryAO = irodsFileSystem.getIRODSAccessObjectFactory().getSpecificQueryAO(irodsAccount);
    Mockito.when(irodsService.getEnvironmentalInfoAO()).thenReturn(environmentalInfoAO);
    Mockito.when(adminServices.getSpecificQueryAO()).thenReturn(specificQueryAO);
    specQueryService.setIrodsServices(irodsService);
    specQueryService.setAdminServices(adminServices);
    List<DataGridMetadataSearch> metadataSearch = new ArrayList<DataGridMetadataSearch>();
    DataGridMetadataSearch search = new DataGridMetadataSearch(DATA_AVU_ATTR1, DATA_AVU_VAL1, "", DataGridSearchOperatorEnum.EQUAL);
    metadataSearch.add(search);
    SpecificQueryResultSet result = specQueryService.searchByMetadata(metadataSearch, irodsAccount.getZone(), false, null, 0, 0);
    Assert.assertFalse("no result", result.getResults().isEmpty());
}
Also used : EnvironmentalInfoAO(org.irods.jargon.core.pub.EnvironmentalInfoAO) AdminServices(com.emc.metalnx.services.interfaces.AdminServices) DataGridMetadataSearch(com.emc.metalnx.core.domain.entity.DataGridMetadataSearch) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) ArrayList(java.util.ArrayList) SpecificQueryResultSet(org.irods.jargon.core.query.SpecificQueryResultSet) IRODSServices(com.emc.metalnx.services.interfaces.IRODSServices) SpecificQueryAO(org.irods.jargon.core.pub.SpecificQueryAO) Test(org.junit.Test)

Aggregations

IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)19 Test (org.junit.Test)10 AdminServices (com.emc.metalnx.services.interfaces.AdminServices)9 IRODSServices (com.emc.metalnx.services.interfaces.IRODSServices)9 EnvironmentalInfoAO (org.irods.jargon.core.pub.EnvironmentalInfoAO)9 SpecificQueryAO (org.irods.jargon.core.pub.SpecificQueryAO)9 ArrayList (java.util.ArrayList)8 DataGridFilePropertySearch (com.emc.metalnx.core.domain.entity.DataGridFilePropertySearch)4 DataGridMetadataSearch (com.emc.metalnx.core.domain.entity.DataGridMetadataSearch)4 SpecificQueryResultSet (org.irods.jargon.core.query.SpecificQueryResultSet)4 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)3 File (java.io.File)3 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)2 AuthResponse (org.irods.jargon.core.connection.auth.AuthResponse)2 JargonException (org.irods.jargon.core.exception.JargonException)2 DataTransferOperations (org.irods.jargon.core.pub.DataTransferOperations)2 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)2 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)2 IRODSTestSetupUtilities (org.irods.jargon.testutils.IRODSTestSetupUtilities)2 TestingPropertiesHelper (org.irods.jargon.testutils.TestingPropertiesHelper)2