01-07-2015 09:33 PM
public String uploadDocument(File fileobj, List<PropertiesModel> metaData)
throws Exception {
String ticketURLResponse = getTicket();
String urlString = "http://" + inboundServerIp + ":"
+ inboundServerPort
+ "/alfresco/service/api/upload?alf_ticket="
+ ticketURLResponse;
HttpClient client = new HttpClient();
PostMethod mPost = new PostMethod(urlString);
BufferedReader br = null;
try {
Part[] parts = {
new FilePart("filedata", fileobj, "application/pdf", null),
new StringPart("filename", fileobj.getName()),
new StringPart("destination", "workspace://SpacesStore/"
+ folderUUID),
new StringPart("aspects",
"PolicyNumber:PolicyNumber,ReferenceNumber:ReferenceNumber") };
mPost.setRequestEntity(new MultipartRequestEntity(parts, mPost
.getParams()));
int statusCode1 = client.executeMethod(mPost);
if (statusCode1 != 200) {
throw new Exception("Error!" + mPost.getResponseBodyAsString());
} else {
br = new BufferedReader(new InputStreamReader(
mPost.getResponseBodyAsStream()));
String readLine;
while (((readLine = br.readLine()) != null)) {
if (readLine.contains("workspace://SpacesStore/")) {
break;
}
}
int startindex = readLine.indexOf("workspace://SpacesStore/")
+ "workspace://SpacesStore/".length();
int endindex = readLine.indexOf("workspace://SpacesStore/")
+ "workspace://SpacesStore/".length() + 36;
String uuid = readLine.substring(startindex, endindex);
return uuid;
}
} catch (Exception e) {
throw e;
} finally {
if (br != null) {
br.close();
}
mPost.releaseConnection();
}
}
01-17-2017 12:53 PM
how can you solve this issue?
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.