use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class BrowseController method setBreadcrumbToModel.
/*
* **************************************************************************
* **************************** PRIVATE METHODS *****************************
* **************************************************************************
*/
/**
* Creates the breadcrumb based on a given path.
*
* @param model
* Model attribute to set variables to be used in the view
* @param path
* path that will be displayed in the breadcrumb
* @throws DataGridException
*/
private void setBreadcrumbToModel(final Model model, final String path) throws DataGridException {
DataGridCollectionAndDataObject obj;
try {
obj = cs.findByName(path);
} catch (FileNotFoundException e) {
obj = new DataGridCollectionAndDataObject();
obj.setPath(path);
obj.setCollection(false);
obj.setParentPath(path.substring(0, path.lastIndexOf("/") + 1));
obj.setName(path.substring(path.lastIndexOf("/") + 1, path.length()));
logger.error("Could not find DataGridCollectionAndDataObject by path: {}", e.getMessage());
} catch (DataGridException e) {
logger.error("unable to find path for breadcrumb", e);
throw e;
}
setBreadcrumbToModel(model, obj);
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class BrowseController method getAvailableRescForPath.
/**
* Get a list of resources in which an object doesn't have replicas
*
* @param model
* @return list of resources in which an object can be replicated
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "getAvailableRescForPath/")
public String getAvailableRescForPath(final Model model, @RequestParam("isUpload") final boolean isUpload) throws DataGridConnectionRefusedException {
logger.info("getAvailableRescForPath()");
Map<DataGridCollectionAndDataObject, DataGridResource> replicasMap = null;
List<DataGridResource> resources = resourceService.findFirstLevelResources();
if (!isUpload) {
for (String path : sourcePaths) {
replicasMap = cs.listReplicasByResource(path);
for (DataGridResource resc : replicasMap.values()) {
if (resources.contains(resc)) {
resources.remove(resc);
}
}
}
}
model.addAttribute("resources", resources);
return "collections/collectionsResourcesForReplica";
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class BrowseController method addCollection.
/**
* Performs the action of actually creating a collection in iRODS
*
* @param model
* @param collection
* @return if the creation of collection was successful, it returns the
* collection management template, and returns the add collection
* template, otherwise.
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "add/action", method = RequestMethod.POST)
public String addCollection(final Model model, @ModelAttribute final CollectionOrDataObjectForm collection, final RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
logger.info("addCollection()");
logger.info("collection:{}", collection);
logger.info("redirectAttributes:{}", redirectAttributes);
DataGridCollectionAndDataObject newCollection = new DataGridCollectionAndDataObject(currentPath + '/' + collection.getCollectionName(), collection.getCollectionName(), currentPath, true);
logger.info("newCollection:{}", newCollection);
newCollection.setParentPath(currentPath);
newCollection.setCreatedAt(new Date());
newCollection.setModifiedAt(newCollection.getCreatedAt());
newCollection.setInheritanceOption(collection.getInheritOption());
boolean creationSucessful;
try {
creationSucessful = cs.createCollection(newCollection);
logger.info("creationSuccessful?:{}", creationSucessful);
if (creationSucessful) {
redirectAttributes.addFlashAttribute("collectionAddedSuccessfully", collection.getCollectionName());
}
} catch (DataGridConnectionRefusedException e) {
throw e;
} catch (DataGridException e) {
logger.error("Could not create collection/data object (lack of permission): ", e.getMessage());
redirectAttributes.addFlashAttribute("missingPermissionError", true);
}
return "redirect:/collections?path=" + URLEncoder.encode(currentPath);
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class TestAddDataGridMetadataListToColls method setUp.
@Before
public void setUp() throws DataGridException {
parentPath = String.format("/%s/home/%s", zone, username);
path = String.format("%s/test-metadata-transfer", parentPath);
fos.deleteCollection(path, true);
cs.createCollection(new DataGridCollectionAndDataObject(path, parentPath, true));
expectedMetadataList = new ArrayList<>();
expectedMetadataList.add(new DataGridMetadata("attr1", "val1", "unit1"));
expectedMetadataList.add(new DataGridMetadata("attr2", "val2", "unit2"));
expectedMetadataList.add(new DataGridMetadata("attr3", "val3", "unit3"));
for (int i = 0; i < NUMBER_OF_COLLS; i++) {
String collname = BASE_COLL_NAME + i;
String collPath = String.format("%s/%s", path, collname);
cs.createCollection(new DataGridCollectionAndDataObject(collPath, path, true));
metadataService.addMetadataToPath(collPath, expectedMetadataList);
}
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class TestAddDataGridMetadataToColls method setUp.
@Before
public void setUp() throws DataGridException {
parentPath = String.format("/%s/home/%s", zone, username);
path = String.format("%s/test-metadata-transfer", parentPath);
fos.deleteCollection(path, true);
cs.createCollection(new DataGridCollectionAndDataObject(path, parentPath, true));
expectedMetadataList = MetadataUtils.createRandomMetadata(NUMBER_OF_METADATA_TAGS);
for (int i = 0; i < NUMBER_OF_COLLS; i++) {
String collPath = String.format("%s/%s", path, BASE_COLL_NAME + i);
cs.createCollection(new DataGridCollectionAndDataObject(collPath, path, true));
for (DataGridMetadata metadata : expectedMetadataList) {
metadataService.addMetadataToPath(collPath, metadata);
}
}
}
Aggregations