use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class GroupServiceImpl method updateReadPermissions.
@Override
public boolean updateReadPermissions(DataGridGroup group, Map<String, Boolean> addCollectionsToRead, Map<String, Boolean> removeCollectionsToRead) throws DataGridConnectionRefusedException {
CollectionAO collectionAO = irodsServices.getCollectionAO();
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
try {
for (String path : addCollectionsToRead.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.setAccessPermissionReadAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), addCollectionsToRead.get(path));
} else {
dataObjectAO.setAccessPermissionReadInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
for (String path : removeCollectionsToRead.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.removeAccessPermissionForUserAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), removeCollectionsToRead.get(path));
} else {
dataObjectAO.setAccessPermissionReadInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
return true;
} catch (JargonException | DataGridException e) {
logger.error("Could not set read permission:", e);
}
return false;
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class MetadataServiceImpl method findMetadataValuesByPath.
@Override
public List<DataGridMetadata> findMetadataValuesByPath(String path) throws DataGridConnectionRefusedException {
List<MetaDataAndDomainData> metadataList;
List<DataGridMetadata> dataGridMetadataList = new ArrayList<>();
List<MetaDataAndDomainData> resultingList;
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
if (obj instanceof DataObject) {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
metadataList = dataObjectAO.findMetadataValuesForDataObject(path);
} else {
CollectionAO collectionAO = irodsServices.getCollectionAO();
metadataList = collectionAO.findMetadataValuesForCollection(path);
}
// TODO2: Making sure all AVUs are unique. Jargon should do that.
resultingList = new ArrayList<>();
Set<Integer> setOfAlreadyListedAVUs = new HashSet<>();
for (MetaDataAndDomainData avuForItem : metadataList) {
int avuId = avuForItem.getAvuId();
if (!setOfAlreadyListedAVUs.contains(avuId)) {
resultingList.add(avuForItem);
setOfAlreadyListedAVUs.add(avuId);
}
}
for (MetaDataAndDomainData metadata : resultingList) {
DataGridMetadata dataGridMetadata = new DataGridMetadata();
dataGridMetadata.setAttribute(metadata.getAvuAttribute());
dataGridMetadata.setValue(metadata.getAvuValue());
dataGridMetadata.setUnit(metadata.getAvuUnit());
dataGridMetadataList.add(dataGridMetadata);
}
Collections.sort(dataGridMetadataList);
} catch (JargonQueryException e) {
logger.error("Error getting metadata info from collection: " + e.toString());
} catch (JargonException e) {
logger.error("Error getting metadata info from dataobject: " + e.toString());
}
return dataGridMetadataList;
}
use of org.irods.jargon.core.pub.DataObjectAO 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.DataObjectAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getChecksum.
@Override
public String getChecksum(String path) throws DataGridConnectionRefusedException {
logger.info("getChecksum()");
logger.debug("Getting checksum 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.getChecksum();
}
return new String();
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listReplicasByResource.
@Override
public Map<DataGridCollectionAndDataObject, DataGridResource> listReplicasByResource(String path) throws DataGridConnectionRefusedException {
logger.info("listReplicasByResource()");
logger.info("Listing all replicas of " + path);
Map<DataGridCollectionAndDataObject, DataGridResource> map = new HashMap<DataGridCollectionAndDataObject, DataGridResource>();
String collectionAbsPath = null;
String fileName = null;
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
try {
collectionAbsPath = path.substring(0, path.lastIndexOf(IRODS_PATH_SEPARATOR));
fileName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR) + 1, path.length());
List<DataObject> replicas = dataObjectAO.listReplicationsForFile(collectionAbsPath, fileName);
for (DataObject replica : replicas) {
DataGridCollectionAndDataObject dataGridCollectionAndDataObject = DataGridUtils.getDataGridCollectionAndDataObject(replica);
DataGridResource dataGridResource = resourceService.find(replica.getResourceName());
map.put(dataGridCollectionAndDataObject, dataGridResource);
}
} catch (JargonException e) {
logger.error("Could not list replicas by resource for " + path);
}
return DataGridUtils.sortReplicaResourceMap(map);
}
Aggregations