mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
. 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:
@@ -32,7 +32,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.LoginBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
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_SPACEDETAILS = "showSpaceDetails";
|
||||
private final static String OUTCOME_BROWSE = "browse";
|
||||
private final static String OUTCOME_LOGOUT = "logout";
|
||||
|
||||
private static final String ARG_TEMPLATE = "template";
|
||||
|
||||
@@ -181,44 +184,55 @@ public class ExternalAccessServlet extends BaseServlet
|
||||
}
|
||||
else if (OUTCOME_BROWSE.equals(outcome))
|
||||
{
|
||||
if (args != null)
|
||||
if (args != null && args.length >= 3)
|
||||
{
|
||||
NodeRef nodeRef = null;
|
||||
int offset = 0;
|
||||
if (args.length >= 3)
|
||||
|
||||
offset = args.length - 3;
|
||||
StoreRef storeRef = new StoreRef(args[0+offset], args[1+offset]);
|
||||
nodeRef = new NodeRef(storeRef, args[2+offset]);
|
||||
|
||||
// check that the user has at least READ access - else redirect to the login page
|
||||
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED)
|
||||
{
|
||||
offset = args.length - 3;
|
||||
StoreRef storeRef = new StoreRef(args[0+offset], args[1+offset]);
|
||||
nodeRef = new NodeRef(storeRef, args[2+offset]);
|
||||
|
||||
// check that the user has at least READ access - else redirect to the login page
|
||||
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("User does not have permissions to READ NodeRef: " + nodeRef.toString());
|
||||
redirectToLoginPage(req, res);
|
||||
return;
|
||||
}
|
||||
|
||||
// this call sets up the current node Id, and updates or initialises the
|
||||
// breadcrumb component with the selected node as appropriate.
|
||||
browseBean.updateUILocation(nodeRef);
|
||||
|
||||
// force a "late" refresh of the BrowseBean to handle external servlet access URL
|
||||
browseBean.externalAccessRefresh();
|
||||
|
||||
// check for view mode first argument
|
||||
if (args[0].equals(ARG_TEMPLATE))
|
||||
{
|
||||
browseBean.setDashboardView(true);
|
||||
}
|
||||
|
||||
// the above calls setup the NavigationHandler automatically
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("User does not have permissions to READ NodeRef: " + nodeRef.toString());
|
||||
redirectToLoginPage(req, res);
|
||||
return;
|
||||
}
|
||||
|
||||
// this call sets up the current node Id, and updates or initialises the
|
||||
// breadcrumb component with the selected node as appropriate.
|
||||
browseBean.updateUILocation(nodeRef);
|
||||
|
||||
// force a "late" refresh of the BrowseBean to handle external servlet access URL
|
||||
browseBean.externalAccessRefresh();
|
||||
|
||||
// check for view mode first argument
|
||||
if (args[0].equals(ARG_TEMPLATE))
|
||||
{
|
||||
browseBean.setDashboardView(true);
|
||||
}
|
||||
|
||||
// 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
|
||||
String viewId = fc.getViewRoot().getViewId();
|
||||
getServletContext().getRequestDispatcher(FACES_SERVLET + viewId).forward(req, res);
|
||||
}
|
||||
|
@@ -141,27 +141,44 @@ public final class SearchContext implements Serializable
|
||||
|
||||
// match against content text
|
||||
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.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
|
||||
if (text.charAt(0) != OP_WILDCARD)
|
||||
{
|
||||
// escape characters and append the wildcard character
|
||||
String safeText = QueryParser.escape(text);
|
||||
fullTextQuery = " TEXT:" + safeText + OP_WILDCARD;
|
||||
nameAttrQuery = " @" + nameAttr + ":" + safeText + OP_WILDCARD;
|
||||
fullTextBuf.append("TEXT:").append(safeText).append(OP_WILDCARD);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":").append(safeText).append(OP_WILDCARD);
|
||||
}
|
||||
else
|
||||
{
|
||||
// found a leading wildcard - prepend it again after escaping the other characters
|
||||
String safeText = QueryParser.escape(text.substring(1));
|
||||
fullTextQuery = " TEXT:*" + safeText + OP_WILDCARD;
|
||||
nameAttrQuery = " @" + nameAttr + ":*" + safeText + OP_WILDCARD;
|
||||
fullTextBuf.append("TEXT:*").append(safeText).append(OP_WILDCARD);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeText).append(OP_WILDCARD);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -171,15 +188,14 @@ public final class SearchContext implements Serializable
|
||||
{
|
||||
// as a single quoted phrase
|
||||
String quotedSafeText = '"' + QueryParser.escape(text.substring(1, text.length() - 1)) + '"';
|
||||
fullTextQuery = " TEXT:" + quotedSafeText;
|
||||
nameAttrQuery = " @" + nameAttr + ":" + quotedSafeText;
|
||||
fullTextBuf.append("TEXT:").append(quotedSafeText);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":").append(quotedSafeText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// as individual search terms
|
||||
StringTokenizer t = new StringTokenizer(text, " ");
|
||||
StringBuilder fullTextBuf = new StringBuilder(64);
|
||||
StringBuilder nameAttrBuf = new StringBuilder(64);
|
||||
|
||||
fullTextBuf.append('(');
|
||||
nameAttrBuf.append('(');
|
||||
int tokenCount = t.countTokens();
|
||||
@@ -196,37 +212,46 @@ public final class SearchContext implements Serializable
|
||||
term = term.substring(1);
|
||||
}
|
||||
|
||||
// operators such as AND and OR are only make sense for full text searching
|
||||
if (i != 0)
|
||||
if (term.length() != 0)
|
||||
{
|
||||
fullTextBuf.append(operatorAND ? " AND " : " OR ");
|
||||
nameAttrBuf.append(operatorAND ? " AND " : " OR ");
|
||||
}
|
||||
|
||||
// prepend NOT operator if supplied
|
||||
if (operatorNOT)
|
||||
{
|
||||
fullTextBuf.append(OP_NOT);
|
||||
nameAttrBuf.append(OP_NOT);
|
||||
}
|
||||
|
||||
if (term.charAt(0) != OP_WILDCARD)
|
||||
{
|
||||
String safeTerm = QueryParser.escape(term);
|
||||
fullTextBuf.append("TEXT:").append(safeTerm).append(OP_WILDCARD);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":").append(safeTerm).append(OP_WILDCARD);
|
||||
}
|
||||
else
|
||||
{
|
||||
String safeTerm = QueryParser.escape(term.substring(1));
|
||||
fullTextBuf.append("TEXT:*").append(safeTerm).append(OP_WILDCARD);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeTerm).append(OP_WILDCARD);
|
||||
// operators such as AND and OR are only make sense for full text searching
|
||||
if (i != 0 && !operatorAND)
|
||||
{
|
||||
fullTextBuf.append("OR ");
|
||||
nameAttrBuf.append("OR ");
|
||||
}
|
||||
|
||||
// prepend NOT operator if supplied
|
||||
if (operatorNOT)
|
||||
{
|
||||
fullTextBuf.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)
|
||||
{
|
||||
String safeTerm = QueryParser.escape(term);
|
||||
fullTextBuf.append("TEXT:").append(safeTerm).append(OP_WILDCARD);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":").append(safeTerm).append(OP_WILDCARD);
|
||||
}
|
||||
else
|
||||
{
|
||||
String safeTerm = QueryParser.escape(term.substring(1));
|
||||
fullTextBuf.append("TEXT:*").append(safeTerm).append(OP_WILDCARD);
|
||||
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeTerm).append(OP_WILDCARD);
|
||||
}
|
||||
fullTextBuf.append(' ');
|
||||
nameAttrBuf.append(' ');
|
||||
}
|
||||
}
|
||||
fullTextBuf.append(')');
|
||||
nameAttrBuf.append(')');
|
||||
fullTextQuery = fullTextBuf.toString();
|
||||
nameAttrQuery = nameAttrBuf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,13 +374,15 @@ public final class SearchContext implements Serializable
|
||||
// match against FOLDER type
|
||||
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)
|
||||
{
|
||||
// text query for name and/or full text specified
|
||||
switch (mode)
|
||||
{
|
||||
case SearchContext.SEARCH_ALL:
|
||||
query = '(' + fileTypeQuery + " AND " + '(' + nameAttrQuery + fullTextQuery + ')' + ')' + " OR " +
|
||||
query = '(' + fileTypeQuery + " AND " + '(' + nameAttrQuery + ' ' + fullTextQuery + ')' + ')' + " OR " +
|
||||
'(' + folderTypeQuery + " AND " + nameAttrQuery + ')';
|
||||
break;
|
||||
|
||||
@@ -364,7 +391,7 @@ public final class SearchContext implements Serializable
|
||||
break;
|
||||
|
||||
case SearchContext.SEARCH_FILE_NAMES_CONTENTS:
|
||||
query = fileTypeQuery + " AND " + '(' + nameAttrQuery + fullTextQuery + ')';
|
||||
query = fileTypeQuery + " AND " + '(' + nameAttrQuery + ' ' + fullTextQuery + ')';
|
||||
break;
|
||||
|
||||
case SearchContext.SEARCH_SPACE_NAMES:
|
||||
|
@@ -41,7 +41,7 @@ public class PageTag extends TagSupport
|
||||
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_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_TEXT = "Content managed by Alfresco";
|
||||
private final static String ALF_COPY = "Alfresco Software Inc. <20> 2005 All rights reserved.";
|
||||
|
@@ -244,7 +244,7 @@ public class SystemErrorTag extends TagSupport
|
||||
{
|
||||
out.write("\n<div style='padding-top:16px;'><a href='");
|
||||
out.write(((HttpServletRequest)pageContext.getRequest()).getContextPath());
|
||||
out.write(ExternalAccessServlet.generateExternalURL("browse", null));
|
||||
out.write(ExternalAccessServlet.generateExternalURL("logout", null));
|
||||
out.write("'>");
|
||||
out.write(bundle.getString(MSG_LOGOUT));
|
||||
out.write("</a></div>");
|
||||
|
Reference in New Issue
Block a user