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";
}
}
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);
}
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();
}
}
}
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();
}
}
}
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());
}
Aggregations