Skip to content
This repository has been archived by the owner on Feb 23, 2018. It is now read-only.

Commit

Permalink
#27 collection info controller and views updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Hetal Patel committed Jan 16, 2018
1 parent 0cd4dee commit 97f278c
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 296 deletions.
4 changes: 3 additions & 1 deletion src/emc-metalnx-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

<build>
<plugins>
<!-- Plugin required to build java classes from XSD using XJC -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
Expand All @@ -99,6 +100,7 @@
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<arguments>-extension -npa -b "${project.basedir}/src/main/xsd/global.xjb"</arguments>
</configuration>
</plugin>
Expand Down Expand Up @@ -271,4 +273,4 @@

</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,11 @@ 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, @RequestParam("path") final String path)
@RequestMapping(value = "/info/" , method = RequestMethod.POST)
public String getFileInfo(final Model model, final String path)
throws DataGridConnectionRefusedException {

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

Expand Down Expand Up @@ -492,8 +493,9 @@ public String getFileInfo(final Model model, @RequestParam("path") final String
System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("currentCollection.getName() == "+ dataGridObj.getName());

//return "collections/collectionInfo";
return "collections/info";
System.out.println("CollectionController getInfoFile() ends !!");
return "collections/collectionInfo";
//return "collections/info";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,77 +11,109 @@
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
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.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.PermissionsService;


@Controller
@Scope(WebApplicationContext.SCOPE_SESSION)
@SessionAttributes({ "sourcePaths" })
@RequestMapping(value = "/collectionInfo")
public class CollectionInfoController {

@Autowired
private CollectionController collectionController;
private LoggedUserUtils loggedUserUtils;

@Autowired
private MetadataController metadataController;
CollectionService collectionService;

@Autowired
private PermissionsController permissionsController;
PermissionsService permissionsService;

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


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


logger.info("------CollectionInfoController getTestCollectionInfo() starts !!");
final String path = "/"+extractFilePath(request);
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;

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("collectionAndDataObject", dgColObj);
if(dgColObj != null)
model.addAttribute("flag", true);
else {
model.addAttribute("flag", false);
}

logger.info("path ::" + path) ;
model.addAttribute("Summary", "This is comming from the CollectionInfoController() - Test the main controller");
logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
return "collections/info"; //metadataController.getMetadata(model, path);
return "collections/info";

}

@RequestMapping(value = "/collectionFileInfo/**", method = RequestMethod.GET)
/*
@RequestMapping(value = "/collectionFileInfo/", method = RequestMethod.POST)
public String getCollectionFileInfo(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {
System.out.println("------CollectionInfoController getCollectionFileInfo() starts :: " +path);
model.addAttribute("name", "Info");
logger.info("------CollectionInfoController getCollectionFileInfo() starts :: " +path);
DataGridUser loggedUser = LoggedUserUtils.getLoggedDataGridUser();
logger.info("User First Name :: " +loggedUser.getUsername());
model.addAttribute("infoName", "This is Info !!");
return "collections/info";
//return collectionController.getFileInfo(model, path);//"collections/info";
}
}*/

@RequestMapping(value = "/collectionMetadata/**", method = RequestMethod.GET)
/*@RequestMapping(value = "/collectionMetadata/", method = RequestMethod.POST)
public String getCollectionMetadata(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {

System.out.println("------CollectionInfoController collectionMetadata() starts :: " +path);
model.addAttribute("name", "Metadata");
return "collections/info";
//return metadataController.getMetadata(model, path);//"collections/info";
logger.info("-----------------------------getCollectionMetadata()-------------------------------- !!");
logger.info("------CollectionInfoController collectionMetadata() starts :: " +path);
model.addAttribute("metadataName", "This is Metadata !!");
logger.info("MetadataName :: " +model.containsAttribute("MetadataName"));
//return "collections/info";
return "metadata/test";
}

@RequestMapping(value = "/collectionPermisssionDetails/**", method = RequestMethod.GET)
@RequestMapping(value = "/collectionPermisssionDetails/", method = RequestMethod.POST)
public String getCollectionPermissionDetails(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {
logger.info("-----------------------------getCollectionPermissionDetails()-------------------------------- !!");
logger.info("------CollectionInfoController collectionPermisssionDetails() starts :: " +path);
System.out.println("------CollectionInfoController collectionPermisssionDetails() starts :: " +path);

model.addAttribute("name", "Permission");
model.addAttribute("permissionName", "This is Permission !!");
return "collections/info";
//return permissionsController.getPermissionDetails(model, path);//"collections/info";
}
*/
private static String extractFilePath(HttpServletRequest request) {
String path = (String) request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ public void exportSearchResultsToCSVFile(final HttpServletResponse response)
}
}

@RequestMapping(value = "/getMetadata/")
@RequestMapping(value = "/getMetadata/", method = RequestMethod.POST)
public String getMetadata(final Model model, final String path)
throws DataGridConnectionRefusedException {
System.out.println("MetadataController getMetadata() starts !!");
logger.info("MetadataController getMetadata() starts !!");
List<DataGridMetadata> metadataList = metadataService.findMetadataValuesByPath(path);
DataGridCollectionAndDataObject dgColObj = null;

Expand All @@ -262,22 +262,17 @@ public String getMetadata(final Model model, final String path)
} catch (DataGridException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path);
}

System.out.println("CurrentPath =======" +path);
System.out.println("dgColObj =======" +dgColObj);
System.out.println("permissionOnCurrentPath =======" +collectionService.getPermissionsForPath(path));

model.addAttribute("permissionOnCurrentPath", collectionService.getPermissionsForPath(path));
model.addAttribute("dataGridMetadataList", metadataList);
model.addAttribute("currentPath", path);
model.addAttribute("collectionAndDataObject", dgColObj);
model.addAttribute("metadataFlag",true);

System.out.println("MetadataController getMetadata() ends !!");
//return "metadata/metadataTable";
return "collections/info";
model.addAttribute("metadataFlag",true);

logger.info("MetadataController getMetadata() ends !!");
return "metadata/metadataTable :: metadataTable";
}

@RequestMapping(value = "/addMetadata/")
public String setMetadata(final Model model, @RequestParam("path") final String path,
@RequestParam("attribute") final String attribute, @RequestParam("value") final String value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private String findMostRestrictivePermission(@RequestParam("paths[]") final Stri
* @throws JargonException
* @throws FileNotFoundException
*/
@RequestMapping(value = "/getPermissionDetails/")
@RequestMapping(value = "/getPermissionDetails/" , method = RequestMethod.POST)
public String getPermissionDetails(final Model model, @RequestParam("path") final String path) throws DataGridConnectionRefusedException {

logger.debug("Getting permission info for {}", path);
Expand Down Expand Up @@ -189,9 +189,9 @@ public String getPermissionDetails(final Model model, @RequestParam("path") fina

System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("------Permission Conroller - /getPermissionDetail/ ends------");
//return "permissions/permissionDetails :: permissionDetails";
return "permissions/permissionDetails :: permissionDetails";
//return "permissions/permissionDetails";
return "collections/info";

}

@RequestMapping(value = "/changePermissionForGroup/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function ajaxEncapsulation(url, method, params, successFunction, errorFunction,
if (contentType == null || typeof contentType === 'undefined') {
contentType = "application/x-www-form-urlencoded; charset=UTF-8";
}
console.log("calling ajaxEncapsulation - ajax.js");

$.ajax({
url: url,
type: method,
Expand Down
100 changes: 33 additions & 67 deletions src/emc-metalnx-shared/src/main/resources/static/js/collection.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,62 @@
function getTestInfo(path){
function getCollectionSummary(path){
console.log(" In getTestInfo() " +path);
var url = "/emc-metalnx-web/collectionInfo"+path;
getBreadcrumb(path);
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
ajaxEncapsulation(url, "GET", {path: path}, displayCollectionSummar, null, null);
}

function displayTestDetails(data){
console.log("displayTestDetails()");
$('#table-loader').hide();
$('#table-loader').after(data);
function displayCollectionSummary(data){
console.log("displayTestDetails()");
$("#summary").html(data);
}

function getMetadata(){
console.log("Collection getMetadata() :: " +path);
var path ="/zone1/home/test1/CollectionServiceImplTestTestRoot";
window.location.hash = "metadata";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/collectionInfo/collectionMetadata"+path;
console.log(1);
//getBreadcrumb(path);
ajaxEncapsulation(url, "GET", {path: path}, displayMetadata, null, null);
}

function getInfoDetails(){
function getInfoDetails(path){
console.log("Collection getInfoDetails() starts !!");
var path ="/zone1/home/test1/CollectionServiceImplTestTestRoot";
window.location.hash = "info";
console.log("Path :: " +path);
var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo"+path;
//console.log("URL :: " +url);

//var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo/";
var url = "/emc-metalnx-web/collections/info/";
//getBreadcrumb(path);
ajaxEncapsulation(url, "GET", {path: path}, displayInfoDetails, null, null, null);
console.log("Collection getInfoDetails() ends !!");
ajaxEncapsulation(url, "POST", {path: path}, displayInfoDetails, null, null, null);

}

function getPermDetails(){
function getMetadata(path){
console.log("Collection getMetadata() :: " +path);
window.location.hash = "metadata";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/metadata/getMetadata/";
console.log("url " +url);
//getBreadcrumb(path);
ajaxEncapsulation(url , "POST", {path: path}, displayMetadata, null, null, null);
}

function getPermissionDetails(path){
console.log("Collection getPermDetails() :: " +path);
var path ="/zone1/home/test1/CollectionServiceImplTestTestRoot";
var url = "/emc-metalnx-web/collectionInfo/collectionPermisssionDetails"+path;
window.location.hash = "permission";
var url = "/emc-metalnx-web/permissions/getPermissionDetails/";
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayPermDetails, null, null);
//getBreadcrumb(path);
ajaxEncapsulation(url, "POST", {path: path}, displayPermissionDetails, null, null);
}

function displayMetadata(data){
$('#table-loader').hide();
$('#table-loader').after(data);
$("#uploadIcon").prop("disabled", true);
$("#uploadIcon").addClass("disabled");
$("#showCollectionFormBtn").prop("disabled", true);
$("#showCollectionFormBtn").addClass("disabled");
}

function displayInfoDetails(data){
//alert("displayInfoDetails");
$("#table-loader").hide();
$("#table-loader").after(data);
}

function displayPermDetails(data){
$('#table-loader').hide();
$("#table-loader").after(data);
$("#uploadIcon").prop("disabled", true);
$("#uploadIcon").addClass("disabled");
$("#showCollectionFormBtn").prop("disabled", true);
$("#showCollectionFormBtn").addClass("disabled");
$("#info").html(data);
}



/*function getInfoDetails(path){
console.log("Collection getInfoDetails() :: " +path);
window.location.hash = "info";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo"+path;
getBreadcrumb(path);
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
function displayMetadata(data){
$("#metadata").html(data);
}

function getPermDetails(path){
console.log("Collection getPermDetails() :: " +path);
window.location.hash = "permission";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/collectionInfo/collectionPermisssionDetails"+path;
getBreadcrumb(path);
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
function displayPermissionDetails(data){
$('#permission').html(data);

}

/*
function ChangeUrl(title, urlVal) {
console.log("ChangeUrl()");
Expand Down
Loading

0 comments on commit 97f278c

Please sign in to comment.