12-01-2016 08:35 AM
Hi, Im Using alfresco community 5
my project config are : java 8,wildfly 8 ,
so will cmis will work on it, because i was trying since two days .i unable success on download any specific document . here follow some my code
String fileName = "abcd.docx";
String authURI = "http://127.0.0.1:8090/alfresco/service/api/login";
String username = "user1";
String password = "user1";
HttpUtils httpUtils = new HttpUtils();
String authTicket = ConstantsTemp.EMPTY;
try {
authTicket = httpUtils.getAuthTicket(authURI, username, password);
String url = "http://127.0.0.1:8090/alfresco/download/direct?path=/app:company_home/st:testuserone/cm:documentLibr..."
+ fileName + "?alf_ticket=" + authTicket;
System.out.println(url);
HttpClient client = new HttpClient();
GetMethod metodoGet = new GetMethod(url);
int status = client.executeMethod(metodoGet);
System.out.println(status);
byte[] file = metodoGet.getResponseBody();
metodoGet.releaseConnection();
} catch (Exception e) {
}
error :
500
Internal Server Error
Folder not found: /st:testuserone (in workspace://SpacesStore/329bbf25-9ebb-4f47-845c-ddb16dd15852)
commons-httpclient-3.1.jar
commons-io-2.4.jar
and let me know can possible to retrieve list of file(link to download) from any one directory(folder)
12-01-2016 08:47 PM
I believe your code will not work because of the url you are creating is not right.
Please, take a look at this one, which is the right one, generated by Share when you click the Download action:
http://localhost:8081/share/proxy/alfresco/slingshot/node/content/workspace/SpacesStore/60bcd2b9-73f...caca/Especifica%c3%a7%c3%a3o_T%c3%a9cnica_OS207.pdf?a=true
One idea is to try to find in Share's source code the part responsible for generating the url.
12-01-2016 10:46 PM
Thank you doug.
String url = "http://127.0.0.1:8090/share/proxy/alfresco/slingshot/node/content/workspace/SpacesStore/a22bb988-84e..."; eventhough its getting 401 Unauthorized ...
if that workspace contains same filename then how can i differentiate. like folder or directories
12-01-2016 09:57 PM
Why not use apache chemistry openCMIS library?
12-01-2016 10:35 PM
I was Tried that also it getting ContentServiceSoapBindingStub getContentService error ... please send the link example program for download
12-01-2016 11:54 PM
import org.apache.chemistry.opencmis.client.api.*
public Session getSession()
{
String serverUrl = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom";
String userName = "admin";
String password = "admin";
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> params = new HashMap<String, String>();
params.put(SessionParameter.USER, userName);
params.put(SessionParameter.PASSWORD, password);
params.put(SessionParameter.ATOMPUB_URL, serverUrl);
params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
params.put(SessionParameter.OBJECT_FACTORY_CLASS,
"org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
List<Repository> repos = sessionFactory.getRepositories(params);
if (repos.isEmpty()) {
throw new RuntimeException("Server has no repositories!");
}
return repos.get(0).createSession();
}
public void downloadCotent()
{
Session session = getSession();
try {
Document document = (Document)session.getObjectByPath( "/sites/testuserone/documentLibrary/Test") ;
InputStream stream = document.getContentStream().getStream();
....
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
12-02-2016 12:18 AM
Thank you but
it showing Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/chemistry/opencmis/client/api/TransientCmisObject exception
12-02-2016 12:36 AM
I used many jar
alfresco-web-service-client-4.2.d.jar
chemistry-opencmis-client-api-0.13.0.jar,
chemistry-opencmis-client-bindings-0.13.0.jar
chemistry-opencmis-client-impl-0.13.0.jar
chemistry-opencmis-commons-api-0.13.0.jar
chemistry-opencmis-commons-impl-0.14.0.jar
chemistry-opencmis-osgi-client-1.0.0.jar
commons-httpclient-3.1.jar,httpclient-4.2.jar
stax2-api.jar,woodstox-core-5.0.3.jar,wss4j-2.1.jar
12-02-2016 01:10 AM
I use maven ,opencmis version Release 1.0.0
You can download 1.0.0 here Apache Chemistry - OpenCMIS Downloads
12-02-2016 01:23 AM
thank you kz, i am using in normal java web project .i download chemistry-opencmis-osgi-client-1.0.0.jar from Apache Chemistry - OpenCMIS Downloads .
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.