use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO in project metalnx-web by irods-contrib.
the class MetadataServiceImpl method delMetadataFromPath.
@Override
public boolean delMetadataFromPath(String path, String attribute, String value, String unit) throws DataGridConnectionRefusedException {
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
AvuData avuData = new AvuData(attribute, value, unit);
Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
if (obj instanceof DataObject) {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
dataObjectAO.deleteAVUMetadata(path, avuData);
} else {
CollectionAO collectionAO = irodsServices.getCollectionAO();
collectionAO.deleteAVUMetadata(path, avuData);
}
} catch (JargonException e) {
logger.error("Error trying to delete metadata: " + e.toString());
return false;
}
return true;
}
use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listCollectionsWithPermissionsForEntity.
/**
* Auxiliary method that filters the directories with the specified permission
* level for the given entity, that can be an user or a group
*
* @param path
* The path for which we would like to list the objects with
* permissions
* @param entityName
* The entity name
* @param permissionType
* The permission stype
* @param entityType
* The entity type that can be user or group
* @return
* @throws DataGridConnectionRefusedException
*/
private Set<String> listCollectionsWithPermissionsForEntity(String path, String entityName, FilePermissionEnum permissionType, String entityType) throws DataGridConnectionRefusedException {
logger.info("listCollectionsWithPermissionsForEntity()");
Set<String> collections = new HashSet<String>();
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
List<CollectionAndDataObjectListingEntry> collList = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(path);
logger.info("Getting permissions and bookmarks for path {}", path);
for (CollectionAndDataObjectListingEntry collEntry : collList) {
String filePath = "";
if (collEntry.isCollection()) {
filePath = collEntry.getPathOrName();
} else {
filePath = collEntry.getParentPath() + IRODS_PATH_SEPARATOR + collEntry.getPathOrName();
if (collEntry.getParentPath().compareTo(IRODS_PATH_SEPARATOR) == 0) {
filePath = collEntry.getParentPath() + collEntry.getPathOrName();
}
}
List<DataGridFilePermission> permissions = permissionsService.getPathPermissionDetails(filePath, entityName);
// Deciding whether we should get permissions for users or groups
if (entityType.compareTo("user") == 0) {
// Filtering permissions for users
List<DataGridUserPermission> userPermissions = permissionsService.getUsersWithPermissions(permissions);
// Adding collections with permissions into the result list
for (DataGridUserPermission dataGridUserPermission : userPermissions) {
if (dataGridUserPermission.getPermission().equalsIgnoreCase(permissionType.name())) {
collections.add(filePath);
}
}
} else {
// Filtering permissions for groups
List<DataGridGroupPermission> groupPermissions = permissionsService.getGroupsWithPermissions(permissions);
// Adding collections with permissions into the result list
for (DataGridGroupPermission dataGridGroupPermission : groupPermissions) {
if (dataGridGroupPermission.getPermission().equalsIgnoreCase(permissionType.name())) {
collections.add(filePath);
}
}
}
}
} catch (JargonException e) {
logger.error("Could not get permissions: ", e);
}
return collections;
}
use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getSubCollectionsUnderPath.
@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsUnderPath(String parent) throws DataGridConnectionRefusedException {
logger.info("getSubCollectionsUnderPath()");
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
try {
List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPath(parent, 0);
dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
return dataGridCollectionAndDataObjects;
} catch (FileNotFoundException e) {
logger.error("Could not locate file: ", e);
} catch (JargonException e) {
logger.error("Error: ", e);
}
return dataGridCollectionAndDataObjects;
}
use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getSubCollectionsAndDataObjectsUnderPath.
@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPath(String parent) throws DataGridConnectionRefusedException, JargonException {
logger.info("getSubCollectionsAndDataObjectsUnderPath()");
if (parent == null || parent.isEmpty()) {
throw new IllegalArgumentException("null or empty parent");
}
logger.info("parent:{}", parent);
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
try {
List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(parent);
dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
return dataGridCollectionAndDataObjects;
} catch (FileNotFoundException e) {
logger.error("Could not locate file: ", e);
throw e;
} catch (JargonException e) {
logger.error("Error: ", e);
throw e;
}
}
use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method findByName.
@Override
public DataGridCollectionAndDataObject findByName(String path) throws FileNotFoundException, DataGridException {
logger.info("findByName()");
if (path == null || path.isEmpty()) {
logger.info("Could not find collection or data object by name: path is null");
return null;
}
logger.info("Find collection or data object by name: {}", path);
CollectionAndDataObjectListAndSearchAO objectsAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
DataGridCollectionAndDataObject dataGridCollectionAndDataObject;
try {
CollectionAndDataObjectListingEntry entry = objectsAO.getCollectionAndDataObjectListingEntryAtGivenAbsolutePathWithHeuristicPathGuessing(path);
dataGridCollectionAndDataObject = this.mapListingEntryToDataGridCollectionAndDataObject(entry);
} catch (FileNotFoundException fnf) {
logger.warn("file not found for path:{}", path);
throw fnf;
} catch (JargonException e) {
logger.debug("error finding collection/data object by name: {}", path);
throw new DataGridException("Could not find path " + path);
}
return dataGridCollectionAndDataObject;
}
Aggregations