Space or Content Properties modification
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2012 12:24 PM
Hi,
I would like to modify the space properties or space properties via Alfresco Web Services API. Please help provide with sample code how to modify.
Thanks
Benson
I would like to modify the space properties or space properties via Alfresco Web Services API. Please help provide with sample code how to modify.
Thanks
Benson
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2012 11:02 AM
Go to http://ecmarchitect.com/alfresco-developer-series and read the custom content types tutorial.
The example modifies content objects but it works the same for spaces.
Jeff
The example modifies content objects but it works the same for spaces.
Jeff
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2012 03:59 AM
Thanks Jeff. Do you know how I can display the tree structure of a space? Is there any sample code?
Please help
Thanks
Benson
Please help
Thanks
Benson
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2012 10:02 AM
If you download the OpenCMIS Workbench from Apache Chemistry and fire it up, you can open and run the Print Descendants Tree example in the Groovy Console. The code prints a tree of all descendants, but you could add a check to test whether or not the content type of each child is a folder if you are looking for spaces only.
If you've never run the workbench or worked with CMIS before, assuming you are on Alfresco 4, the service URL for the ATOM Pub binding is http://localhost:8080/alfresco/cmisatom. If you are on older versions of Alfresco, the URL is http://localhost:8080/alfresco/s/api/cmis.
Hope that helps,
Jeff
import org.apache.chemistry.opencmis.client.api.*session.rootFolder.getDescendants(-1).each { printTree(it, 0)}def printTree(Tree tree, int depth) { for(i in 0..depth) { print " " } println tree.item.name if(tree.children.size > 0) { tree.children.each { printTree(it, depth + 1) } }}
If you've never run the workbench or worked with CMIS before, assuming you are on Alfresco 4, the service URL for the ATOM Pub binding is http://localhost:8080/alfresco/cmisatom. If you are on older versions of Alfresco, the URL is http://localhost:8080/alfresco/s/api/cmis.
Hope that helps,
Jeff
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2012 10:38 AM
Hi Jeff,
Thanks for your patience. However, I still don't get it unfortunately.
Actually, what I want to do is to make a statistics of the all the directory structure of each space.
For example,
Under Company Home folder, I have created a Patient Record folder. Under Patient Record folder, there are lots of different folders for every patient. As there is a lot of patient folder under Patient Record folder, I need to develop a program to generate a list of directory structure of each patient folder so that I can view what type of file are being stored in these folders. The following is the program to try to generate a list of directory structure, however, it can only return the number of folders under Patient Record folder, but cannot display every folder name.
Thank you very much
Benson
package test;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.ISO9075;
import org.alfresco.webservice.util.WebServiceFactory;
import org.apache.axis.utils.BeanPropertyDescriptor;
public class TestAlfresco {
/**
* @param args
*/
public static final Store STORE = new Store(Constants.WORKSPACE_STORE,
"SpacesStore");
public static String getNodeUUID(String rootPath, String folderName) {
String uuid = "";
try {
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/"
+ rootPath + "/" + "cm:" + ISO9075.encode(folderName)
+ "/*\" AND TYPE:\"cm:folder\"");
System.out.println(query.getStatement());
QueryResult queryResult = null;
queryResult = WebServiceFactory.getRepositoryService().query(STORE,
query, false);
ResultSet resultSet = queryResult.getResultSet();
System.out.println("No. of rows=" + resultSet.getTotalRowCount());
ResultSetRow[] rows = resultSet.getRows();
if (rows.length > 0) {
for(int j = 0 ; j < rows.length ; j++) {
System.out.println(" UUID ID :" + rows[j].getNode().getId());
uuid = rows[j].getNode().getId();
String[] strs = rows[j].getNode().getAspects();
System.out.println("type=" + rows[j].getNode().getType());
for(int i = 0 ; i < strs.length ; i++) {
System.out.println("strs=" + strs);
}
NamedValue[] nvs = rows[j].getColumns();
for(int i = 0 ; i < nvs.length ; i++) {
System.out.println(nvs.getName());
}
// resultSet = null;
// rows = null;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return uuid;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
FileOutputStream output = null;
// WebServiceFactory.setEndpointAddress("http://10.24.0.241:8080/alfresco/api");
WebServiceFactory.setEndpointAddress(args[0]);
try {
output = new FileOutputStream("exception.txt");
AuthenticationUtils.startSession("admin", "admin");
System.out.println("Session start");
String rootUUID = TestAlfresco.getNodeUUID("app:company_home",
args[1]);
System.out.println("rootUUID=" + rootUUID);
AuthenticationUtils.endSession();
System.out.println("End of session.");
} catch (Exception e) {
PrintStream ps = new PrintStream(output);
e.printStackTrace(ps);
ps.flush();
}
}
}
Thanks for your patience. However, I still don't get it unfortunately.
Actually, what I want to do is to make a statistics of the all the directory structure of each space.
For example,
Under Company Home folder, I have created a Patient Record folder. Under Patient Record folder, there are lots of different folders for every patient. As there is a lot of patient folder under Patient Record folder, I need to develop a program to generate a list of directory structure of each patient folder so that I can view what type of file are being stored in these folders. The following is the program to try to generate a list of directory structure, however, it can only return the number of folders under Patient Record folder, but cannot display every folder name.
Thank you very much
Benson
package test;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.ISO9075;
import org.alfresco.webservice.util.WebServiceFactory;
import org.apache.axis.utils.BeanPropertyDescriptor;
public class TestAlfresco {
/**
* @param args
*/
public static final Store STORE = new Store(Constants.WORKSPACE_STORE,
"SpacesStore");
public static String getNodeUUID(String rootPath, String folderName) {
String uuid = "";
try {
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/"
+ rootPath + "/" + "cm:" + ISO9075.encode(folderName)
+ "/*\" AND TYPE:\"cm:folder\"");
System.out.println(query.getStatement());
QueryResult queryResult = null;
queryResult = WebServiceFactory.getRepositoryService().query(STORE,
query, false);
ResultSet resultSet = queryResult.getResultSet();
System.out.println("No. of rows=" + resultSet.getTotalRowCount());
ResultSetRow[] rows = resultSet.getRows();
if (rows.length > 0) {
for(int j = 0 ; j < rows.length ; j++) {
System.out.println(" UUID ID :" + rows[j].getNode().getId());
uuid = rows[j].getNode().getId();
String[] strs = rows[j].getNode().getAspects();
System.out.println("type=" + rows[j].getNode().getType());
for(int i = 0 ; i < strs.length ; i++) {
System.out.println("strs=" + strs);
}
NamedValue[] nvs = rows[j].getColumns();
for(int i = 0 ; i < nvs.length ; i++) {
System.out.println(nvs.getName());
}
// resultSet = null;
// rows = null;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return uuid;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
FileOutputStream output = null;
// WebServiceFactory.setEndpointAddress("http://10.24.0.241:8080/alfresco/api");
WebServiceFactory.setEndpointAddress(args[0]);
try {
output = new FileOutputStream("exception.txt");
AuthenticationUtils.startSession("admin", "admin");
System.out.println("Session start");
String rootUUID = TestAlfresco.getNodeUUID("app:company_home",
args[1]);
System.out.println("rootUUID=" + rootUUID);
AuthenticationUtils.endSession();
System.out.println("End of session.");
} catch (Exception e) {
PrintStream ps = new PrintStream(output);
e.printStackTrace(ps);
ps.flush();
}
}
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2014 05:23 AM
Hi Jeff
Thank you for this code. Its working fine. But i am getting this folder tree on console. I want folder list like pop up. I want to delete specific version document. I have groovy script to delete specific version. But i want first i search a document in list means if i click on main folder,i will get all subfolders and documents and if i click speific document,i will get all versions of that document. So can you please help me how i will get folders and subfolders in list format.
Thank you
Thank you for this code. Its working fine. But i am getting this folder tree on console. I want folder list like pop up. I want to delete specific version document. I have groovy script to delete specific version. But i want first i search a document in list means if i click on main folder,i will get all subfolders and documents and if i click speific document,i will get all versions of that document. So can you please help me how i will get folders and subfolders in list format.
Thank you
