Class Utils


  • public class Utils
    extends Object
    Utility methods for GRSF Management panel widget.
    Author:
    Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • getFieldToFieldNameSpaceMapping

        public static Map<String,​String> getFieldToFieldNameSpaceMapping​(javax.servlet.http.HttpSession httpSession,
                                                                               String resourceName)
        Return a map for converting a key to a namespace:key format by reading a generic resource.
        Parameters:
        httpSession -
        Returns:
        a map
      • replaceFieldsKey

        public static Map<String,​List<String>> replaceFieldsKey​(List<org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanPair> extrasAsPairs,
                                                                      Map<String,​String> namespaces)
        Replace the extras' keys if needed, e.g. fishery_identity:Short Title -> Short Title
        Parameters:
        extrasAsPairs -
        namespaces -
        Returns:
        a map with replaced key value pairs
      • getExtrasAsHashMap

        public static Map<String,​List<String>> getExtrasAsHashMap​(List<org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanPair> extrasAsPairs)
        Get the extras of this dataset as hashmap
        Parameters:
        extrasAsPairs -
        Returns:
      • updateRecord

        public static void updateRecord​(String serviceUrl,
                                        ManageProductBean bean,
                                        org.gcube.datacatalogue.utillibrary.server.DataCatalogue catalogue,
                                        String username,
                                        String fullName,
                                        javax.servlet.http.HttpServletRequest httpServletRequest,
                                        long groupId,
                                        String context,
                                        String token)
                                 throws Exception
        Send an update for this bean
        Parameters:
        baseUrl -
        bean -
        username -
        catalogue -
        Throws:
        Exception
      • revertOperation

        public static void revertOperation​(org.apache.http.impl.client.CloseableHttpClient httpClient,
                                           String baseUrl,
                                           javax.servlet.http.HttpServletRequest httpServletRequest,
                                           RevertableOperationInfo rInfo,
                                           String token,
                                           String context,
                                           long groupId)
                                    throws Exception
        Revert operation and alert admins/vre users
        Parameters:
        httpClient -
        baseUrl -
        fullName -
        uuid -
        Throws:
        Exception
      • getScopeFromClientUrl

        public static String getScopeFromClientUrl​(javax.servlet.http.HttpServletRequest httpServletRequest)
        Get the scope in which ckan information needs to be discovered from the url
        Parameters:
        httpServletRequest -
        Returns:
      • getCurrentClientUrl

        public static String getCurrentClientUrl​(javax.servlet.http.HttpServletRequest httpServletRequest)
        Needed to get the url of the client
        Parameters:
        httpServletRequest - the httpServletRequest object
        Returns:
        the instance of the user
        See Also:
        url at client side
      • getCurrentContext

        public static String getCurrentContext​(javax.servlet.http.HttpServletRequest request,
                                               boolean setInThread)
        Retrieve the current scope by using the portal manager
        Parameters:
        b -
        Returns:
        a GcubeUser object
      • getCurrentUser

        public static org.gcube.vomanagement.usermanagement.model.GCubeUser getCurrentUser​(javax.servlet.http.HttpServletRequest request)
        Retrieve the current user by using the portal manager
        Returns:
        a GcubeUser object
      • getDatasetFromUrl

        public static org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset getDatasetFromUrl​(String url,
                                                                                                            org.gcube.datacatalogue.utillibrary.server.DataCatalogue clg,
                                                                                                            String username)
                                                                                                     throws Exception
        Exploits the fact that in GRSF the url of a record contains the name (which is unique) of the record itself.
        Parameters:
        url - the url
        clg - the clg
        username - the username
        Returns:
        the dataset from url
        Throws:
        Exception - the exception
      • getDatasetKnowledgeBaseIdFromUrl

        public static String getDatasetKnowledgeBaseIdFromUrl​(String url)
        Exploits the fact that in GRSF the url of a record contains the name (which is unique) of the record itself
        Parameters:
        url -
        clg -
        Returns:
      • similarGRSFRecordFromJson

        public static SimilarGRSFRecord similarGRSFRecordFromJson​(String json,
                                                                  org.gcube.datacatalogue.utillibrary.server.DataCatalogue ctl,
                                                                  String username,
                                                                  javax.servlet.http.HttpSession httpSession)
                                                           throws org.json.simple.parser.ParseException
        Get a SimilarGRSFRecord from a json string
        Parameters:
        json -
        Returns:
        SimilarGRSFRecord
        Throws:
        org.json.simple.parser.ParseException
      • isIntoPortal

        public static boolean isIntoPortal()
        Checks if is into portal.
        Returns:
        true, if is into portal
      • connectedBeanRecordFromUrl

        public static ConnectedBean connectedBeanRecordFromUrl​(String destUrl,
                                                               org.gcube.datacatalogue.utillibrary.server.DataCatalogue clg,
                                                               String username,
                                                               javax.servlet.http.HttpSession httpSession)
                                                        throws org.json.simple.parser.ParseException
        Get Connected bean from record.
        Parameters:
        destUrl - the dest url
        clg - the clg
        username - the username
        httpSession - the http session
        Returns:
        the connected bean
        Throws:
        org.json.simple.parser.ParseException - the parse exception