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 package fr.paris.lutece.plugins.document.service;
35
36 import fr.paris.lutece.plugins.document.business.DocumentType;
37 import fr.paris.lutece.plugins.document.business.DocumentTypeHome;
38 import fr.paris.lutece.util.xml.XmlUtil;
39
40
41
42
43
44
45 public class DocumentTypeService
46 {
47 private static final String TAG_DOCUMENT_TYPES = "document_types";
48 private static final String TAG_DOCUMENT_TYPE = "document_type";
49 private static final String TAG_DOCUMENT_TYPE_CODE = "code_document_type";
50 private static final String TAG_DOCUMENT_TYPE_NAME = "document_type_name";
51 private static final String TAG_DOCUMENT_TYPE_DESCRIPTION = "description";
52 private static final String TAG_DOCUMENT_TYPE_THUMBNAIL_ATTRIBUTE_ID = "thumbnail_attr_id";
53 private static final String TAG_DOCUMENT_TYPE_DEFAULT_THUMBNAIL_URL = "default_thumbnail_url";
54 private static final String TAG_DOCUMENT_TYPE_METADATA_HANDLER = "metadata_handler";
55
56
57 private static DocumentTypeServicee/DocumentTypeService.html#DocumentTypeService">DocumentTypeService _singleton = new DocumentTypeService( );
58
59
60 private DocumentTypeService( )
61 {
62 }
63
64
65
66
67
68 public static DocumentTypeService getInstance( )
69 {
70 return _singleton;
71 }
72
73
74
75
76
77 public String getXmlDocumentTypesList( )
78 {
79 StringBuffer sbXML = new StringBuffer( );
80 XmlUtil.beginElement( sbXML, TAG_DOCUMENT_TYPES );
81
82 for ( DocumentType type : DocumentTypeHome.findAll( ) )
83 {
84 findDocumentTypes( sbXML, type.getCode( ) );
85 }
86
87 XmlUtil.endElement( sbXML, TAG_DOCUMENT_TYPES );
88
89 return sbXML.toString( );
90 }
91
92
93
94
95
96
97
98 private void findDocumentTypes( StringBuffer sbXML, String strDocumentTypeCode )
99 {
100 DocumentType type = DocumentTypeHome.findByPrimaryKey( strDocumentTypeCode );
101
102 XmlUtil.beginElement( sbXML, TAG_DOCUMENT_TYPE );
103 XmlUtil.addElement( sbXML, TAG_DOCUMENT_TYPE_CODE, type.getCode( ) );
104 XmlUtil.addElement( sbXML, TAG_DOCUMENT_TYPE_NAME, type.getName( ) );
105 XmlUtil.addElement( sbXML, TAG_DOCUMENT_TYPE_DESCRIPTION, type.getDescription( ) );
106 XmlUtil.addElement( sbXML, TAG_DOCUMENT_TYPE_THUMBNAIL_ATTRIBUTE_ID, type.getThumbnailAttributeId( ) );
107 XmlUtil.addElement( sbXML, TAG_DOCUMENT_TYPE_DEFAULT_THUMBNAIL_URL, type.getDefaultThumbnailUrl( ) );
108 XmlUtil.addElement( sbXML, TAG_DOCUMENT_TYPE_METADATA_HANDLER, type.getMetadataHandler( ) );
109 XmlUtil.endElement( sbXML, TAG_DOCUMENT_TYPE );
110 }
111 }