02-14-2011 06:59 AM
03-28-2011 10:37 AM
03-28-2011 10:43 AM
 
					
				
		
03-30-2011 05:30 AM
 
					
				
			
			
				
			
			
			
			
			
			
			
		04-04-2011 06:28 AM
04-05-2011 11:34 AM
<%
/**
 * Copyright (C) 2010  John Baskeyfield, john.baskeyfield@gmail.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
%>
<%@ include file="init.jsp" %>
<%
   Log logger = LogFactory.getLog("alfrescosearch");
   
   PortletPreferences preferences = renderRequest.getPreferences();
   String endPoint = preferences.getValue("endPoint", new String());
   String user = preferences.getValue("user", new String());
   String password = preferences.getValue("password", new String());
   String keywords = request.getParameter("keywords");
   int results = Integer.parseInt(preferences.getValue("results", new String()));
   
   PortletURL portletURL = renderResponse.createRenderURL();
%>
<form action="<%=portletURL%>" method="POST">
   <input type="text" name="keywords" value="<%if(keywords != null) out.println(keywords); %>"/>
   <input type="submit" value="Search" />
</form>
<br>
<%
   if (keywords != null){
      
      try{      
         WebServiceFactory.setEndpointAddress(endPoint+"/api");
         AuthenticationUtils.startSession(user, password);
         Reference parentReference = null;        
         RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService(); 
         Query query = new Query("lucene", "ALL:'" + keywords + "'");       
         Store storeRef = new Store("workspace", "SpacesStore");
         Node [] nodes = null;
         nodes = WebServiceFactory.getRepositoryService().get(new Predicate(null,storeRef,query));         
         int pageIndex = 0;
         int resultIndex = 0;
         int pageResults = 0;
         int iterations = 0;
         String name = null;
         String uuid = null;
         String description = null;
         
         if (request.getParameter("position") == null ){ pageIndex = 0;} else { pageIndex = Integer.parseInt(request.getParameter("position"));}   
         if (nodes != null){
            NamedValue[] props = null;
%>
<table width="100%" class="lfr-table">
      <tbody>
        <tr>
          <td width="70%" valign="top">
            <div style="padding-bottom: 5px;">
              <b>Alfresco</b>
            </div>
            <div class="results-grid">
              <table class="taglib-search-iterator">
                <tbody>
                  <tr class="portlet-section-header results-header">
                    <th width="18px" class="col-1">
                      #
                    </th>
                    <th class="col-2">
                      Name
                    </th>
                    <th class="col-3">
                      Description
                    </th>
                  </tr>
                  <tr class="lfr-template portlet-section-body results-row">
                    <td width="18px"></td>
                    <td></td>
                    <td></td>
                  </tr>
<%
   if (nodes.length - (pageIndex * results) > results){iterations = (pageIndex * results)+results;}else{iterations=nodes.length;}
      for (int x = pageIndex * results; x < iterations; x++)
      {
         props=nodes[x].getProperties();
         pageResults++;
         for(int y = 0; y < props.length; y++) 
         {
            if(props[y].getName().endsWith("{http://www.alfresco.org/model/content/1.0}name") == true) {                   
               name=props[y].getValue();
            }
            if(props[y].getName().endsWith("{http://www.alfresco.org/model/content/1.0}description") == true) {                   
               description=props[y].getValue();
            }
            if(props[y].getName().endsWith("{http://www.alfresco.org/model/system/1.0}node-uuid") == true) {             
               uuid=props[y].getValue();
            }
         }   
         if((x-(pageIndex * results))%2 == 0) {
%>
               <tr height="22px" onmouseout="this.className = 'portlet-section-body results-row';"
                       onmouseover="this.className = 'portlet-section-body-hover results-row hover';"
                       class="portlet-section-body results-row">
<%}else{%>
               <tr height="22px" onmouseout="this.className = 'portlet-section-alternate results-row alt';"
                       onmouseover="this.className = 'portlet-section-alternate-hover results-row alt hover';"
                       class="portlet-section-alternate results-row alt">
<%}%>
                        <td width="18px" align="left" valign="middle" colspan="1" class="col-1">
                          <%=resultIndex+1+(pageIndex*results)%>.
                        </td>
                        <td align="left" valign="middle" colspan="1" class="col-2">
                           <a target="_blank" href="<%=endPoint%>/d/a/workspace/SpacesStore/<%=uuid%>/<%=name%>"><%=name%></a>
                        </td>
                        <td align="left" valign="middle" colspan="1" class="col-3">
                        <%if(description!=null) out.println(description); %>
                        </td>
               </tr>
<%
            resultIndex++;                        
            }
%>
                     </tbody>
                  </table>
               </div>
            <div class="taglib-search-iterator-page-iterator-bottom">
               <div class="taglib-page-iterator">
                  <div class="search-results">
                     <%if(nodes.length <= results){%>
                        <%=pageResults%> results.<p> </p>
                     <%}else{%>
                        Results <%=(pageIndex * results)+1%> - <%=(resultIndex+(pageIndex * results))%> of <%=nodes.length%>.
                     <%}%>
                  </div>
               </div>
            </div>
         </td>
      </tr>
   </tbody>
</table>
<%
      PortletURL portletURLpage = renderResponse.createRenderURL();
      portletURLpage.setParameter("keywords", keywords);
      if(nodes.length > results){
         for (int x = 0; x < Math.ceil( (double)nodes.length / (double)results ); x++){
%>
            <a href="<%=portletURLpage%>&position=<%=x%>"><%=x+1%></a>
<%
            if(x != (Math.ceil( (double)nodes.length / (double)results ))-1){out.println(" ,");}
         }
%>
<p> </p>
<%
      }            
    }else{
%>
          <p>No results found.</p>
<%
      }
        
        }catch(AuthenticationFault af){
         out.println("<p>Invalid User/Password for Alfresco. Please set preferences.</p>");
        }catch(WebServiceException wse){
         out.println("<p>Unable to connect to Alfresco url. Please set preferences.</p>");      
        }catch(Exception ex){
           logger.error(ex.getMessage());
      }
        finally
        {
            // End the session
            AuthenticationUtils.endSession();      
        }
}
%>04-12-2011 03:42 AM
 ites/*/cm:Exchange/"+keywords+"\"");
ites/*/cm:Exchange/"+keywords+"\"");04-12-2011 05:16 AM
 ites/*/cm:Exchange/"+keywords+"\"");
ites/*/cm:Exchange/"+keywords+"\"");
					
				
			
			
				
			
			
			
			
			
			
			
		 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.