11-28-2008 08:15 AM
package org.alfresco.sample.webservice;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLCreate;
import org.alfresco.webservice.types.ContentFormat;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.ParentReference;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.Utils;
import org.alfresco.webservice.util.WebServiceFactory;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import javax.xml.rpc.ServiceException;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.repository.RepositoryFault;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.WebServiceFactory;
import com.azeriland.models.supremeModel;
public class JoinTwoClass {
public static void main(String[] args)
throws Exception
{
// Start the session
AuthenticationUtils.startSession(USERNAME, PASSWORD);
try
{
// Make sure smaple data has been created
// createSampleData();
// Execute the search sample
executeSearch();
}
finally
{
// End the session
AuthenticationUtils.endSession();
}
}
private boolean useComlainers = true;
private boolean useAdditonalPersons = false;
private boolean useComplainer = false;
private boolean useAdditinalPerson = false;
protected static final String USERNAME = "RRR";
protected static final String PASSWORD = "rrr";
protected static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
//protected static final Reference SAMPLE_FOLDER = new Reference(STORE,null, "/sup:legalproc");
/* protected static void createSampleData() throws Exception
{
try
{
// Check to see if the sample folder has already been created or not
WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[]{SAMPLE_FOLDER}, STORE, null));
}
catch (Exception exception)
{
// Create parent reference to company home
ParentReference parentReference = new ParentReference(
STORE,
null,
"/sup:legalproc",
Constants.ASSOC_CONTAINS,
Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "sample_folder"));
}
}*/
public static Reference executeSearch() throws ServiceException, RemoteException, RepositoryFault
{
Reference parentReference = null;
// Get a reference to the respository web service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Create a query object, looking for all items with alfresco in the name of text
String searchPath = "PATH:\"/app:company_home/cm:Archive//*\"";
searchPath = searchPath + " AND TYPE:\"{http://www.com.azerland/model/supremecourt/1.0}legalproc\"";
//String propStr = "\\@" + Repository.escapeQName(supremeModel.PROPERTY_PROCID) + ":AM*";
String propStr = "\\@" + Repository.escapeQName(supremeModel.PROPERTY_PROCID) + ":AM*";
String searchString = searchPath + " AND (" + propStr + ")";
Query query = new Query(Constants.QUERY_LANG_LUCENE,searchString);
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows == null)
{
System.out.println("No query results found.");
}
else
{
System.out.println("Results from query:");
outputResultSet(rows);
// Get the id of the first result
String firstResultId = rows[0].getNode().getId();
Reference reference = new Reference(STORE, firstResultId, null);
// Get the parent(s) of the first result
QueryResult parentQueryResult = repositoryService.queryParents(reference);
// Get the parent of the first result
ResultSet parentResultSet = parentQueryResult.getResultSet();
ResultSetRow[] parentRows = parentResultSet.getRows();
}
return parentReference;
}
public static void outputResultSet(ResultSetRow[] rows)
{
if (rows != null)
{
for (int x = 0; x < rows.length; x++)
{
ResultSetRow row = rows[x];
System.out.println("—————————–");
System.out.println("id node = "+row.getColumns(5).getName() + " – " + "Node value = "+ row.getColumns(5).getValue());
}
}
}
}
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="org.alfresco.webservice.repository.UpdateResult"%>
<%@page import="org.alfresco.webservice.types.CML"%>
<%@page import="org.alfresco.webservice.types.CMLCreate"%>
<%@page import="org.alfresco.webservice.types.ContentFormat"%>
<%@page import="org.alfresco.webservice.types.NamedValue"%>
<%@page import="org.alfresco.webservice.types.ParentReference"%>
<%@page import="org.alfresco.webservice.types.Predicate"%>
<%@page import="org.alfresco.webservice.types.Reference"%>
<%@page import="org.alfresco.webservice.types.Store"%>
<%@page import="org.alfresco.webservice.util.Constants"%>
<%@page import="org.alfresco.webservice.util.Utils"%>
<%@page import="org.alfresco.webservice.util.WebServiceFactory"%>
<%@page import="java.rmi.RemoteException"%>
<%–@page import="javax.xml.rpc.ServiceException"–%>
<%@page import="org.alfresco.webservice.repository.QueryResult"%>
<%@page import="org.alfresco.webservice.repository.RepositoryFault"%>
<%@page import="org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub"%>
<%@page import="org.alfresco.webservice.types.Query"%>
<%@page import="org.alfresco.webservice.types.ResultSet"%>
<%@page import="org.alfresco.webservice.types.ResultSetRow"%>
<%@page import="org.alfresco.webservice.util.AuthenticationUtils"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%!
protected static final String USERNAME = "admin";
protected static final String PASSWORD = "admin";
protected static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
protected static final Reference SAMPLE_FOLDER = new Reference(STORE,null, "/app:company_home/cm:Intranet");
public static Reference executeSearch() throws RemoteException, RepositoryFault
{
try
{
Reference parentReference = null;
// Get a reference to the respository web service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Create a query object, looking for all items with alfresco in the name of text
Query query = new Query(Constants.QUERY_LANG_LUCENE, "@cm\\:name:EE*");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows == null)
{
System.out.println("No query results found.");
}
else
{
System.out.println("Results from query:");
outputResultSet(rows);
// Get the id of the first result
String firstResultId = rows[0].getNode().getId();
Reference reference = new Reference(STORE, firstResultId, null);
// Get the parent(s) of the first result
QueryResult parentQueryResult = repositoryService.queryParents(reference);
// Get the parent of the first result
ResultSet parentResultSet = parentQueryResult.getResultSet();
ResultSetRow[] parentRows = parentResultSet.getRows();
}
}
catch(ServiceException ee){}
return parentReference;
}
public static void outputResultSet(ResultSetRow[] rows)
{
if (rows != null)
{
for (int x = 0; x < rows.length; x++)
{
ResultSetRow row = rows[x];
// NamedValue[] columns = row.getColumns();
System.out.println("——————————-");
System.out.println("id node = "+row.getColumns(5).getName() + " – " + "Node value = "+ row.getColumns(5).getValue() );
}
}
}
%>
<%
AuthenticationUtils.startSession(USERNAME, PASSWORD);
try
{
// Make sure smaple data has been created
// Execute the search sample
executeSearch();
}
catch(RemoteException e1){
}
catch(Exception e){
}
finally
{
// End the session
AuthenticationUtils.endSession();
}
%>
</body>
</html>
11-19-2009 05:20 AM
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import= "d2b.simpleClient.SearchService_v2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<br/>
<h1>Risultato della Ricerca: </h1>
<%
SearchService_v2 scdq = new SearchService_v2();
out.println(scdq.ciao());
%>
</body>
</html>
GRAVE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 20 in the jsp file: /principale.jsp
SearchService_v2 cannot be resolved to a type
17:
18: <%
19:
20: SearchService_v2 scdq = new SearchService_v2();
21:
22: out.println(scdq.ciao());
23: %>
An error occurred at line: 20 in the jsp file: /principale.jsp
SearchService_v2 cannot be resolved to a type
17:
18: <%
19:
20: SearchService_v2 scdq = new SearchService_v2();
21:
22: out.println(scdq.ciao());
23: %>
Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
11-19-2009 11:39 PM
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.