use of org.irods.jargon.core.pub.DataObjectAO 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.DataObjectAO 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.DataObjectAO 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.DataObjectAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getTotalNumberOfReplsForDataObject.
@Override
public int getTotalNumberOfReplsForDataObject(String path) throws DataGridException {
logger.info("getTotalNumberOfReplsForDataObject()");
int totalNumberOfRepls = 0;
if (path == null || path.isEmpty()) {
return 0;
}
String parentPath = path.substring(0, path.lastIndexOf(IRODS_PATH_SEPARATOR));
String dataObjectName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR), path.length());
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
// getting total number of replicas
try {
totalNumberOfRepls = dataObjectAO.getTotalNumberOfReplsForDataObject(parentPath, dataObjectName);
} catch (JargonException e) {
logger.error("Could not get number of replicas of a data obj: {}", e.getMessage());
throw new DataGridException(e.getMessage());
}
return totalNumberOfRepls;
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getReplicationNumber.
@Override
public int getReplicationNumber(String path) throws DataGridConnectionRefusedException {
logger.info("getReplicationNumber()");
logger.debug("Getting replication number of " + path);
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
DataObject dataObject = null;
try {
dataObject = dataObjectAO.findByAbsolutePath(path);
} catch (JargonException e) {
logger.error("Could not find a data object matching " + path, e);
}
if (dataObject != null) {
return dataObject.getDataReplicationNumber();
}
return 0;
}
Aggregations