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 }
92 catch (OleException e) {
93 docStoreLogger.log(e.getMessage());
94 return "Error in checking out the file. Please refer to the logs for more details!";
95 }
96 catch (RepositoryException e) {
97 docStoreLogger.log(e.getMessage());
98 return "Error in checking out the file. Please refer to the logs for more details!";
99 }
100 catch (FileNotFoundException e) {
101 docStoreLogger.log(e.getMessage());
102 return "Error in checking out the file. Please refer to the logs for more details!";
103 }
104 }
105
106
107 public String updateRecord(RequestDocument updateContent) throws OleException {
108 return checkinManager.updateContent(updateContent);
109 }
110
111 public File checkOutMultiPart(Request request) throws Exception {
112 return checkoutManager.checkOutMultiPart(request);
113 }
114
115 public void addReference(String uuidFile1, String uuidFile2, String userId, String action) {
116 }
117
118
119
120
121
122
123
124
125 public String checkOutBinary(String uuid, String userId, String action, String docFormat) throws IOException {
126 try {
127 return checkoutManager.checkOutBinary(uuid, userId, action, docFormat);
128 }
129
130 catch (OleException e) {
131 docStoreLogger.log(e.getMessage());
132 return "Error in checking out the file. Please refer to the logs for more details!";
133 }
134 catch (RepositoryException e) {
135 docStoreLogger.log(e.getMessage());
136 return "Error in checking out the file. Please refer to the logs for more details!";
137 }
138 catch (FileNotFoundException e) {
139 docStoreLogger.log(e.getMessage());
140 return "Error in checking out the file. Please refer to the logs for more details!";
141 }
142 }
143 }