-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUploader.java
87 lines (71 loc) · 3.1 KB
/
Uploader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package oracle.hr.server.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;
public class Uploader implements IUploadFile {
public Uploader() {
super();
}
public int record(String url,
String user,
String pass,
String sourceFileFQP,
String contentType,
String dDocTitle,
String dDocAuthor,
String dSecurityGroup,
String dDocAccount,
String dDocName) {
InputStream is = null;
IdcClient idcClient;
IdcClientManager m_clientManager;
IdcContext userContext;
try {
String fileName = sourceFileFQP.substring(sourceFileFQP.lastIndexOf('/') + 1);
is = new FileInputStream(sourceFileFQP);
m_clientManager = new IdcClientManager();
idcClient = m_clientManager.createClient(url);
userContext = new IdcContext(user, pass);
long fileLength = new File(sourceFileFQP).length();
TransferFile primaryFile = new TransferFile();
primaryFile.setInputStream(is);
primaryFile.setContentType(contentType);
primaryFile.setFileName(fileName);
primaryFile.setContentLength(fileLength);
DataBinder request = idcClient.createBinder();
request.putLocal("IdcService", "CHECKIN_UNIVERSAL");
request.addFile("primaryFile", primaryFile);
request.putLocal("dDocTitle", dDocTitle);
request.putLocal("dDocAuthor", dDocAuthor);
request.putLocal("dDocType", contentType);
request.putLocal("dSecurityGroup", dSecurityGroup);
request.putLocal("dDocAccount", dDocAccount == null ? "" : dDocAccount);
if (dDocName != null && dDocName.trim().length() > 0) {
request.putLocal("dDocName", dDocName);
}
ServiceResponse response = idcClient.sendRequest(userContext, request);
DataBinder responseBinder = response.getResponseAsBinder();
System.out.println (responseBinder.toString());
} catch (IOException | IdcClientException e) {
e.printStackTrace(System.out);
return 1;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ignore) {
System.out.println(ignore.toString());
}
}
}
return 0;
}
}