Browse Source

Feature #18174 Workspace Search facility

added business logic on workspace side
task/19600
francesco 2 years ago
parent
commit
c113175723
  1. 7
      changelog.xml
  2. 2
      pom.xml
  3. 19
      src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
  4. 24
      src/test/java/org/gcube/portlets/user/workspace/TestEncodeDecodeBase64.java

7
changelog.xml

@ -6,7 +6,12 @@
</Change>
<Change>[Feature #18150] Get Shareable Link coy to clipboard facility
</Change>
<Change>[Bug #18577] Fixing Shareable link informative text for public file</Change>
<Change>[Bug #18577] Fixing Shareable link informative text for public
file
</Change>
<Change>[Feature #18174] Workspace Search facility, business logic
applied on workspace side
</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-user.workspace-portlet-tree.6-28-1"

2
pom.xml

@ -11,7 +11,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId>
<version>6.29.0</version>
<version>6.29.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name>
<description>
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace

19
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<org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem> foundItems = workspace.search(text, folderId);
workspaceLogger.info("backend searching for text: " + toSearch + " in the folder id: " + folderId);
List<org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem> foundItems = workspace.search(toSearch, folderId);
if(foundItems==null) {
workspaceLogger.info("Searching by SHUB returned null, instancing empty list");

24
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

Loading…
Cancel
Save