Skip to content

Commit

Permalink
#27 merge conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Hetal Patel committed Jan 29, 2018
2 parents da24a71 + 57fe755 commit 7fa208a
Show file tree
Hide file tree
Showing 21 changed files with 1,362 additions and 277 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ public void init() throws DataGridException {
* @throws DataGridException
*/
@RequestMapping(value = "/")
public String index(final Model model, final HttpServletRequest request,
@RequestParam(value = "uploadNewTab", required = false) final boolean uploadNewTab)
throws DataGridConnectionRefusedException {
public String index(final Model model, final HttpServletRequest request) throws DataGridConnectionRefusedException {
logger.info("index()");
try {
sourcePaths.clear();
Expand All @@ -204,9 +202,6 @@ public String index(final Model model, final HttpServletRequest request,
model.addAttribute("homePath", cs.getHomeDirectyForCurrentUser());
model.addAttribute("publicPath", cs.getHomeDirectyForPublic());
}
if (uploadNewTab) {
model.addAttribute("uploadNewTab", uploadNewTab);
}

model.addAttribute("cameFromFilePropertiesSearch", cameFromFilePropertiesSearch);
model.addAttribute("cameFromMetadataSearch", cameFromMetadataSearch);
Expand Down Expand Up @@ -332,18 +327,17 @@ public String getSubDirectories(final Model model, @RequestParam("path") String
while (path.endsWith("/") && !"/".equals(path)) {
path = path.substring(0, path.lastIndexOf("/"));
}

logger.info("Get subdirectories of {}", path);

System.out.println("In GetSubdirectories!!");
System.out.println("path :: " +path);
System.out.println("path :: " + path);

// put old path in collection history stack
addPathToHistory(path);

return getCollBrowserView(model, path);
}


/**
* Goes back in collection historic stack
Expand Down Expand Up @@ -454,17 +448,16 @@ public String getSubDirectoriesOldTree(final Model model, @RequestParam("path")
* @return the template that shows the data object information
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "/info/" , method = RequestMethod.POST)
public String getFileInfo(final Model model, final String path)
@RequestMapping(value = "/info/", method = RequestMethod.POST)
public String getFileInfo(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {

System.out.println("CollectionController getInfoFile() starts !!");
DataGridCollectionAndDataObject dataGridObj = null;
Map<DataGridCollectionAndDataObject, DataGridResource> replicasMap = null;

try {
System.out.println("Path = " +path);
System.out.println("Path = " + path);

dataGridObj = cs.findByName(path);

if (dataGridObj != null && !dataGridObj.isCollection()) {
Expand All @@ -473,9 +466,8 @@ public String getFileInfo(final Model model, final String path)
dataGridObj.setNumberOfReplicas(cs.getTotalNumberOfReplsForDataObject(path));
dataGridObj.setReplicaNumber(String.valueOf(cs.getReplicationNumber(path)));
permissionsService.resolveMostPermissiveAccessForUser(dataGridObj,
loggedUserUtils.getLoggedDataGridUser());


loggedUserUtils.getLoggedDataGridUser());

}

} catch (DataGridConnectionRefusedException e) {
Expand All @@ -487,16 +479,14 @@ public String getFileInfo(final Model model, final String path)

model.addAttribute("collectionAndDataObject", dataGridObj);
model.addAttribute("currentCollection", dataGridObj);
model.addAttribute("replicasMap", replicasMap);
model.addAttribute("replicasMap", replicasMap);
model.addAttribute("infoFlag", true);



System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("currentCollection.getName() == "+ dataGridObj.getName());

System.out.println("CollectionController getInfoFile() ends !!");
return "collections/info :: infoView";
//return "collections/info";
System.out.println("currentCollection.getName() == " + dataGridObj.getName());

// return "collections/collectionInfo";
return "collections/info";
}

/**
Expand Down Expand Up @@ -579,7 +569,7 @@ public String getDirectoriesAndFilesForUser(final Model model, @RequestParam("pa
@RequestParam("username") final String username,
@RequestParam("retrievePermissions") final boolean retrievePermissions)
throws DataGridConnectionRefusedException, FileNotFoundException, JargonException {

List<DataGridCollectionAndDataObject> list = new ArrayList<DataGridCollectionAndDataObject>();
Set<String> readPermissions = new HashSet<String>();
Set<String> writePermissions = new HashSet<String>();
Expand Down Expand Up @@ -1107,10 +1097,10 @@ private String getCollBrowserView(final Model model, String path) throws DataGri
model.addAttribute("collection", collectionForm);
model.addAttribute("inheritanceDisabled", inheritanceDisabled);
model.addAttribute("requestMapping", "/collections/add/action/");
model.addAttribute("parentPath", parentPath);
model.addAttribute("parentPath", parentPath);
setBreadcrumbToModel(model, dataGridObj);
return "collections/collectionsBrowser";
//return "collections/info";
return "collections/collectionsBrowser";
// return "collections/info";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.io.IOUtils;
import org.irods.jargon.core.connection.IRODSAccount;
import org.irods.jargon.core.exception.JargonException;
Expand All @@ -22,7 +21,6 @@
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -31,7 +29,6 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.HandlerMapping;

import com.emc.metalnx.controller.utils.LoggedUserUtils;
import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException;
import com.emc.metalnx.core.domain.exceptions.DataGridException;
import com.emc.metalnx.modelattribute.breadcrumb.DataGridBreadcrumb;
Expand All @@ -58,7 +55,7 @@ public class CollectionInfoController {

@Autowired
IRODSServices irodsServices;

@Autowired
IconService iconService;

Expand All @@ -69,7 +66,7 @@ public class CollectionInfoController {

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

logger.info("CollectionInfoController getTestCollectionInfo() starts !!");
final String path = "/" + extractFilePath(request);
Expand All @@ -78,36 +75,35 @@ public String getTestCollectionInfo(final Model model, HttpServletRequest reques

@SuppressWarnings("rawtypes")
DataProfile dataProfile = getCollectionDataProfile(path);

String iconToDisplay = "";
if(dataProfile!= null && dataProfile.isFile())

if (dataProfile != null && dataProfile.isFile())
iconToDisplay = iconService.getIconToDisplayFile(dataProfile.getDataType().getMimeType());
if(dataProfile!= null && !dataProfile.isFile())
if (dataProfile != null && !dataProfile.isFile())
iconToDisplay = iconService.getIconToDisplayCollection();
model.addAttribute("iconToDisplay", iconToDisplay);

model.addAttribute("iconToDisplay", iconToDisplay);
model.addAttribute("dataProfile", dataProfile);
model.addAttribute("breadcrumb", new DataGridBreadcrumb(dataProfile.getAbsolutePath()));
DataGridBreadcrumb bc = new DataGridBreadcrumb(dataProfile.getAbsolutePath());

System.out.println("Absolute Path :: " +dataProfile.getAbsolutePath());
String template = "";
if(!dataProfile.isFile())

if (!dataProfile.isFile())
template = "collections/collectionInfo";
if(dataProfile.isFile())
if (dataProfile.isFile())
template = "collections/fileInfo";
return template;
//:: mainPage(page='collections/collectionInfo', fragment='collectionInfo')";
//"main :: mainPage(page='some-page', fragment='somePage')";

return template;

// :: mainPage(page='collections/collectionInfo', fragment='collectionInfo')";
// "main :: mainPage(page='some-page', fragment='somePage')";
}

@SuppressWarnings("unchecked")
public DataProfile<IRODSDomainObject> getCollectionDataProfile(String path) throws DataGridException {


IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();
logger.debug("got irodsAccount:{}", irodsAccount);
Expand All @@ -123,47 +119,45 @@ public DataProfile<IRODSDomainObject> getCollectionDataProfile(String path) thro
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 dataProfile;

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

}




@RequestMapping(value = "/collectionFileInfo/", method = RequestMethod.POST)
public String getCollectionFileInfo(final Model model, @RequestParam("path")
final String path) throws DataGridException {
public String getCollectionFileInfo(final Model model, @RequestParam("path") final String path)
throws DataGridException {

logger.info("CollectionInfoController getCollectionFileInfo() starts :: " + path);

logger.info("CollectionInfoController getCollectionFileInfo() starts :: " +path);

@SuppressWarnings("rawtypes")
DataProfile dataProfile = getCollectionDataProfile(path);

String iconToDisplay = "";
if(dataProfile!= null && dataProfile.isFile())

if (dataProfile != null && dataProfile.isFile())
iconToDisplay = iconService.getIconToDisplayFile(dataProfile.getDataType().getMimeType());
if(dataProfile!= null && !dataProfile.isFile())
if (dataProfile != null && !dataProfile.isFile())
iconToDisplay = iconService.getIconToDisplayCollection();
model.addAttribute("iconToDisplay", iconToDisplay);

model.addAttribute("iconToDisplay", iconToDisplay);
model.addAttribute("dataProfile", dataProfile);

logger.info("getCollectionFileInfo() ends !!");
return "collections/info :: infoView";
//return "collections/info";
// return "collections/info";
}
@RequestMapping(value = "/getFile/",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)

@RequestMapping(value = "/getFile/", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody byte[] getFile() throws IOException {
logger.info("getFile() starts!!");
InputStream in = getClass()
Expand Down Expand Up @@ -206,8 +200,15 @@ public String getCollectionFileInfo(final Model model, @RequestParam("path")
*
* }
*/
private static String extractFilePath(HttpServletRequest request) {
private String extractFilePath(HttpServletRequest request) throws JargonException {
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
try {
path = URLDecoder.decode(path,
this.getIrodsServices().getIrodsAccessObjectFactory().getJargonProperties().getEncoding());
} catch (UnsupportedEncodingException | JargonException e) {
logger.error("unable to decode path", e);
throw new JargonException(e);
}
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
return apm.extractPathWithinPattern(bestMatchPattern, path);
Expand Down
Loading

0 comments on commit 7fa208a

Please sign in to comment.