portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r1721082 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/search/ resources/org/apache/jetspeed/portlets/search/ resources/org/apache/jetspeed/portlets/search/resources/ webapp/WEB-INF/ webapp...
Date Mon, 21 Dec 2015 04:07:14 GMT
Author: taylor
Date: Mon Dec 21 04:07:14 2015
New Revision: 1721082

URL: http://svn.apache.org/viewvc?rev=1721082&view=rev
Log:
JS2-1348: implemented 2 new portlets, search and search results

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/PortletToPageMap.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchInfo.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchResultsPortlet.java
      - copied, changed from r1709948, portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/resources/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/resources/SearchResources.properties
      - copied, changed from r1709942, portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search-results.jsp
      - copied, changed from r1709947, portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/PortletToPageMap.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/PortletToPageMap.java?rev=1721082&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/PortletToPageMap.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/PortletToPageMap.java
Mon Dec 21 04:07:14 2015
@@ -0,0 +1,52 @@
+package org.apache.jetspeed.portlets.search;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Created by dtaylor on 12/5/15.
+ */
+public class PortletToPageMap {
+    private Map<String, List<String>> portletMap;
+    private Map<String, List<String>> contentMap;
+
+    public PortletToPageMap() {
+        portletMap = new ConcurrentHashMap<>();
+        contentMap = new ConcurrentHashMap<>();
+    }
+
+    public void putPortlet(String portlet, String pagePath) {
+        List<String> pages = portletMap.get(portlet);
+        if (pages == null) {
+            pages = new ArrayList<>();
+            portletMap.put(portlet, pages);
+        }
+        pages.add(pagePath);
+    }
+
+    public void putContent(String contentPath, String pagePath) {
+        List<String> pages = contentMap.get(contentPath);
+        if (pages == null) {
+            pages = new ArrayList<>();
+            contentMap.put(contentPath, pages);
+        }
+        pages.add(pagePath);
+    }
+
+    public List<String> getPortlet(String portlet) {
+        return portletMap.get(portlet);
+    }
+    public List<String> getContent(String portlet) {
+        return contentMap.get(portlet);
+    }
+
+    public int portletSize() {
+        return portletMap.size();
+    }
+
+    public int contentSize() {
+        return contentMap.size();
+    }
+}

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchInfo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchInfo.java?rev=1721082&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchInfo.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchInfo.java
Mon Dec 21 04:07:14 2015
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.search;
+
+/**
+ * Created by dtaylor on 12/4/15.
+ */
+public class SearchInfo {
+
+    private String title;
+    private String type;
+    private String key;
+    private Float score;
+    private String description;
+    private String link;
+
+    public SearchInfo(String title, String type, String key, Float score, String description,
String link) {
+        this.title = title;
+        this.type = type;
+        this.key = key;
+        this.score = score;
+        this.description = description;
+        this.link = link;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public Float getScore() {
+        return score;
+    }
+
+    public void setScore(Float score) {
+        this.score = score;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getLink() {
+        return link;
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+}

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java?rev=1721082&r1=1721081&r2=1721082&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java
Mon Dec 21 04:07:14 2015
@@ -17,16 +17,36 @@
 package org.apache.jetspeed.portlets.search;
 
 import org.apache.jetspeed.CommonPortletServices;
-import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.administration.PortalAdministration;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.om.page.FragmentReference;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.page.document.NodeSet;
+import org.apache.jetspeed.search.ParsedObject;
 import org.apache.jetspeed.search.SearchEngine;
+import org.apache.jetspeed.search.SearchResults;
 import org.apache.portals.bridges.common.GenericServletPortlet;
 
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * Jetspeed Search Portlet
@@ -34,27 +54,193 @@ import java.io.IOException;
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  * @version $Id$
  */
-public class SearchPortlet extends GenericServletPortlet
-{
+public class SearchPortlet extends GenericServletPortlet {
+    public static final String SEARCH_KEY = "SEARCH_KEY";
+    public static final String SEARCH_RESULTS = "SEARCH_RESULTS";
+    public static final String DEFAULT_SEARCH_RESULTS_PAGE = "/search/results.psml";
+
     private SearchEngine searchEngine;
+    private PortalAdministration admin;
+    private PageManager pageManager;
+    private PortletRegistry portletRegistry;
+
+    private String filePreference;
+    private String portletClass;
+    private String mountPoint;
 
-    public void init(PortletConfig config) throws PortletException
-    {
+    public void init(PortletConfig config) throws PortletException {
         super.init(config);
         PortletContext context = getPortletContext();
         searchEngine = (SearchEngine) context.getAttribute(CommonPortletServices.CPS_SEARCH_COMPONENT);
-        if (searchEngine == null)
-                throw new PortletException(
-                        "Could not get instance of portal Search Engine component");
+        if (searchEngine == null) {
+            throw new PortletException(
+                    "Could not get instance of portal Search Engine component");
+        }
+        admin = (PortalAdministration) getPortletContext().getAttribute(
+                CommonPortletServices.CPS_PORTAL_ADMINISTRATION);
+        if (null == admin) {
+            throw new PortletException(
+                    "Failed to find the Portal Administration on portlet initialization");
+        }
+        pageManager = (PageManager) context.getAttribute(CommonPortletServices.CPS_PAGE_MANAGER_COMPONENT);
+        if (pageManager == null)
+            throw new PortletException(
+                    "Could not get instance of portal PageManager component");
+        portletRegistry = (PortletRegistry) context.getAttribute(CommonPortletServices.CPS_REGISTRY_COMPONENT);
+        if (portletRegistry == null)
+            throw new PortletException(
+                    "Could not get instance of portal PortletRegistry component");
+        filePreference = config.getInitParameter("FilePreference");
+        portletClass = config.getInitParameter("PortletClass");
+        mountPoint = config.getInitParameter("MountPoint");
+
     }
 
     public void doView(RenderRequest request, RenderResponse response)
-            throws PortletException, IOException
-    {    
-        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+            throws PortletException, IOException {
         String viewPage = getPortletConfig().getInitParameter("ViewPage");
         getPortletContext().getRequestDispatcher(viewPage).include(request, response);
-        // TODO: complete this portlet
     }
 
+    @Override
+    public void processAction(ActionRequest request, ActionResponse actionResponse) throws
PortletException, IOException {
+        String jsSearch = request.getParameter("jsSearch");
+        if (jsSearch == null) {
+            jsSearch = "";
+        }
+        SearchResults searchResults = searchEngine.search(jsSearch);
+        List<SearchInfo> searchInfoResults = new ArrayList<>();
+        for (ParsedObject result : searchResults.getResults()) {
+            if (result.getType().equals("url")) {
+                int index = result.getTitle().indexOf(mountPoint);
+                if (index > -1) {
+                    String key = result.getTitle().substring(index);
+                    if (key != null) {
+                        List<String> links = getPortletToPageMap().getContent(key);
+                        String link = getBestLink(links);
+                        searchInfoResults.add(new SearchInfo(key, result.getType(), link,
result.getScore(), result.getDescription(),
+                                admin.getPortalURL(request, actionResponse, link)));
+                    }
+                }
+            } else {
+                String key = result.getKey().substring(result.getKey().indexOf("::") + 2);
+                List<String> links = getPortletToPageMap().getPortlet(key);
+                String link = getBestLink(links);
+                searchInfoResults.add(new SearchInfo(result.getTitle(), result.getType(),
key, result.getScore(), result.getDescription(),
+                        admin.getPortalURL(request, actionResponse, link)));
+            }
+        }
+        request.getPortletSession().setAttribute(SEARCH_RESULTS, searchInfoResults, PortletSession.APPLICATION_SCOPE);
+        request.getPortletSession().setAttribute(SEARCH_KEY, jsSearch, PortletSession.APPLICATION_SCOPE);
+        String redirect = admin.getPortalURL(request, actionResponse, DEFAULT_SEARCH_RESULTS_PAGE);
+        actionResponse.sendRedirect(redirect);
+    }
+
+    private static PortletToPageMap map = null;
+
+    private PortletToPageMap getPortletToPageMap() {
+        if (map == null) {
+            System.out.println(".... starting loading of portlet page map");
+            long start = System.currentTimeMillis();
+            map = buildPortletToPageMap();
+            System.out.println(".... completed loading of " + map.portletSize() + " portlet
page map in " + (System.currentTimeMillis() - start) + " ms");
+        }
+        return map;
+    }
+
+    /**
+     * Build a map of portlets to pages where they exist
+     *
+     * @return
+     */
+    private synchronized PortletToPageMap buildPortletToPageMap() {
+        PortletToPageMap map = new PortletToPageMap();
+        try {
+            Folder root = pageManager.getFolder("/");
+            traverse(root, map);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+    private void traverse(Folder folder, PortletToPageMap map) {
+        try {
+            for (Node node : folder.getAll()) {
+                switch (node.getType()) {
+                    case Folder.FOLDER_TYPE:
+                        traverse((Folder) node, map);
+                        break;
+                    case Page.DOCUMENT_TYPE:
+                        visitPortlets((Fragment) ((Page) node).getRootFragment(), map, node.getPath());
+                        break;
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void visitPortlets(Fragment root, PortletToPageMap map, String pagePath) {
+        try {
+            for (BaseFragmentElement f : root.getFragments()) {
+                if (f instanceof FragmentReference) {
+                    FragmentReference fragmentReference = (FragmentReference) f;
+                    NodeSet definitions = pageManager.getFragmentDefinitions(pageManager.getFolder("/"));
+                    Iterator<Node> it = definitions.iterator();
+                    while (it.hasNext()) {
+                        Node n = it.next();
+                        Fragment fragment = (Fragment) ((FragmentDefinition) n).getRootFragment();
+                        String contentPath = getContentFilePath(fragment.getName());
+                        if (contentPath != null) {
+                            map.putContent(contentPath, pagePath);
+                        } else {
+                            map.putPortlet(fragment.getName(), pagePath);
+                        }
+                    }
+                } else {
+                    Fragment fragment = (Fragment) f;
+                    String contentPath = getContentFilePath(fragment.getName());
+                    if (contentPath != null) {
+                        map.putContent(contentPath, pagePath);
+                    } else {
+                        map.putPortlet(fragment.getName(), pagePath);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private String getContentFilePath(String uniqueName) {
+        PortletDefinition portlet = portletRegistry.getPortletDefinitionByUniqueName(uniqueName);
+        if (portlet != null) {
+            if (portlet.getPortletClass().equals(portletClass)) {
+                Preference pref = portlet.getPortletPreferences().getPortletPreference(filePreference);
+                if (pref != null) {
+                    List<String> values = pref.getValues();
+                    if (values.size() > 0) {
+                        return values.get(0);
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private String getBestLink(List<String> links) {
+        if (links == null || links.size() == 0) {
+            return "/";
+        }
+        String best = links.get(0);
+        for (String link: links) {
+            if (link.startsWith("/_")) {
+                continue;
+            }
+            best = link;
+        }
+        return best;
+    }
 }

Copied: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchResultsPortlet.java
(from r1709948, portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchResultsPortlet.java?p2=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchResultsPortlet.java&p1=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java&r1=1709948&r2=1721082&rev=1721082&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/search/SearchResultsPortlet.java
Mon Dec 21 04:07:14 2015
@@ -17,16 +17,18 @@
 package org.apache.jetspeed.portlets.search;
 
 import org.apache.jetspeed.CommonPortletServices;
-import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.search.SearchEngine;
 import org.apache.portals.bridges.common.GenericServletPortlet;
 
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Jetspeed Search Portlet
@@ -34,27 +36,31 @@ import java.io.IOException;
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  * @version $Id$
  */
-public class SearchPortlet extends GenericServletPortlet
-{
+public class SearchResultsPortlet extends GenericServletPortlet {
+    public static final String SEARCH_PAGE_MAP = "searchPageMap";
     private SearchEngine searchEngine;
 
-    public void init(PortletConfig config) throws PortletException
-    {
+    public void init(PortletConfig config) throws PortletException {
         super.init(config);
         PortletContext context = getPortletContext();
         searchEngine = (SearchEngine) context.getAttribute(CommonPortletServices.CPS_SEARCH_COMPONENT);
         if (searchEngine == null)
-                throw new PortletException(
-                        "Could not get instance of portal Search Engine component");
+            throw new PortletException(
+                    "Could not get instance of portal Search Engine component");
     }
 
     public void doView(RenderRequest request, RenderResponse response)
-            throws PortletException, IOException
-    {    
-        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+            throws PortletException, IOException {
+
         String viewPage = getPortletConfig().getInitParameter("ViewPage");
+        List<SearchInfo> results = (List<SearchInfo>) request.getPortletSession().getAttribute(SearchPortlet.SEARCH_RESULTS,
PortletSession.APPLICATION_SCOPE);
+        if (results == null) {
+            results = new ArrayList<>();
+        }
+        String searchKey = (String) request.getPortletSession().getAttribute(SearchPortlet.SEARCH_KEY,
PortletSession.APPLICATION_SCOPE);
+        request.setAttribute(SearchPortlet.SEARCH_KEY, searchKey);
+        request.setAttribute(SearchPortlet.SEARCH_RESULTS, results);
         getPortletContext().getRequestDispatcher(viewPage).include(request, response);
-        // TODO: complete this portlet
     }
 
-}
+}
\ No newline at end of file

Copied: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/resources/SearchResources.properties
(from r1709942, portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/resources/SearchResources.properties?p2=portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/resources/SearchResources.properties&p1=portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties&r1=1709942&r2=1721082&rev=1721082&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/search/resources/SearchResources.properties
Mon Dec 21 04:07:14 2015
@@ -16,42 +16,8 @@
 # $Id$
 #
 
-spaces.label.name = Name
-spaces.label.title = Title
-spaces.label.description = Description
-spaces.label.owner = Owner
-spaces.label.security = Security
-spaces.label.theme = Theme
-spaces.table.title = Spaces
-spaces.label.edit = Edit
-spaces.label.delete = Delete
-spaces.label.add = Add Space
-spaces.label.edit.current = Edit Current Space
-spaces.label.save = Save
-spaces.label.cancel = Cancel
-spaces.message.forbidden = You are not allowed to edit the current space.
-spaces.message.confirm.delete = Are you sure to delete this item?
-
-spaces.pages.label.nodeType.folder = Folder
-spaces.pages.label.nodeType..psml = Page
-spaces.pages.label.nodeType..link = Link
-spaces.pages.label.add = Add
-spaces.pages.label.rename = Rename
-spaces.pages.label.documentOrdering = Document Ordering
-spaces.pages.label.changeUrl = Change URL
-spaces.pages.label.delete = Delete
-spaces.pages.label.move = Move
-spaces.pages.label.copy = Copy
-spaces.pages.label.space.title = {0}
-spaces.pages.label.template = Template
-spaces.pages.label.close = Close
-spaces.pages.label.ok = OK
-spaces.pages.label.cancel = Cancel
-spaces.pages.message.prompt.title = Please enter the title.
-spaces.pages.message.prompt.url = Please enter the URL.
-spaces.pages.message.confirm.delete = Are you sure to delete this item?
-spaces.pages.message.confirm.choosefolder = Choose a target folder.
-spaces.pages.message.confirm.move = Are you sure to move this item?
-spaces.pages.message.confirm.copy = Are you sure to copy this item?
-spaces.pages.message.choose.different.target = Please choose a different target folder from
the current folder.
-spaces.pages.message.choose.existing.target = There already exists the same item in the target
folder.
+search.label.title = Title
+search.label.type = Type
+search.label.name = Name
+search.label.score = Score
+search.label.description = Description

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=1721082&r1=1721081&r2=1721082&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Mon
Dec 21 04:07:14 2015
@@ -2865,6 +2865,20 @@
         <name>ViewPage</name>
         <value>/WEB-INF/view/search/search.jsp</value>
     </init-param>
+
+    <init-param>
+      <name>FilePreference</name>
+      <value>file</value>
+    </init-param>
+    <init-param>
+      <name>PortletClass</name>
+      <value>org.apache.portals.gems.file.FilePortlet</value>
+    </init-param>
+    <init-param>
+      <name>MountPoint</name>
+      <value>/WEB-INF</value>
+    </init-param>
+
     <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>VIEW</portlet-mode>
@@ -2876,6 +2890,26 @@
     </portlet-info>
   </portlet>
 
+  <portlet>
+    <description>Search Results Portlet</description>
+    <portlet-name>SearchResultsPortlet</portlet-name>
+    <display-name>Search Results Portlet</display-name>
+    <portlet-class>org.apache.jetspeed.portlets.search.SearchResultsPortlet</portlet-class>
+    <init-param>
+      <name>ViewPage</name>
+      <value>/WEB-INF/view/search/search-results.jsp</value>
+    </init-param>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <portlet-info>
+      <title>Search Results</title>
+      <keywords>search,find,results,searchresults</keywords>
+    </portlet-info>
+  </portlet>
+
   <custom-portlet-mode>
     <description>Custom About Mode</description>
     <portlet-mode>about</portlet-mode>

Copied: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search-results.jsp
(from r1709947, portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search-results.jsp?p2=portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search-results.jsp&p1=portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp&r1=1709947&r2=1721082&rev=1721082&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search-results.jsp
Mon Dec 21 04:07:14 2015
@@ -15,13 +15,46 @@ See the License for the specific languag
 limitations under the License.
 
 --%>
+<%@page contentType="text/html" %>
 <%@page import="java.util.List"%>
-<%@page import="org.apache.jetspeed.page.document.Node"%>
-<%@page import="org.apache.jetspeed.portlets.spaces.BreadcrumbMenu.BreadcrumbMenuItem"
%>
-<%@ page contentType="text/html" %>
-<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@page import="org.apache.jetspeed.portlets.spaces.SpaceBean"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects/>
+<fmt:setBundle basename="org.apache.jetspeed.portlets.search.resources.SearchResources"
/>
+
+<form id='jsSearchList' method="POST" action='<portlet:actionURL/>'>
+    <table width='100%'>
+        <tr>
+            <th class="portlet-section-subheader"><fmt:message key="search.label.title"/></th>
+            <th class="portlet-section-subheader"><fmt:message key="search.label.type"/></th>
+            <th class="portlet-section-subheader"><fmt:message key="search.label.name"/></th>
+            <th class="portlet-section-subheader"><fmt:message key="search.label.score"/></th>
+            <th class="portlet-section-subheader"><fmt:message key="search.label.description"/></th>
+        </tr>
+        <c:forEach var="item" items="${SEARCH_RESULTS}" varStatus="status">
+            <c:choose>
+                <c:when test="${status.index % 2 == 0}">
+                    <c:set var="styleClass" value="'portlet-section-alternate'" />
+                </c:when>
+                <c:otherwise>
+                    <c:set var="styleClass" value="'portlet-section-body'" />
+                </c:otherwise>
+            </c:choose>
+            <tr>
+                <td class="${styleClass}">
+                    <a href="${item.link}">${item.title}</a>
+                </td>
+                <td class="${styleClass}">${item.type}</td>
+                <td class="${styleClass}">${item.key}</td>
+                <td class="${styleClass}">${item.score}</td>
+                <td class="${styleClass}">${item.description}</td>
+            </tr>
+        </c:forEach>
+        <tr>
+            <th class="portlet-section-header" colspan="5"></th>
+        </tr>
+    </table>
+</form>
 
-<input id="jsSearch" type="search" style='font-size: 8pt' placeholder='Search'/>
\ No newline at end of file

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp?rev=1721082&r1=1721081&r2=1721082&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/search/search.jsp
Mon Dec 21 04:07:14 2015
@@ -24,4 +24,18 @@ limitations under the License.
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects/>
 
-<input id="jsSearch" type="search" style='font-size: 8pt' placeholder='Search'/>
\ No newline at end of file
+<c:if test="${renderRequest.getUserPrincipal() != null}">
+<script type="text/javascript" language="javascript">
+    function submitJetspeedSearch(event) {
+        if (event.which == 13 || event.keyCode == 13) {
+            document.getElementById("<portlet:namespace/>-jetspeedSearchForm").submit();
+            return false;
+        }
+        return true;
+    };
+</script>
+
+<form id='<portlet:namespace/>=-jetspeedSearchForm' method="POST" action="<portlet:actionURL/>">
+    <input id="jsSearch" name='jsSearch' type="search" style='font-size: 8pt' placeholder='Search'
onkeypress="return submitJetspeedSearch(event)" />
+</form>
+</c:if>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message