1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.repository;
17
18 import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
19 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
20 import org.kuali.ole.docstore.model.xmlpojo.ingest.Response;
21 import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler;
22 import org.kuali.ole.logger.DocStoreLogger;
23 import org.kuali.ole.pojo.OleException;
24 import org.springframework.beans.factory.annotation.Required;
25
26 import javax.jcr.RepositoryException;
27
28 import java.io.File;
29 import java.io.FileNotFoundException;
30 import java.io.IOException;
31
32
33
34
35
36
37
38
39
40
41 public class DocumentStoreManager {
42 DocStoreLogger docStoreLogger = new DocStoreLogger(this.getClass().getName());
43
44
45
46 private CheckinManager checkinManager;
47
48
49
50 private CheckoutManager checkoutManager;
51
52
53
54 private DeleteManager deleteManager;
55
56
57
58 private RequestHandler requestHandler;
59
60 @Required
61 public void setCheckinManager(CheckinManager checkinManager) {
62 this.checkinManager = checkinManager;
63 }
64
65 @Required
66 public void setCheckoutManager(CheckoutManager checkoutManager) {
67 this.checkoutManager = checkoutManager;
68 }
69
70 @Required
71 public void setDeleteManager(DeleteManager deleteManager) {
72 this.deleteManager = deleteManager;
73 }
74
75 @Required
76 public void setRequestHandler(RequestHandler requestHandler) {
77 this.requestHandler = requestHandler;
78 }
79
80 public Response processDeleteRequest(String requestString) throws Exception {
81 Response response = null;
82 Request request = requestHandler.toObject(requestString);
83 response = deleteManager.deleteDocs(request);
84 return response;
85
86 }
87
88 public String checkOut(String uuid, String userId, String action) {
89 try {
90 return checkoutManager.checkOut(uuid, userId, action);
91 } catch (OleException e) {
92 docStoreLogger.log(e.getMessage());
93 return "Error in checking out the file. Please refer to the logs for more details!";
94 } catch (RepositoryException e) {
95 docStoreLogger.log(e.getMessage());
96 return "Error in checking out the file. Please refer to the logs for more details!";
97 } catch (FileNotFoundException e) {
98 docStoreLogger.log(e.getMessage());
99 return "Error in checking out the file. Please refer to the logs for more details!";
100 }
101 }
102
103
104 public String updateRecord(RequestDocument updateContent) throws OleException {
105 return checkinManager.updateContent(updateContent);
106 }
107
108 public File checkOutMultiPart(Request request) throws Exception {
109 return checkoutManager.checkOutMultiPart(request);
110 }
111
112 public void addReference(String uuidFile1, String uuidFile2, String userId, String action) {
113 }
114
115
116
117
118
119
120
121
122 public String checkOutBinary(String uuid, String userId, String action, String docFormat) throws IOException {
123 try {
124 return checkoutManager.checkOutBinary(uuid, userId, action, docFormat);
125 } catch (OleException e) {
126 docStoreLogger.log(e.getMessage());
127 return "Error in checking out the file. Please refer to the logs for more details!";
128 } catch (RepositoryException e) {
129 docStoreLogger.log(e.getMessage());
130 return "Error in checking out the file. Please refer to the logs for more details!";
131 } catch (FileNotFoundException e) {
132 docStoreLogger.log(e.getMessage());
133 return "Error in checking out the file. Please refer to the logs for more details!";
134 }
135 }
136 }