Skip to content

Commit

Permalink
#1 merge latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Oct 30, 2018
1 parent 4997fc7 commit bb7fa52
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 134 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Copyright (c) 2018, University of North Carolina at Chapel Hill */
/* Copyright (c) 2015-2017, Dell EMC */


/* Copyright (c) 2018, University of North Carolina at Chapel Hill */
/* Copyright (c) 2015-2017, Dell EMC */

package com.emc.metalnx.services.configuration;

Expand Down Expand Up @@ -78,6 +76,9 @@ public class ConfigServiceImpl implements ConfigService {
@Value("${access.proxy}")
private boolean handleNoAccessViaProxy;

@Value("${irods.auth.scheme}")
private String defaultIrodsAuthScheme;

@Override
public GlobalConfig getGlobalConfig() {
logger.info("getGlobalConfig()");
Expand Down Expand Up @@ -174,43 +175,45 @@ public void setTicketsEnabled(boolean ticketsEnabled) {

@Override
public String toString() {
final int maxLen = 10;
StringBuilder builder = new StringBuilder();
builder.append("ConfigServiceImpl [");
if (msiAPIVersionSupported != null) {
builder.append("msiAPIVersionSupported=").append(msiAPIVersionSupported).append(", ");
}
if (mlxMSIsExpected != null) {
builder.append("mlxMSIsExpected=").append(mlxMSIsExpected).append(", ");
}
if (irods41MSIsExpected != null) {
builder.append("irods41MSIsExpected=").append(irods41MSIsExpected).append(", ");
}
if (irods42MSIsExpected != null) {
builder.append("irods42MSIsExpected=").append(irods42MSIsExpected).append(", ");
}
if (otherMSIsExpected != null) {
builder.append("otherMSIsExpected=").append(otherMSIsExpected).append(", ");
}
if (irodsHost != null) {
builder.append("irodsHost=").append(irodsHost).append(", ");
}
if (irodsPort != null) {
builder.append("irodsPort=").append(irodsPort).append(", ");
}
if (irodsZone != null) {
builder.append("irodsZone=").append(irodsZone).append(", ");
}
if (irodsJobUser != null) {
builder.append("irodsJobUser=").append(irodsJobUser).append(", ");
}

if (irodsAuthScheme != null) {
builder.append("irodsAuthScheme=").append(irodsAuthScheme).append(", ");
}
builder.append("populateMsiEnabled=").append(populateMsiEnabled).append(", ticketsEnabled=")
builder.append("ConfigServiceImpl [msiAPIVersionSupported=").append(msiAPIVersionSupported)
.append(", mlxMSIsExpected=").append(mlxMSIsExpected).append(", irods41MSIsExpected=")
.append(irods41MSIsExpected).append(", irods42MSIsExpected=").append(irods42MSIsExpected)
.append(", otherMSIsExpected=").append(otherMSIsExpected).append(", irodsHost=").append(irodsHost)
.append(", irodsPort=").append(irodsPort).append(", irodsZone=").append(irodsZone)
.append(", irodsJobUser=").append(irodsJobUser).append(", irodsAuthScheme=").append(irodsAuthScheme)
.append(", populateMsiEnabled=").append(populateMsiEnabled).append(", ticketsEnabled=")
.append(ticketsEnabled).append(", uploadRulesEnabled=").append(uploadRulesEnabled)
.append(", downloadLimit=").append(downloadLimit).append(", handleNoAccessViaProxy=")
.append(handleNoAccessViaProxy).append("]");
.append(handleNoAccessViaProxy).append(", defaultIrodsAuthScheme=").append(defaultIrodsAuthScheme)
.append(", getGlobalConfig()=").append(getGlobalConfig()).append(", getMsiAPIVersionSupported()=")
.append(getMsiAPIVersionSupported()).append(", getMlxMSIsExpected()=")
.append(getMlxMSIsExpected() != null
? getMlxMSIsExpected().subList(0, Math.min(getMlxMSIsExpected().size(), maxLen))
: null)
.append(", getIrods41MSIsExpected()=")
.append(getIrods41MSIsExpected() != null
? getIrods41MSIsExpected().subList(0, Math.min(getIrods41MSIsExpected().size(), maxLen))
: null)
.append(", getIrods42MSIsExpected()=")
.append(getIrods42MSIsExpected() != null
? getIrods42MSIsExpected().subList(0, Math.min(getIrods42MSIsExpected().size(), maxLen))
: null)
.append(", getOtherMSIsExpected()=")
.append(getOtherMSIsExpected() != null
? getOtherMSIsExpected().subList(0, Math.min(getOtherMSIsExpected().size(), maxLen))
: null)
.append(", getIrodsHost()=").append(getIrodsHost()).append(", getIrodsPort()=").append(getIrodsPort())
.append(", getIrodsZone()=").append(getIrodsZone()).append(", getIrodsJobUser()=")
.append(getIrodsJobUser()).append(", getIrodsJobPassword()=").append(getIrodsJobPassword())
.append(", getIrodsAuthScheme()=").append(getIrodsAuthScheme()).append(", getDownloadLimit()=")
.append(getDownloadLimit()).append(", isPopulateMsiEnabled()=").append(isPopulateMsiEnabled())
.append(", isTicketsEnabled()=").append(isTicketsEnabled()).append(", isUploadRulesEnabled()=")
.append(isUploadRulesEnabled()).append(", isHandleNoAccessViaProxy()=")
.append(isHandleNoAccessViaProxy()).append(", getDefaultIrodsAuthScheme()=")
.append(getDefaultIrodsAuthScheme()).append(", getClass()=").append(getClass()).append(", hashCode()=")
.append(hashCode()).append(", toString()=").append(super.toString()).append("]");
return builder.toString();
}

Expand All @@ -230,4 +233,13 @@ public boolean isHandleNoAccessViaProxy() {
public void setHandleNoAccessViaProxy(boolean handleNoAccessViaProxy) {
this.handleNoAccessViaProxy = handleNoAccessViaProxy;
}

@Override
public String getDefaultIrodsAuthScheme() {
return defaultIrodsAuthScheme;
}

public void setDefaultIrodsAuthScheme(String defaultIrodsAuthScheme) {
this.defaultIrodsAuthScheme = defaultIrodsAuthScheme;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Copyright (c) 2018, University of North Carolina at Chapel Hill */
/* Copyright (c) 2015-2017, Dell EMC */


/* Copyright (c) 2018, University of North Carolina at Chapel Hill */
/* Copyright (c) 2015-2017, Dell EMC */

package com.emc.metalnx.services.irods;

Expand Down Expand Up @@ -172,6 +170,68 @@ public boolean isDataObject(String path) throws DataGridConnectionRefusedExcepti
return !isCollection(path);
}

@Override
public boolean canUserAccessThisPath(String path) throws DataGridException {
logger.info("canUserAccessThisPath()");
if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("null or empty path");
}
logger.info("path:{}", path);
CollectionAndDataObjectListAndSearchAO lister = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
lister.retrieveObjectStatForPath(path);
return true;
} catch (FileNotFoundException fnf) {
logger.warn("no access to file");
return false;
} catch (JargonException e) {
logger.error("exception obtaining objStat", e);
throw new DataGridException(e);
}
}

@Override
@SuppressWarnings("unchecked")
public DataProfile<IRODSDomainObject> getCollectionDataProfileAsProxyAdmin(String path)
throws FileNotFoundException, DataGridException {

logger.info("getCollectionDataProfileAsProxyAdmin()");
IRODSAccount irodsAccount = irodsServices.getIrodsAdminAccount();

if (path == null) {
throw new IllegalArgumentException("null path");
}

logger.info("path:{}", path);

DataProfilerSettings dataProfilerSettings = new DataProfilerSettings();
dataProfilerSettings.setDetectMimeAndInfoType(true);
dataProfilerSettings.setRetrieveAcls(false);
dataProfilerSettings.setRetrieveMetadata(true);
dataProfilerSettings.setRetrieveReplicas(false);
dataProfilerSettings.setRetrieveShared(false);
dataProfilerSettings.setRetrieveStarred(false);
dataProfilerSettings.setRetrieveTickets(false);

DataProfilerService dataProfilerService = dataProfilerFactory.instanceDataProfilerService(irodsAccount,
dataProfilerSettings);

try {
@SuppressWarnings("rawtypes")
DataProfile dataProfile = dataProfilerService.retrieveDataProfile(path);
logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
logger.info("data profile retrieved:{}", dataProfile);
return dataProfile;
} catch (FileNotFoundException fnf) {
logger.warn("file not found for path:{}", path);
throw fnf;
} catch (JargonException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path, e);
throw new DataGridException(e.getMessage());
}

}

@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated(
String parentPath, String searchText, int pageNum, int pageSize, int orderColumn, String orderDir,
Expand Down Expand Up @@ -241,26 +301,6 @@ public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnde
return dataGridCollectionAndDataObjects;
}

@Override
public boolean canUserAccessThisPath(String path) throws DataGridException {
logger.info("canUserAccessThisPath()");
if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("null or empty path");
}
logger.info("path:{}", path);
CollectionAndDataObjectListAndSearchAO lister = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
lister.retrieveObjectStatForPath(path);
return true;
} catch (FileNotFoundException fnf) {
logger.warn("no access to file");
return false;
} catch (JargonException e) {
logger.error("exception obtaining objStat", e);
throw new DataGridException(e);
}
}

@Override
public String getPermissionsForPath(String path) throws DataGridConnectionRefusedException {

Expand Down Expand Up @@ -500,6 +540,58 @@ public DataGridCollectionAndDataObject findByName(String path) throws FileNotFou
return dataGridCollectionAndDataObject;
}

@Override
public void modifyInheritance(String path, boolean inheritOption, boolean recursive) throws DataGridException {
logger.info("modifyInheritance()");
if (path == null || path.isEmpty()) {
logger.error("null or empty path:{}");
throw new IllegalArgumentException("null or empty path");
}

logger.info("path:{}", path);
logger.info("inheritOption:{}", inheritOption);
logger.info("recursive:{}", recursive);

// if role is admin, use the admin option for this operation
boolean asAdmin = this.getIrodsServices().isActingAsAdmin();
logger.info("acting as an admin");
CollectionAO collectionAO = irodsServices.getCollectionAO();
IRODSFileSystemAO irodsFileSystemAO = irodsServices.getIRODSFileSystemAO();

try {

String zoneName = irodsFileSystemAO.getIRODSServerProperties().getRodsZone();

if (!asAdmin) {
logger.info("acting as an normal user");
if (inheritOption) {
logger.debug("Setting inheritance option on {}", path);
collectionAO.setAccessPermissionInherit(zoneName, path, recursive);
}
// disable inheritance for this collection
else {
logger.debug("Removing inheritance setting on {}", path);
collectionAO.setAccessPermissionToNotInherit(zoneName, path, recursive);
}
} else {
logger.info("acting as a administrator");
if (inheritOption) {
logger.debug("Setting inheritance option on {}", path);
collectionAO.setAccessPermissionInheritAsAdmin(zoneName, path, recursive);
}
// disable inheritance for this collection
else {
logger.debug("Removing inheritance setting on {}", path);
collectionAO.setAccessPermissionToNotInheritInAdminMode(zoneName, path, recursive);
}

}
} catch (JargonException je) {
throw new DataGridException(je);
}

}

@Override
public boolean modifyCollectionAndDataObject(String previousPath, String newPath, boolean inheritOption)
throws DataGridConnectionRefusedException {
Expand Down Expand Up @@ -1424,7 +1516,8 @@ public void setFileOperationService(FileOperationService fileOperationService) {

@SuppressWarnings("unchecked")
@Override
public DataProfile<IRODSDomainObject> getCollectionDataProfile(String path) throws FileNotFoundException , DataGridException {
public DataProfile<IRODSDomainObject> getCollectionDataProfile(String path)
throws FileNotFoundException, DataGridException {
IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();

logger.info("path:{}", path);
Expand All @@ -1446,47 +1539,6 @@ public DataProfile<IRODSDomainObject> getCollectionDataProfile(String path) thro

}

@Override
@SuppressWarnings("unchecked")
public DataProfile<IRODSDomainObject> getCollectionDataProfileAsProxyAdmin(String path) throws FileNotFoundException, DataGridException {

logger.info("getCollectionDataProfileAsProxyAdmin()");
IRODSAccount irodsAccount = irodsServices.getIrodsAdminAccount();

if (path == null) {
throw new IllegalArgumentException("null path");
}

logger.info("path:{}", path);

DataProfilerSettings dataProfilerSettings = new DataProfilerSettings();
dataProfilerSettings.setDetectMimeAndInfoType(true);
dataProfilerSettings.setRetrieveAcls(false);
dataProfilerSettings.setRetrieveMetadata(true);
dataProfilerSettings.setRetrieveReplicas(false);
dataProfilerSettings.setRetrieveShared(false);
dataProfilerSettings.setRetrieveStarred(false);
dataProfilerSettings.setRetrieveTickets(false);

DataProfilerService dataProfilerService = dataProfilerFactory.instanceDataProfilerService(irodsAccount,
dataProfilerSettings);

try {
@SuppressWarnings("rawtypes")
DataProfile dataProfile = dataProfilerService.retrieveDataProfile(path);
logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
logger.info("data profile retrieved:{}", dataProfile);
return dataProfile;
} catch (FileNotFoundException fnf) {
logger.warn("file not found for path:{}", path);
throw fnf;
} catch (JargonException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path, e);
throw new DataGridException(e.getMessage());
}

}

public SpecificQueryProviderFactory getSpecificQueryProviderFactory() {
return specificQueryProviderFactory;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* Copyright (c) 2018, University of North Carolina at Chapel Hill */
/* Copyright (c) 2015-2017, Dell EMC */


/* Copyright (c) 2018, University of North Carolina at Chapel Hill */
/* Copyright (c) 2015-2017, Dell EMC */

package com.emc.metalnx.services.irods;

Expand Down Expand Up @@ -489,6 +487,11 @@ public IRODSAccessObjectFactory getIrodsAccessObjectFactory() {
return irodsAccessObjectFactory;
}

@Override
public boolean isActingAsAdmin() {
return this.getUserTokenDetails().getUser().isAdmin();
}

public UserTokenDetails getUserTokenDetails() {
return userTokenDetails;
}
Expand Down
Loading

0 comments on commit bb7fa52

Please sign in to comment.