diff --git a/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java b/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java index 1fd8fe2b6d..4b7ec472f1 100644 --- a/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java +++ b/source/java/org/alfresco/web/app/servlet/ExternalAccessServlet.java @@ -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); } diff --git a/source/java/org/alfresco/web/bean/SearchContext.java b/source/java/org/alfresco/web/bean/SearchContext.java index 602aef2b6a..80d2294905 100644 --- a/source/java/org/alfresco/web/bean/SearchContext.java +++ b/source/java/org/alfresco/web/bean/SearchContext.java @@ -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: diff --git a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java index f04675f666..3f92d59294 100644 --- a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java +++ b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java @@ -41,7 +41,7 @@ public class PageTag extends TagSupport private final static String SCRIPTS_WEBDAV = "/scripts/webdav.js\">\n"; private final static String STYLES_START = "\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. © 2005 All rights reserved."; diff --git a/source/java/org/alfresco/web/ui/repo/tag/SystemErrorTag.java b/source/java/org/alfresco/web/ui/repo/tag/SystemErrorTag.java index 7643056646..0d8f42d9ac 100644 --- a/source/java/org/alfresco/web/ui/repo/tag/SystemErrorTag.java +++ b/source/java/org/alfresco/web/ui/repo/tag/SystemErrorTag.java @@ -244,7 +244,7 @@ public class SystemErrorTag extends TagSupport { out.write("\n
");