Class Utils
- java.lang.Object
-
- org.gcube.datacatalogue.grsf_manage_widget.server.manage.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 Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConnectedBeanconnectedBeanRecordFromUrl(String destUrl, org.gcube.datacatalogue.utillibrary.server.DataCatalogue clg, String username, javax.servlet.http.HttpSession httpSession)Get Connected bean from record.static StringgetCurrentClientUrl(javax.servlet.http.HttpServletRequest httpServletRequest)Needed to get the url of the clientstatic StringgetCurrentContext(javax.servlet.http.HttpServletRequest request, boolean setInThread)Retrieve the current scope by using the portal managerstatic org.gcube.vomanagement.usermanagement.model.GCubeUsergetCurrentUser(javax.servlet.http.HttpServletRequest request)Retrieve the current user by using the portal managerstatic org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDatasetgetDatasetFromUrl(String url, org.gcube.datacatalogue.utillibrary.server.DataCatalogue clg, String username)Exploits the fact that in GRSF the url of a record contains the name (which is unique) of the record itself.static StringgetDatasetKnowledgeBaseIdFromUrl(String url)Exploits the fact that in GRSF the url of a record contains the name (which is unique) of the record itselfstatic Map<String,List<String>>getExtrasAsHashMap(List<org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanPair> extrasAsPairs)Get the extras of this dataset as hashmapstatic 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.static StringgetScopeFromClientUrl(javax.servlet.http.HttpServletRequest httpServletRequest)Get the scope in which ckan information needs to be discovered from the urlstatic booleanisIntoPortal()Checks if is into portal.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.static voidrevertOperation(org.apache.http.impl.client.CloseableHttpClient httpClient, String baseUrl, javax.servlet.http.HttpServletRequest httpServletRequest, RevertableOperationInfo rInfo, String token, String context, long groupId)Revert operation and alert admins/vre usersstatic SimilarGRSFRecordsimilarGRSFRecordFromJson(String json, org.gcube.datacatalogue.utillibrary.server.DataCatalogue ctl, String username, javax.servlet.http.HttpSession httpSession)Get aSimilarGRSFRecordfrom a json stringstatic voidupdateRecord(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)Send an update for this bean
-
-
-
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 ExceptionRevert 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 urlclg- the clgusername- 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 aSimilarGRSFRecordfrom 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 urlclg- the clgusername- the usernamehttpSession- the http session- Returns:
- the connected bean
- Throws:
org.json.simple.parser.ParseException- the parse exception
-
-