Skip to content

Commit

Permalink
[irods-contrib/metalnx-web#332] Added new method with createParentCol…
Browse files Browse the repository at this point in the history
…lections
  • Loading branch information
JustinKyleJames authored and michael-conway committed Feb 2, 2023
1 parent bb54bd7 commit 84ee8e1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ public List<DataGridCollectionAndDataObject> getSubCollectionsUnderPath(String p

@Override
public boolean createCollection(DataGridCollectionAndDataObject collection) throws DataGridException {
return createCollection(collection, false);
}

@Override
public boolean createCollection(DataGridCollectionAndDataObject collection, boolean createParentCollections) throws DataGridException {

logger.info("createCollection()");

Expand All @@ -403,7 +408,7 @@ public boolean createCollection(DataGridCollectionAndDataObject collection) thro
IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();

IRODSFile newFile = irodsFileFactory.instanceIRODSFile(collection.getParentPath(), collection.getName());
irodsFileSystemAO.mkdir(newFile, false);
irodsFileSystemAO.mkdir(newFile, createParentCollections);

// Updating inheritance option on the collection, if needed
CollectionAO collectionAO = irodsServices.getCollectionAO();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,34 @@ public void testGetSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPagin

}

@Test
public void testCreateCollectionWithParent() throws Exception {

IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

IRODSServicesImpl irodsServices = new IRODSServicesImpl();
irodsServices.setIrodsAccount(irodsAccount);
irodsServices.irodsAccessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory();

CollectionServiceImpl collectionService = new CollectionServiceImpl();
collectionService.setIrodsServices(irodsServices);

// get new collection as DataGridCollectionAndDataObject
String newSubCollection = "subdir1/subdir2";

String currentPath = irodsAccount.getHomeDirectory();
String fullPath = currentPath + '/' + newSubCollection;

DataGridCollectionAndDataObject newCollection = new DataGridCollectionAndDataObject(
fullPath, newSubCollection, currentPath, true);

// create new collection
collectionService.createCollection(newCollection, true);

// search for new collection
List<DataGridCollectionAndDataObject> actual = collectionService.searchCollectionAndDataObjectsByName(fullPath);

Assert.assertTrue("actual number of matching collections is not 1", actual.size() == 1);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.emc.metalnx.services.unittests;

import com.emc.metalnx.services.irods.CollectionServiceImplTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({ CollectionServiceImplTest.class })
public class AllTests {

}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPath(S
* @throws DataGridException
*/
boolean createCollection(DataGridCollectionAndDataObject newCollection) throws DataGridException;

/**
* Create a collection in iRODS
*
* @param newCollection
* @param createParentCollections
* @throws DataGridException
*/
boolean createCollection(DataGridCollectionAndDataObject newCollection, boolean createParentCollections) throws DataGridException;

/**
* Find collections that match the parameter name
Expand Down

0 comments on commit 84ee8e1

Please sign in to comment.