. Fix for AWC-501

- Single word term using an operator now processed correctly e.g. just searching for
	+biscuit
is the same as
	biscuit
. Changed generated PageTag link in web-client footer area from www.alfrescosoftware.com to www.alfresco.com
. Fix to Logout link for error page - no longer worked as the External Access Servlet no longer forces a login…!
 - added new outcome case for External Access Servlet - logout

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2326 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-02-08 17:20:12 +00:00
parent cf1ccdec80
commit 89de41d208
4 changed files with 111 additions and 70 deletions

View File

@@ -32,7 +32,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.LoginBean;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -63,6 +65,7 @@ public class ExternalAccessServlet extends BaseServlet
private final static String OUTCOME_DOCDETAILS = "showDocDetails"; private final static String OUTCOME_DOCDETAILS = "showDocDetails";
private final static String OUTCOME_SPACEDETAILS = "showSpaceDetails"; private final static String OUTCOME_SPACEDETAILS = "showSpaceDetails";
private final static String OUTCOME_BROWSE = "browse"; private final static String OUTCOME_BROWSE = "browse";
private final static String OUTCOME_LOGOUT = "logout";
private static final String ARG_TEMPLATE = "template"; private static final String ARG_TEMPLATE = "template";
@@ -181,12 +184,11 @@ public class ExternalAccessServlet extends BaseServlet
} }
else if (OUTCOME_BROWSE.equals(outcome)) else if (OUTCOME_BROWSE.equals(outcome))
{ {
if (args != null) if (args != null && args.length >= 3)
{ {
NodeRef nodeRef = null; NodeRef nodeRef = null;
int offset = 0; int offset = 0;
if (args.length >= 3)
{
offset = args.length - 3; offset = args.length - 3;
StoreRef storeRef = new StoreRef(args[0+offset], args[1+offset]); StoreRef storeRef = new StoreRef(args[0+offset], args[1+offset]);
nodeRef = new NodeRef(storeRef, args[2+offset]); nodeRef = new NodeRef(storeRef, args[2+offset]);
@@ -213,9 +215,21 @@ public class ExternalAccessServlet extends BaseServlet
browseBean.setDashboardView(true); browseBean.setDashboardView(true);
} }
// the above calls setup the NavigationHandler automatically // the above calls into BrowseBean setup the NavigationHandler automatically
}
else
{
// perform the appropriate JSF navigation outcome
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, outcome);
} }
} }
else if (OUTCOME_LOGOUT.equals(outcome))
{
// special case for logout
req.getSession().invalidate();
res.sendRedirect(req.getContextPath() + FACES_SERVLET + Application.getLoginPage(getServletContext()));
return;
} }
// perform the forward to the page processed by the Faces servlet // perform the forward to the page processed by the Faces servlet

View File

@@ -141,27 +141,44 @@ public final class SearchContext implements Serializable
// match against content text // match against content text
String text = this.text.trim(); String text = this.text.trim();
String fullTextQuery = null;
String nameAttrQuery = null; StringBuilder fullTextBuf = new StringBuilder(64);
StringBuilder nameAttrBuf = new StringBuilder(64);
if (text.length() != 0 && text.length() >= minimum) if (text.length() != 0 && text.length() >= minimum)
{ {
if (text.indexOf(' ') == -1 && text.charAt(0) != '"') if (text.indexOf(' ') == -1 && text.charAt(0) != '"')
{ {
// check for existance of a special operator
boolean operatorAND = (text.charAt(0) == OP_AND);
boolean operatorNOT = (text.charAt(0) == OP_NOT);
// strip operator from term if one was found
if (operatorAND || operatorNOT)
{
text = text.substring(1);
}
// prepend NOT operator if supplied
if (operatorNOT)
{
fullTextBuf.append(OP_NOT);
nameAttrBuf.append(OP_NOT);
}
// simple single word text search // simple single word text search
if (text.charAt(0) != OP_WILDCARD) if (text.charAt(0) != OP_WILDCARD)
{ {
// escape characters and append the wildcard character // escape characters and append the wildcard character
String safeText = QueryParser.escape(text); String safeText = QueryParser.escape(text);
fullTextQuery = " TEXT:" + safeText + OP_WILDCARD; fullTextBuf.append("TEXT:").append(safeText).append(OP_WILDCARD);
nameAttrQuery = " @" + nameAttr + ":" + safeText + OP_WILDCARD; nameAttrBuf.append("@").append(nameAttr).append(":").append(safeText).append(OP_WILDCARD);
} }
else else
{ {
// found a leading wildcard - prepend it again after escaping the other characters // found a leading wildcard - prepend it again after escaping the other characters
String safeText = QueryParser.escape(text.substring(1)); String safeText = QueryParser.escape(text.substring(1));
fullTextQuery = " TEXT:*" + safeText + OP_WILDCARD; fullTextBuf.append("TEXT:*").append(safeText).append(OP_WILDCARD);
nameAttrQuery = " @" + nameAttr + ":*" + safeText + OP_WILDCARD; nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeText).append(OP_WILDCARD);
} }
} }
else else
@@ -171,15 +188,14 @@ public final class SearchContext implements Serializable
{ {
// as a single quoted phrase // as a single quoted phrase
String quotedSafeText = '"' + QueryParser.escape(text.substring(1, text.length() - 1)) + '"'; String quotedSafeText = '"' + QueryParser.escape(text.substring(1, text.length() - 1)) + '"';
fullTextQuery = " TEXT:" + quotedSafeText; fullTextBuf.append("TEXT:").append(quotedSafeText);
nameAttrQuery = " @" + nameAttr + ":" + quotedSafeText; nameAttrBuf.append("@").append(nameAttr).append(":").append(quotedSafeText);
} }
else else
{ {
// as individual search terms // as individual search terms
StringTokenizer t = new StringTokenizer(text, " "); StringTokenizer t = new StringTokenizer(text, " ");
StringBuilder fullTextBuf = new StringBuilder(64);
StringBuilder nameAttrBuf = new StringBuilder(64);
fullTextBuf.append('('); fullTextBuf.append('(');
nameAttrBuf.append('('); nameAttrBuf.append('(');
int tokenCount = t.countTokens(); int tokenCount = t.countTokens();
@@ -196,11 +212,13 @@ public final class SearchContext implements Serializable
term = term.substring(1); term = term.substring(1);
} }
// operators such as AND and OR are only make sense for full text searching if (term.length() != 0)
if (i != 0)
{ {
fullTextBuf.append(operatorAND ? " AND " : " OR "); // operators such as AND and OR are only make sense for full text searching
nameAttrBuf.append(operatorAND ? " AND " : " OR "); if (i != 0 && !operatorAND)
{
fullTextBuf.append("OR ");
nameAttrBuf.append("OR ");
} }
// prepend NOT operator if supplied // prepend NOT operator if supplied
@@ -209,6 +227,12 @@ public final class SearchContext implements Serializable
fullTextBuf.append(OP_NOT); fullTextBuf.append(OP_NOT);
nameAttrBuf.append(OP_NOT); nameAttrBuf.append(OP_NOT);
} }
// prepend AND operator if supplied
if (operatorAND)
{
fullTextBuf.append(OP_AND);
nameAttrBuf.append(OP_AND);
}
if (term.charAt(0) != OP_WILDCARD) if (term.charAt(0) != OP_WILDCARD)
{ {
@@ -222,11 +246,12 @@ public final class SearchContext implements Serializable
fullTextBuf.append("TEXT:*").append(safeTerm).append(OP_WILDCARD); fullTextBuf.append("TEXT:*").append(safeTerm).append(OP_WILDCARD);
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeTerm).append(OP_WILDCARD); nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeTerm).append(OP_WILDCARD);
} }
fullTextBuf.append(' ');
nameAttrBuf.append(' ');
}
} }
fullTextBuf.append(')'); fullTextBuf.append(')');
nameAttrBuf.append(')'); nameAttrBuf.append(')');
fullTextQuery = fullTextBuf.toString();
nameAttrQuery = nameAttrBuf.toString();
} }
} }
@@ -349,13 +374,15 @@ public final class SearchContext implements Serializable
// match against FOLDER type // match against FOLDER type
String folderTypeQuery = " TYPE:\"{" + NamespaceService.CONTENT_MODEL_1_0_URI + "}folder\" "; String folderTypeQuery = " TYPE:\"{" + NamespaceService.CONTENT_MODEL_1_0_URI + "}folder\" ";
String fullTextQuery = fullTextBuf.toString();
String nameAttrQuery = nameAttrBuf.toString();
if (text.length() != 0 && text.length() >= minimum) if (text.length() != 0 && text.length() >= minimum)
{ {
// text query for name and/or full text specified // text query for name and/or full text specified
switch (mode) switch (mode)
{ {
case SearchContext.SEARCH_ALL: case SearchContext.SEARCH_ALL:
query = '(' + fileTypeQuery + " AND " + '(' + nameAttrQuery + fullTextQuery + ')' + ')' + " OR " + query = '(' + fileTypeQuery + " AND " + '(' + nameAttrQuery + ' ' + fullTextQuery + ')' + ')' + " OR " +
'(' + folderTypeQuery + " AND " + nameAttrQuery + ')'; '(' + folderTypeQuery + " AND " + nameAttrQuery + ')';
break; break;
@@ -364,7 +391,7 @@ public final class SearchContext implements Serializable
break; break;
case SearchContext.SEARCH_FILE_NAMES_CONTENTS: case SearchContext.SEARCH_FILE_NAMES_CONTENTS:
query = fileTypeQuery + " AND " + '(' + nameAttrQuery + fullTextQuery + ')'; query = fileTypeQuery + " AND " + '(' + nameAttrQuery + ' ' + fullTextQuery + ')';
break; break;
case SearchContext.SEARCH_SPACE_NAMES: case SearchContext.SEARCH_SPACE_NAMES:

View File

@@ -41,7 +41,7 @@ public class PageTag extends TagSupport
private final static String SCRIPTS_WEBDAV = "/scripts/webdav.js\"></script>\n"; private final static String SCRIPTS_WEBDAV = "/scripts/webdav.js\"></script>\n";
private final static String STYLES_START = "<link rel=\"stylesheet\" href=\""; private final static String STYLES_START = "<link rel=\"stylesheet\" href=\"";
private final static String STYLES_MAIN = "/css/main.css\" TYPE=\"text/css\">\n"; private final static String STYLES_MAIN = "/css/main.css\" TYPE=\"text/css\">\n";
private final static String ALF_URL = "http://www.alfrescosoftware.com"; private final static String ALF_URL = "http://www.alfresco.com";
private final static String ALF_LOGO = "/images/logo/alfresco_logo.gif"; private final static String ALF_LOGO = "/images/logo/alfresco_logo.gif";
private final static String ALF_TEXT = "Content managed by Alfresco"; private final static String ALF_TEXT = "Content managed by Alfresco";
private final static String ALF_COPY = "Alfresco Software Inc. <20> 2005 All rights reserved."; private final static String ALF_COPY = "Alfresco Software Inc. <20> 2005 All rights reserved.";

View File

@@ -244,7 +244,7 @@ public class SystemErrorTag extends TagSupport
{ {
out.write("\n<div style='padding-top:16px;'><a href='"); out.write("\n<div style='padding-top:16px;'><a href='");
out.write(((HttpServletRequest)pageContext.getRequest()).getContextPath()); out.write(((HttpServletRequest)pageContext.getRequest()).getContextPath());
out.write(ExternalAccessServlet.generateExternalURL("browse", null)); out.write(ExternalAccessServlet.generateExternalURL("logout", null));
out.write("'>"); out.write("'>");
out.write(bundle.getString(MSG_LOGOUT)); out.write(bundle.getString(MSG_LOGOUT));
out.write("</a></div>"); out.write("</a></div>");