use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class MetadataServiceImpl method addMetadataToPath.
@Override
public boolean addMetadataToPath(String path, String attribute, String value, String unit) throws DataGridConnectionRefusedException {
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
boolean isMetadataAdded = false;
logger.debug(path + ": " + attribute + " " + value + " " + unit);
try {
AvuData avuData = new AvuData(attribute, value, unit);
Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
if (obj instanceof DataObject) {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
dataObjectAO.addAVUMetadata(path, avuData);
} else {
CollectionAO collectionAO = irodsServices.getCollectionAO();
collectionAO.addAVUMetadata(path, avuData);
}
isMetadataAdded = true;
} catch (JargonException e) {
logger.error("Error trying to add metadata: " + e);
}
return isMetadataAdded;
}
use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class MetadataServiceImpl method modMetadataFromPath.
@Override
public boolean modMetadataFromPath(String path, String oldAttribute, String oldValue, String oldUnit, String newAttribute, String newValue, String newUnit) throws DataGridConnectionRefusedException {
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
AvuData oldAVUData = new AvuData(oldAttribute, oldValue, oldUnit);
AvuData newAVUData = new AvuData(newAttribute, newValue, newUnit);
Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
if (obj instanceof DataObject) {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
dataObjectAO.modifyAVUMetadata(path, oldAVUData, newAVUData);
} else {
CollectionAO collectionAO = irodsServices.getCollectionAO();
collectionAO.modifyAVUMetadata(path, oldAVUData, newAVUData);
}
} catch (JargonException e) {
logger.error("Error trying to modify metadata: " + e.toString());
return false;
}
return true;
}
use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getPermissionsForPath.
@Override
public String getPermissionsForPath(String path) throws DataGridConnectionRefusedException {
logger.info("getPermissionsForPath()");
FilePermissionEnum filePermissionEnum = null;
String permissionType = "none";
try {
String user = irodsServices.getCurrentUser();
String zone = irodsServices.getCurrentUserZone();
Object obj = irodsServices.getCollectionAndDataObjectListAndSearchAO().getFullObjectForType(path);
if (obj instanceof Collection) {
CollectionAO collectionAO = irodsServices.getCollectionAO();
filePermissionEnum = collectionAO.getPermissionForCollection(path, user, zone);
} else {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
filePermissionEnum = dataObjectAO.getPermissionForDataObject(path, user, zone);
}
if (filePermissionEnum != null) {
permissionType = filePermissionEnum.toString().toLowerCase();
}
} catch (FileNotFoundException e) {
logger.error("Could not find path: {}", e.getMessage());
} catch (JargonException e) {
logger.error("Could not get permission for path: {}", e.getMessage());
}
return permissionType;
}
use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listInheritanceForPath.
@Override
public Set<String> listInheritanceForPath(String path) throws DataGridConnectionRefusedException {
logger.info("listInheritanceForPath()");
Set<String> collections = new HashSet<String>();
CollectionAO collectionAO = irodsServices.getCollectionAO();
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
List<CollectionAndDataObjectListingEntry> collList = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPathWithPermissions(path, 0);
for (CollectionAndDataObjectListingEntry collEntry : collList) {
String currentCollPath = collEntry.getPathOrName();
if (collectionAO.isCollectionSetForPermissionInheritance(currentCollPath)) {
collections.add(currentCollPath);
}
}
return collections;
} catch (JargonException e) {
logger.error("Could not get collections with inheritance option enabled: ", e);
}
return null;
}
use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method countAll.
@Override
public int countAll() throws DataGridConnectionRefusedException {
logger.info("countAll()");
CollectionAO collectionAO = irodsServices.getCollectionAO();
try {
return collectionAO.countAllFilesUnderneathTheGivenCollection(IRODS_PATH_SEPARATOR);
} catch (JargonException e) {
logger.error("Could not count all files in the data grid: ", e);
}
return 0;
}
Aggregations