From 5f0838b8334a6268f99307ab5c6c4bb1b8c5343c Mon Sep 17 00:00:00 2001 From: Hetal Patel Date: Wed, 24 Jan 2018 14:31:12 -0500 Subject: [PATCH] #27 collection tabs --- .../services/irods/IRODSServicesImpl.java | 468 ------------------ .../controller/CollectionController.java | 2 +- .../main/resources/static/js/collection.js | 24 +- .../resources/views/collections/info.html | 55 +- .../resources/views/collections/summary.html | 17 +- 5 files changed, 66 insertions(+), 500 deletions(-) delete mode 100755 src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/IRODSServicesImpl.java diff --git a/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/IRODSServicesImpl.java b/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/IRODSServicesImpl.java deleted file mode 100755 index 4fc4e3eef..000000000 --- a/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/IRODSServicesImpl.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.services.irods; - -import java.net.ConnectException; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.IrodsVersion; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.BulkFileOperationsAO; -import org.irods.jargon.core.pub.CollectionAO; -import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO; -import org.irods.jargon.core.pub.DataObjectAO; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.EnvironmentalInfoAO; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.pub.IRODSFileSystemAO; -import org.irods.jargon.core.pub.RemoteExecutionOfCommandsAO; -import org.irods.jargon.core.pub.ResourceAO; -import org.irods.jargon.core.pub.RuleProcessingAO; -import org.irods.jargon.core.pub.SpecificQueryAO; -import org.irods.jargon.core.pub.Stream2StreamAO; -import org.irods.jargon.core.pub.TrashOperationsAO; -import org.irods.jargon.core.pub.UserAO; -import org.irods.jargon.core.pub.UserGroupAO; -import org.irods.jargon.core.pub.ZoneAO; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.ticket.TicketAdminService; -import org.irods.jargon.ticket.TicketServiceFactory; -import org.irods.jargon.ticket.TicketServiceFactoryImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.context.annotation.ScopedProxyMode; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.context.WebApplicationContext; - -import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException; -import com.emc.metalnx.services.auth.UserTokenDetails; -import com.emc.metalnx.services.interfaces.IRODSServices; - -@Service("irodsServices") -@Transactional -@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.INTERFACES) -public class IRODSServicesImpl implements IRODSServices { - - @Autowired - IRODSAccessObjectFactory irodsAccessObjectFactory; - - private UserTokenDetails userTokenDetails; - private IRODSAccount irodsAccount; - - private static final Logger logger = LoggerFactory.getLogger(IRODSServicesImpl.class); - - public IRODSServicesImpl() { - /* - * This is a shim to support testing, probably a dependency on seccontextholder - * is unwarranted and should be factored out of this layer in the future - mcc - */ - try { - this.userTokenDetails = (UserTokenDetails) SecurityContextHolder.getContext().getAuthentication() - .getDetails(); - this.irodsAccount = this.userTokenDetails.getIrodsAccount(); - - } catch (NullPointerException npe) { - logger.warn("null pointer getting security context, assume running outside of container", npe); - } - } - - public IRODSServicesImpl(IRODSAccount acct) { - this.irodsAccount = acct; - } - - @Override - public TicketAdminService getTicketAdminService() throws DataGridConnectionRefusedException { - TicketAdminService tas = null; - - try { - TicketServiceFactory tsf = new TicketServiceFactoryImpl(irodsAccessObjectFactory); - tas = tsf.instanceTicketAdminService(irodsAccount); - } catch (JargonException e) { - logger.error("Could not instantiate ticket admin service: ", e.getMessage()); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return tas; - } - - @Override - public TrashOperationsAO getTrashOperationsAO() throws DataGridConnectionRefusedException, JargonException { - return irodsAccessObjectFactory.getTrashOperationsAO(irodsAccount); - } - - @Override - public String findIRodsVersion() throws DataGridConnectionRefusedException { - String version = ""; - - try { - EnvironmentalInfoAO envInfoAO = irodsAccessObjectFactory.getEnvironmentalInfoAO(irodsAccount); - IrodsVersion iv = envInfoAO.getIRODSServerPropertiesFromIRODSServer().getIrodsVersion(); - version = String.format("%s.%s.%s", iv.getMajorAsString(), iv.getMinorAsString(), iv.getPatchAsString()); - } catch (JargonException e) { - logger.error("Could not find iRODS version: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return version; - } - - @Override - public BulkFileOperationsAO getBulkFileOperationsAO() throws DataGridConnectionRefusedException { - BulkFileOperationsAO bulkFileOperationsAO = null; - - try { - // Returning UserAO instance - bulkFileOperationsAO = irodsAccessObjectFactory.getBulkFileOperationsAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate UserAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return bulkFileOperationsAO; - } - - @Override - public String getCurrentUser() { - return irodsAccount.getUserName(); - } - - @Override - public String getCurrentUserZone() { - return irodsAccount.getZone(); - } - - @Override - public UserAO getUserAO() throws DataGridConnectionRefusedException { - try { - // Returning UserAO instance - return irodsAccessObjectFactory.getUserAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate UserAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public UserGroupAO getGroupAO() throws DataGridConnectionRefusedException { - try { - - // Returning UserAO instance - return irodsAccessObjectFactory.getUserGroupAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate UserAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public CollectionAO getCollectionAO() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAO instance - return irodsAccessObjectFactory.getCollectionAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public CollectionAndDataObjectListAndSearchAO getCollectionAndDataObjectListAndSearchAO() - throws DataGridConnectionRefusedException { - - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAndDataObjectListAndSearchAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return null; - } - - @Override - public IRODSFileSystemAO getIRODSFileSystemAO() throws DataGridConnectionRefusedException { - - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getIRODSFileSystemAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAndDataObjectListAndSearchAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public IRODSFileFactory getIRODSFileFactory() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getIRODSFileFactory(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate IRODSFileFactory: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public DataTransferOperations getDataTransferOperations() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getDataTransferOperations(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate DataTransferOperations: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return null; - } - - @Override - public Stream2StreamAO getStream2StreamAO() throws DataGridConnectionRefusedException { - - try { - - return irodsAccessObjectFactory.getStream2StreamAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate Stream2StreamAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return null; - } - - @Override - public SpecificQueryAO getSpecificQueryAO() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getSpecificQueryAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAndDataObjectListAndSearchAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public RemoteExecutionOfCommandsAO getRemoteExecutionOfCommandsAO() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getRemoteExecutionOfCommandsAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate RemoteExecutionOfCommandsAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public ResourceAO getResourceAO() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getResourceAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAndDataObjectListAndSearchAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public ZoneAO getZoneAO() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getZoneAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAndDataObjectListAndSearchAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return null; - } - - @Override - public DataObjectAO getDataObjectAO() throws DataGridConnectionRefusedException { - try { - - // Returning CollectionAndDataObjectListAndSearchAO instance - return irodsAccessObjectFactory.getDataObjectAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate CollectionAndDataObjectListAndSearchAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - - return null; - } - - @Override - public RuleProcessingAO getRuleProcessingAO() throws DataGridConnectionRefusedException { - try { - // Returning RuleProcessingAO instance - return irodsAccessObjectFactory.getRuleProcessingAO(irodsAccount); - - } catch (JargonException e) { - logger.error("Could not instantiate RuleProcessingAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return null; - } - - @Override - public void setDefaultStorageResource(String newResourceName) { - this.irodsAccount.setDefaultStorageResource(newResourceName); - } - - @Override - public String getDefaultStorageResource() { - return this.irodsAccount.getDefaultStorageResource(); - } - - @Override - public EnvironmentalInfoAO getEnvironmentalInfoAO() throws DataGridConnectionRefusedException { - EnvironmentalInfoAO env = null; - - try { - env = irodsAccessObjectFactory.getEnvironmentalInfoAO(this.irodsAccount); - } catch (JargonException e) { - logger.error("Could not instantiate EnvironmentalInfoAO: ", e); - - if (e.getCause() instanceof ConnectException) { - throw new DataGridConnectionRefusedException(e.getMessage()); - } - } - return env; - } - - @Override - public boolean isAtLeastIrods420() throws DataGridConnectionRefusedException { - boolean isAtLeastIrods420 = false; - - try { - EnvironmentalInfoAO env = irodsAccessObjectFactory.getEnvironmentalInfoAO(this.irodsAccount); - if (env != null) - isAtLeastIrods420 = env.getIRODSServerPropertiesFromIRODSServer().isAtLeastIrods420(); - } catch (JargonException e) { - logger.error("Could not get environmental information from grid: {}", e.getMessage()); - } - - return isAtLeastIrods420; - } - - @Override - public IRODSAccessObjectFactory getIrodsAccessObjectFactory() { - return irodsAccessObjectFactory; - } - - public UserTokenDetails getUserTokenDetails() { - return userTokenDetails; - } - - public void setUserTokenDetails(UserTokenDetails userTokenDetails) { - this.userTokenDetails = userTokenDetails; - } - - public IRODSAccount getIrodsAccount() { - return irodsAccount; - } - - public void setIrodsAccount(IRODSAccount irodsAccount) { - this.irodsAccount = irodsAccount; - } - -} diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/CollectionController.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/CollectionController.java index 822fbdae6..da88fb8f3 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/CollectionController.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/CollectionController.java @@ -1105,7 +1105,7 @@ 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"; diff --git a/src/emc-metalnx-shared/src/main/resources/static/js/collection.js b/src/emc-metalnx-shared/src/main/resources/static/js/collection.js index ef424eaec..7a867c184 100644 --- a/src/emc-metalnx-shared/src/main/resources/static/js/collection.js +++ b/src/emc-metalnx-shared/src/main/resources/static/js/collection.js @@ -13,8 +13,8 @@ function displayCollectionSummary(data){ function getInfoDetails(path){ - $("#info").hide(); - $("#table-loader").show(); + //$("#info").hide(); + //$("#table-loader").show(); window.location.hash = "info"; var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo/"; ajaxEncapsulation(url, "POST", {path: path}, displayInfoDetails, null, null, null); @@ -22,8 +22,8 @@ function getInfoDetails(path){ } function getMetadata(path){ - $("#metadata").hide(); - $("#table-loader").show(); + //$("#metadata").hide(); + //$("#table-loader").show(); console.log("Collection getMetadata() :: " +path); window.location.hash = "metadata"; var url = "/emc-metalnx-web/metadata/getMetadata/"; @@ -31,8 +31,8 @@ function getMetadata(path){ } function getPermissionDetails(path){ - $("#permission").hide(); - $("#table-loader").show(); + //$("#permission").hide(); + //$("#table-loader").show(); console.log("Collection getPermDetails() :: " +path); window.location.hash = "permission"; var url = "/emc-metalnx-web/permissions/getPermissionDetails/"; @@ -41,22 +41,22 @@ function getPermissionDetails(path){ function displayInfoDetails(data){ - $("#table-loader").hide(); + //$("#table-loader").hide(); $("#info").html(data); - $("#info").show(); + //$("#info").show(); } function displayMetadata(data){ - $("#table-loader").hide(); + //$("#table-loader").hide(); $("#metadata").html(data); - $("#metadata").show(); + //$("#metadata").show(); } function displayPermissionDetails(data){ - $("#table-loader").hide(); + //$("#table-loader").hide(); $('#permission').html(data); //alert('showing content menu'); - $("#permission").show(); + //$("#permission").show(); } function showPreview(){ diff --git a/src/emc-metalnx-shared/src/main/resources/views/collections/info.html b/src/emc-metalnx-shared/src/main/resources/views/collections/info.html index caadf1b46..ba284051e 100644 --- a/src/emc-metalnx-shared/src/main/resources/views/collections/info.html +++ b/src/emc-metalnx-shared/src/main/resources/views/collections/info.html @@ -21,7 +21,6 @@
- this is collection Info

@@ -37,7 +36,13 @@

- +
+

+
+
+ +
+
@@ -66,7 +71,6 @@

- this is File Info

@@ -77,26 +81,33 @@

- +
+
+ +
+
+ +
+
- +
+
+
+
+ +
+
@@ -122,6 +133,14 @@

+
diff --git a/src/emc-metalnx-shared/src/main/resources/views/collections/summary.html b/src/emc-metalnx-shared/src/main/resources/views/collections/summary.html index 4336f207e..1b94fe130 100644 --- a/src/emc-metalnx-shared/src/main/resources/views/collections/summary.html +++ b/src/emc-metalnx-shared/src/main/resources/views/collections/summary.html @@ -38,7 +38,22 @@

- +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+