03-23-2007 03:55 PM
03-23-2007 06:03 PM
public class Test {
/**
* Store for all spaces
*/
private final static Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
private final static String username = "admin";
private final static String password = "admin";
public static void main(String[] args) {
new Test();
}
public Test() {
String path = "/";
String file = "Alfresco-Tutorial.pdf";
String where = "/app:company_home";
String xPathFile = where + path + "cm:" + file;
String mimetype = "application/pdf";
try {
// Authentication
AuthenticationUtils.startSession(username, password);
// Clean
if (exists(xPathFile)) {
delete(xPathFile);
}
// Upload
InputStream is = new FileInputStream(Test.class.getResource(path + file).getPath());
Reference contentRef = createContent(where, file);
ContentFormat format = new ContentFormat(mimetype, "UTF-8");
setContent(contentRef, format, is);
// Search for phrase "Alfresco Logo" which exists in Alfresco-Tutorial.pdf
String statement =
"TYPE:\"{http://www.alfresco.org/model/content/1.0}content\""
+ " AND (@\\{http\\://www.alfresco.org/model/content/1.0\\}name:\'Alfresco Logo\""
+ " TEXT:\"Alfresco Logo\"))";
// Search
Query query = new Query(Constants.QUERY_LANG_LUCENE, statement);
QueryResult results = WebServiceFactory.getRepositoryService().query(STORE, query, true);
System.out.println("File found: " + results.getResultSet().getTotalRowCount());
} catch (Exception e) {
e.printStackTrace();
} finally {
AuthenticationUtils.endSession();
}
}
}
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.