diff --git a/changelog.xml b/changelog.xml index 5d00d03..f6e4ff9 100644 --- a/changelog.xml +++ b/changelog.xml @@ -6,7 +6,12 @@ [Feature #18150] Get Shareable Link coy to clipboard facility - [Bug #18577] Fixing Shareable link informative text for public file + [Bug #18577] Fixing Shareable link informative text for public + file + + [Feature #18174] Workspace Search facility, business logic + applied on workspace side + org.gcube.portlets.user workspace-tree-widget - 6.29.0 + 6.29.0-SNAPSHOT gCube Workspace Tree Widget gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 545e644..201c1b9 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -99,6 +99,8 @@ import com.liferay.portal.service.UserLocalServiceUtil; */ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWTWorkspaceService { + public static final String JCR_WILDCARD_TO_SEARCH = "%"; + public static final String CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH = "\""; //is double quote protected static final String IDENTIFIER_IS_NULL = "Identifier is null"; protected static final String RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST = " retrieving item. Either the item doesn't exist anymore or you do not have the permission to access it"; private static final long serialVersionUID = 2828885661214875589L; @@ -2422,9 +2424,22 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.debug("searching folderId is null, searching from the root folder"); folderId = workspace.getRoot().getId(); } + + workspaceLogger.debug("applying business logic for searching, see #18174"); + + System.out.println("\n\nInput searched text is: "+text); + String toSearch = text; + if(toSearch.startsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH) && toSearch.endsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH)){ + workspaceLogger.info("Detected intent of exactly matching (the input text is between "+CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH+" char)"); + toSearch = toSearch.substring(1,toSearch.length()-1); + workspaceLogger.info("exactly matching changed the input text to: "+toSearch); + }else { + toSearch = String.format("%s%s%s", JCR_WILDCARD_TO_SEARCH,toSearch,JCR_WILDCARD_TO_SEARCH); + workspaceLogger.info("prepending and appending the wildcard "+JCR_WILDCARD_TO_SEARCH+", changed the input text to: "+toSearch); + } - workspaceLogger.info("searching by text: " + text + " in the folder id: " + folderId); - List foundItems = workspace.search(text, folderId); + workspaceLogger.info("backend searching for text: " + toSearch + " in the folder id: " + folderId); + List foundItems = workspace.search(toSearch, folderId); if(foundItems==null) { workspaceLogger.info("Searching by SHUB returned null, instancing empty list"); diff --git a/src/test/java/org/gcube/portlets/user/workspace/TestEncodeDecodeBase64.java b/src/test/java/org/gcube/portlets/user/workspace/TestEncodeDecodeBase64.java index 449d7f8..152d586 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/TestEncodeDecodeBase64.java +++ b/src/test/java/org/gcube/portlets/user/workspace/TestEncodeDecodeBase64.java @@ -3,6 +3,8 @@ */ package org.gcube.portlets.user.workspace; +import java.util.Iterator; + import org.gcube.common.encryption.StringEncrypter; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.workspace.server.util.StringUtil; @@ -16,7 +18,9 @@ import org.gcube.portlets.user.workspace.server.util.StringUtil; */ public class TestEncodeDecodeBase64 { + public static final String CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH = "\""; //is double quote static final String SCOPE = "/gcube"; + private static final String JCR_WILDCARD_TO_SEARCH = "%"; // static String folderId = "e7b6bc31-8c35-4398-a7fd-492e391e17d2"; static String folderId = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73"; @@ -33,6 +37,25 @@ public class TestEncodeDecodeBase64 { public static void main(String[] args) { try { + + String[] listTexts = new String[]{"data","data%", "\"mydata\""}; + + for (String text : listTexts) { + System.out.println("\n\nInput searched text is: "+text); + String toSearch = text; + if(toSearch.startsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH) && toSearch.endsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH)){ + System.out.println("Detected intent of exactly mathing, the searched text is between "+CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH+" char"); + toSearch = toSearch.substring(1,toSearch.length()-1); + System.out.println("the searched text for exactly mathing is: "+toSearch); + }else { + toSearch = String.format("%s%s%s", JCR_WILDCARD_TO_SEARCH,toSearch,JCR_WILDCARD_TO_SEARCH); + System.out.println("prepending and appending the wildcard "+JCR_WILDCARD_TO_SEARCH+", changed the input text to: "+toSearch); + } + System.out.println("backend searched text is: "+toSearch); + } + + /* + ScopeProvider.instance.set(SCOPE); System.out.println("Folder Id: "+folderId); encode(); @@ -42,6 +65,7 @@ public class TestEncodeDecodeBase64 { System.out.println("Encrypt/Decript works!"); else System.out.println("Encrypt/Decript doesn't work!"); + */ } catch (Exception e) { // TODO Auto-generated catch block