Search in sources :

Example 26 with DataGridCollectionAndDataObject

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);
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException)

Example 27 with DataGridCollectionAndDataObject

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";
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with DataGridCollectionAndDataObject

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);
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with DataGridCollectionAndDataObject

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);
    }
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) Before(org.junit.Before)

Example 30 with DataGridCollectionAndDataObject

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);
        }
    }
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) Before(org.junit.Before)

Aggregations

DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)55 JargonException (org.irods.jargon.core.exception.JargonException)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Before (org.junit.Before)11 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)9 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)9 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)7 ArrayList (java.util.ArrayList)7 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)7 DataGridPageContext (com.emc.metalnx.core.domain.entity.DataGridPageContext)6 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)6 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)5 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 JargonQueryException (org.irods.jargon.core.query.JargonQueryException)4 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)3 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3