1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.model.xmlpojo.metadata;
17
18 import org.apache.commons.io.IOUtils;
19 import org.kuali.ole.docstore.model.xstream.metadata.DocStoreMetaDataXmlProcessor;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 import com.thoughtworks.xstream.annotations.XStreamAlias;
24 import com.thoughtworks.xstream.annotations.XStreamImplicit;
25
26 import java.util.List;
27
28
29
30
31
32
33
34 @XStreamAlias("documentsMetaData")
35 public class DocumentsMetaData {
36
37 public static Logger logger = LoggerFactory.getLogger(DocumentsMetaData.class);
38 public static DocumentsMetaData docStoreMetaData = null;
39
40 @XStreamImplicit
41 @XStreamAlias("documentMetaData")
42 private List<DocumentMetaData> documentsMetaData = null;
43
44 public List<DocumentMetaData> getDocumentsMetaData() {
45 return documentsMetaData;
46 }
47
48 public void setDocumentsMetaData(List<DocumentMetaData> documentsMetaData) {
49 this.documentsMetaData = documentsMetaData;
50 }
51
52 public DocumentMetaData getDocumentMetaData(String category, String type, String format) {
53 if (documentsMetaData != null && documentsMetaData.size() > 0)
54 for (DocumentMetaData docMetaData : documentsMetaData)
55 if (docMetaData.getCategory().equals(category) && docMetaData.getType().equals(type) && docMetaData.getFormat().equals(format))
56 return docMetaData;
57 return null;
58 }
59
60 public static DocumentsMetaData getInstance() {
61 if (docStoreMetaData == null) {
62 try {
63 DocStoreMetaDataXmlProcessor parser = new DocStoreMetaDataXmlProcessor();
64 String xml = IOUtils.toString(DocumentsMetaData.class.getResourceAsStream("/org/kuali/ole/docstore/documentsMetaData.xml"));
65 docStoreMetaData = parser.fromXml(xml);
66 logger.info("Loaded Doc Store Meta Data Successfully.");
67 } catch (Exception e) {
68 logger.error("Failed in Loading Doc Store Meta Data : Cause : " + e.getMessage(), e);
69 }
70 }
71 return docStoreMetaData;
72 }
73
74 }