Skip to content

Commit

Permalink
#63 metalnx wired in data profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Jan 16, 2018
1 parent 9f405cb commit 19df664
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import javax.servlet.http.HttpServletRequest;

import org.irods.jargon.core.connection.IRODSAccount;
import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.extensions.dataprofiler.DataProfile;
import org.irods.jargon.extensions.dataprofiler.DataProfilerFactory;
import org.irods.jargon.extensions.dataprofiler.DataProfilerService;
import org.irods.jargon.extensions.dataprofiler.DataProfilerSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -16,10 +22,10 @@
import org.springframework.web.servlet.HandlerMapping;

import com.emc.metalnx.controller.utils.LoggedUserUtils;
import com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject;
import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException;
import com.emc.metalnx.core.domain.exceptions.DataGridException;
import com.emc.metalnx.services.interfaces.CollectionService;
import com.emc.metalnx.services.interfaces.IRODSServices;
import com.emc.metalnx.services.interfaces.PermissionsService;

@Controller
Expand All @@ -37,35 +43,64 @@ public class CollectionInfoController {
@Autowired
PermissionsService permissionsService;

@Autowired
DataProfilerFactory dataProfilerFactory;

@Autowired
IRODSServices irodsServices;

@Autowired
DataProfilerSettings dataProfilerSettings;

private static final Logger logger = LoggerFactory.getLogger(CollectionInfoController.class);

@RequestMapping(value = "/**", method = RequestMethod.GET)
public String getTestCollectionInfo(final Model model, HttpServletRequest request)
throws DataGridConnectionRefusedException {
throws DataGridException, DataGridConnectionRefusedException {

logger.info("------CollectionInfoController getTestCollectionInfo() starts !!");
final String path = "/" + extractFilePath(request);
logger.info("path ::" + path);
model.addAttribute("summary", "This is comming from the CollectionInfoController() - Test the main controller");

DataGridCollectionAndDataObject dgColObj = null;
IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();
logger.debug("got irodsAccount:{}", irodsAccount);

DataProfilerService dataProfilerService = dataProfilerFactory.instanceDataProfilerService(irodsAccount);

logger.debug("got the dataProfilerService");

// DataProfilerSettings dataProfilerSettings = new DataProfilerSettings(); //
// TODO: allow clone()
try {
dgColObj = collectionService.findByName(path);
permissionsService.resolveMostPermissiveAccessForUser(dgColObj, loggedUserUtils.getLoggedDataGridUser());
} catch (DataGridException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path);
}
model.addAttribute("currentPath", path);
model.addAttribute("collectionAndDataObject", dgColObj);
if (dgColObj != null)
model.addAttribute("flag", true);
else {
model.addAttribute("flag", false);
@SuppressWarnings("rawtypes")
DataProfile dataProfile = dataProfilerService.retrieveDataProfile(path);
logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
logger.info("data profile retrieved:{}", dataProfile);

/*
* TODO: after this do an if test and send to right view with the DataProfile in
* the model
*/

return "collections/info";
} catch (JargonException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path, e);
throw new DataGridException(e.getMessage());
}

logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
return "collections/info";
/*
* DataGridCollectionAndDataObject dgColObj = null;
*
* try { dgColObj = collectionService.findByName(path);
* permissionsService.resolveMostPermissiveAccessForUser(dgColObj,
* loggedUserUtils.getLoggedDataGridUser()); } catch (DataGridException e) {
* logger.error("Could not retrieve collection/dataobject from path: {}", path);
* } model.addAttribute("currentPath", path);
* model.addAttribute("collectionAndDataObject", dgColObj); if (dgColObj !=
* null) model.addAttribute("flag", true); else { model.addAttribute("flag",
* false); }
*/

}

Expand Down Expand Up @@ -126,4 +161,28 @@ private static String extractFilePath(HttpServletRequest request) {
AntPathMatcher apm = new AntPathMatcher();
return apm.extractPathWithinPattern(bestMatchPattern, path);
}

public DataProfilerFactory getDataProfilerFactory() {
return dataProfilerFactory;
}

public void setDataProfilerFactory(DataProfilerFactory dataProfilerFactory) {
this.dataProfilerFactory = dataProfilerFactory;
}

public IRODSServices getIrodsServices() {
return irodsServices;
}

public void setIrodsServices(IRODSServices irodsServices) {
this.irodsServices = irodsServices;
}

public DataProfilerSettings getDataProfilerSettings() {
return dataProfilerSettings;
}

public void setDataProfilerSettings(DataProfilerSettings dataProfilerSettings) {
this.dataProfilerSettings = dataProfilerSettings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<property name="locations">
<list>

<!-- <value>file:/etc/irods-ext/metalnx.properties</value>-->
<value>file:///C:/Users/hetalben/opt/etc/irods-ext/metalnx.properties</value>
<value>file:/etc/irods-ext/metalnx.properties</value>
<!-- <value>file:///C:/Users/hetalben/opt/etc/irods-ext/metalnx.properties</value> -->
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
Expand All @@ -41,8 +41,8 @@
<!-- this resource must be in the /etc/irods-ext directory, see the CONFIGURATION.md doc at the top of the repo,
It allows theming and custom messages -->

<!--<import resource="file:/etc/irods-ext/metalnxConfig.xml" />-->
<import resource="file:///C:/Users/hetalben/opt/etc/irods-ext/metalnxConfig.xml" />
<import resource="file:/etc/irods-ext/metalnxConfig.xml" />
<!--<import resource="file:///C:/Users/hetalben/opt/etc/irods-ext/metalnxConfig.xml" /> -->

<!-- **************************************************************** -->
<!-- SPRING SECURITY-SPECIFIC ARTIFACTS -->
Expand Down

0 comments on commit 19df664

Please sign in to comment.