Skip to content

Commit

Permalink
Merge branch 'niehs-development' of gitlab.niehs.nih.gov:conwaymc/met…
Browse files Browse the repository at this point in the history
…alnx-web into niehs-development
  • Loading branch information
Hetal Patel committed Jan 29, 2018
2 parents a64e320 + 8a50d87 commit 69a14dc
Show file tree
Hide file tree
Showing 24 changed files with 602 additions and 1,231 deletions.

Large diffs are not rendered by default.

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
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class FileOperationsController {
private static final Logger logger = LoggerFactory.getLogger(FileOperationsController.class);
private static String TRASH_PATH;

@Autowired
private BrowseController browseController;

@Autowired
private CollectionController collectionController;

Expand Down Expand Up @@ -115,7 +118,7 @@ public String move(final Model model, @RequestParam("targetPath") final String t

model.addAttribute("failedMoves", failedMoves);

return collectionController.getSubDirectories(model, targetPath);
return browseController.getSubDirectories(model, targetPath);
}

@RequestMapping(value = "/copy", method = RequestMethod.POST)
Expand All @@ -124,14 +127,26 @@ public String copy(final Model model, @RequestParam("targetPath") final String t
@RequestParam("copyWithMetadata") final boolean copyWithMetadata,
@RequestParam("paths[]") final String[] paths) throws DataGridException, JargonException {

logger.info("copy()");
logger.info("model:{}", model);
logger.info("copyWithMetadata:{}", copyWithMetadata);
logger.info("targetPath:{}", targetPath);
for (String path : paths) {
logger.info("path:{}", path);
}

List<String> failedCopies = new ArrayList<>();
String fileCopied = "";

for (String p : paths) {
String item = p.substring(p.lastIndexOf("/") + 1, p.length());
logger.info("copying p:{}", p);
logger.info("to target path:{}", targetPath);
if (!fileOperationService.copy(p, targetPath, copyWithMetadata)) {
logger.warn("failed on copy of item:{}", item);
failedCopies.add(item);
} else if (paths.length == 1) {
logger.info("success on item:{}", item);
fileCopied = item;
}
}
Expand All @@ -142,7 +157,7 @@ public String copy(final Model model, @RequestParam("targetPath") final String t

model.addAttribute("failedCopies", failedCopies);

return collectionController.getSubDirectories(model, targetPath);
return browseController.getSubDirectories(model, targetPath);
}

/**
Expand Down Expand Up @@ -173,14 +188,14 @@ public String deleteReplica(final Model model, @RequestParam("path") final Strin
} else {
model.addAttribute("delReplReturn", "failure");
}
return collectionController.getFileInfo(model, path);
return browseController.getFileInfo(model, path);
}

@RequestMapping(value = "/replicate", method = RequestMethod.POST)
public String replicate(final Model model, final HttpServletRequest request)
throws DataGridConnectionRefusedException {

List<String> sourcePaths = collectionController.getSourcePaths();
List<String> sourcePaths = browseController.getSourcePaths();
String[] resources = request.getParameterMap().get("resourcesForReplication");
List<String> failedReplicas = new ArrayList<>();

Expand All @@ -203,7 +218,7 @@ public String replicate(final Model model, final HttpServletRequest request)
sourcePaths.clear();
}

return collectionController.index(model, request, false);
return collectionController.index(model, request);
}

@RequestMapping(value = "/prepareFilesForDownload/", method = RequestMethod.GET)
Expand Down Expand Up @@ -262,23 +277,23 @@ public String deleteCollectionAndDataObject(final Model model, @RequestParam("pa
fileDeleted = path.substring(path.lastIndexOf("/") + 1, path.length());
}

collectionController.removePathFromHistory(path);
browseController.removePathFromHistory(path);
}

if (fileDeleted != null) {
model.addAttribute("fileDeleted", fileDeleted);
}

model.addAttribute("failedDeletions", failedDeletions);
model.addAttribute("currentPath", collectionController.getCurrentPath());
model.addAttribute("parentPath", collectionController.getParentPath());
model.addAttribute("currentPath", browseController.getCurrentPath());
model.addAttribute("parentPath", browseController.getParentPath());

return collectionController.getSubDirectories(model, collectionController.getCurrentPath());
return browseController.getSubDirectories(model, browseController.getCurrentPath());
}

@RequestMapping(value = "emptyTrash/", method = RequestMethod.POST)
public ResponseEntity<String> emptyTrash() throws DataGridConnectionRefusedException, JargonException {
String trashForCurrentPath = collectionService.getTrashForPath(collectionController.getCurrentPath());
String trashForCurrentPath = collectionService.getTrashForPath(browseController.getCurrentPath());
DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
if (fileOperationService.emptyTrash(loggedUser, trashForCurrentPath)) {
return new ResponseEntity<>(HttpStatus.OK);
Expand All @@ -298,8 +313,8 @@ public ResponseEntity<String> emptyTrash() throws DataGridConnectionRefusedExcep
*/
@RequestMapping(value = "modify/", method = RequestMethod.GET)
public String showModifyForm(final Model model, @RequestParam("path") final String path) throws DataGridException {
String currentPath = collectionController.getCurrentPath();
String parentPath = collectionController.getParentPath();
String currentPath = browseController.getCurrentPath();
String parentPath = browseController.getParentPath();

String formType = "editDataObjectForm";
CollectionOrDataObjectForm targetForm = new CollectionOrDataObjectForm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public class URLMap {

public static final String URL_COLLECTIONS_INFO = "/info/";
public static final String URL_COLLECTIONS_MANAGEMENT = "/collections/";
public static final String URL_ADD_COLLECTION = "/emc-metalnx-web/collections/add/";
public static final String URL_ADD_COLLECTION = "/emc-metalnx-web/browse/add/";
public static final String URL_MODIFY_COLLECTION = "/emc-metalnx-web/fileOperation/modify/";
public static final String URL_DELETE_COLLECTION = "/emc-metalnx-web/fileOperation/delete/";
public static final String URL_COLLECTION_VALIDATE_NAME = "/emc-metalnx-web/collections/isValidCollectionName/";
public static final String URL_COLLECTION_VALIDATE_NAME = "/emc-metalnx-web/browse/isValidCollectionName/";

public static final String URL_METADATA_SEARCH = "/metadata/";

Expand Down Expand Up @@ -85,13 +85,13 @@ public class URLMap {
public static final String URL_DELETE_SPECIFIC_QUERY = "/emc-metalnx-web/specificqueries/remove/";
public static final String URL_SPECIFIC_QUERY_VALIDATE = "/emc-metalnx-web/specificqueries/validate/";

public static final String URL_HOME_COLLECTION_USER = "/collections/home/";
public static final String URL_PUBLIC_COLLECTION_USER = "/collections/public/";
public static final String URL_TRASH_COLLECTION_USER = "/collections/trash/";
public static final String URL_ADD_COLLECTION_USER = "/emc-metalnx-web/collections/add/";
public static final String URL_HOME_COLLECTION_USER = "/browse/home";
public static final String URL_PUBLIC_COLLECTION_USER = "/browse/public/";
public static final String URL_TRASH_COLLECTION_USER = "/browse/trash/";
public static final String URL_ADD_COLLECTION_USER = "/emc-metalnx-web/browse/add/";
public static final String URL_MODIFY_COLLECTION_USER = "/emc-metalnx-web/fileOperation/modify/";
public static final String URL_DELETE_COLLECTION_USER = "/fileOperation/delete/";
public static final String URL_COLLECTION_VALIDATE_NAME_USER = "/emc-metalnx-web/collections/isValidCollectionName/";
public static final String URL_COLLECTION_VALIDATE_NAME_USER = "/emc-metalnx-web/browse/isValidCollectionName/";
public static final String URL_LOGOUT = "/logout/";

public static final String URL_TICKETS = "/tickets/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
text.back=Back
text.creation.date=Creation Date
text.contains=Contains
text.collections=Collections
text.close=Close
text.file.name=File Name
text.info=Info
text.delete=Delete
Expand Down
26 changes: 26 additions & 0 deletions src/emc-metalnx-shared/src/main/resources/static/css/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#hdr-junctiontitle {
background:none;
bottom:9px;
font-family:"Open Sans", sans-serif;
font-size:35px;
font-weight:300;
left:14px;
margin:0;
padding:0;
position:absolute;
text-decoration:none;
width:100%;
}

#hdr-junctiontitle a {
color:white;
display:block;
margin:0;
padding:0;
text-decoration:none;
width:350px;
}

#page-wrapper {
font-size: 15px;
}
Loading

0 comments on commit 69a14dc

Please sign in to comment.