1 package com.trendmicro.grid.acl.ds.config;
2
3 import net.sf.tinyjee.config.*;
4 import net.sf.tinyjee.config.documentation.PropertyDocumentation;
5 import net.sf.tinyjee.config.documentation.SectionDocumentation;
6
7 import java.util.Collection;
8 import java.util.Collections;
9
10
11
12
13
14
15
16 @SectionDocumentation(
17 name = DataSourcePropertySection.NAME_SECTION,
18 description = "" +
19 "Defines the general settings to use for accessing the GRID infrastructure.\n" +
20 "\n" +
21 "The datasource modules inside the GRID define multiple internal interfaces " +
22 "that allow accessing the different backend systems used inside the GRID.\n" +
23 "\n" +
24 "Most interfaces are backed by several implementations allowing to run the " +
25 "access layer in various modes (including test setups with no external " +
26 "dependencies).\n" +
27 "\n" +
28 "The active implementations that are in use can be selected by editing the file " +
29 "'repository-selection.MODE.xml' and are also exposed to JMX monitoring.",
30 properties = {
31 @PropertyDocumentation(
32 property = DataSourcePropertySection.KEY_AUTOSELECT_NAMES,
33 description = "Specifies a whitespace delimited list of name fragments to use " +
34 "for selecting the initial configuration of repository implementations in case " +
35 "of the 'repository-selection.MODE.xml' file is missing completelly or missing " +
36 "a mapping entry.\n" +
37 "\n" +
38 "The property has no effect if a selection is already stored inside a selection " +
39 "XML file.\n" +
40 "\n" +
41 "By default the value for the property can be specified using the commandline " +
42 "parameter '\"-Dautoselect.ds.implementations=name01 name02 name03\"'."
43 ),
44 @PropertyDocumentation(
45 property = DataSourcePropertySection.KEY_CREATE_VENDOR_IF_MISSING,
46 description = "Defines whether to auto-create vendors implicitly if missing " +
47 "inside the CoreDB for incoming processing results."
48 ),
49 @PropertyDocumentation(
50 property = DataSourcePropertySection.KEY_CREATE_PACKAGE_FAMILY_IF_MISSING,
51 description = "Defines whether to auto-create package family entries implicitly if missing " +
52 "inside the CoreDB for incoming processing results."
53 ),
54 @PropertyDocumentation(
55 property = DataSourcePropertySection.KEY_CREATE_SOURCE_IF_MISSING,
56 description = "Defines whether to auto-create source entries implicitly if missing " +
57 "inside the CoreDB for incoming processing results."
58 ),
59 @PropertyDocumentation(
60 property = DataSourcePropertySection.KEY_UPDATE_TIMESTAMPS_WHEN_CONTENT_IS_SAME,
61 description = "Updates timestamps on LAST_PROCESSED and LAST_RETRIEVED even if " +
62 "the processing didn't change the result."
63 ),
64 @PropertyDocumentation(
65 property = DataSourcePropertySection.KEY_UPDATE_SOURCES_FROM_PROCESS_RESULT,
66 description = "Defines whether to apply changes to sources " +
67 "from incoming processing results. \n" +
68 "If 'false' (default), sources have to be updated using " +
69 "the dedicated SOAP interfaces."
70 ),
71 @PropertyDocumentation(
72 property = DataSourcePropertySection.KEY_UPDATE_VENDOR_FROM_PROCESS_RESULT,
73 description = "Defines whether to apply changes to vendors " +
74 "from incoming processing results. \n" +
75 "If 'false' (default), vendors have to be updated using " +
76 "the dedicated SOAP interfaces."
77 ),
78 @PropertyDocumentation(
79 property = DataSourcePropertySection.KEY_UPDATE_PACKAGE_FAMILY_FROM_PROCESS_RESULT,
80 description = "Defines whether to apply changes to package family entries " +
81 "from incoming processing results. \n" +
82 "If 'false' (default), package families have to be updated using " +
83 "the dedicated SOAP interfaces."
84 ),
85 @PropertyDocumentation(
86 property = DataSourcePropertySection.KEY_IGNORE_ALL_UPDATES,
87 description = "Ignores all updates to any data. (default and recommended: false).\n" +
88 "When set to 'true', data can just be added but it can never be updated. " +
89 "History records are never created either.\n" +
90 "Use this option with care! (e.g. to speed-up bulk data inserts)"
91 ),
92 @PropertyDocumentation(
93 property = DataSourcePropertySection.KEY_IGNORE_NULL_METADATA_UPDATES,
94 description = "Ignores updates to metadata fields if the received metadata " +
95 "is set to 'null' (default: true).\n" +
96 "Effectively this setting ensures that existing metadata is not overriden " +
97 "with empty metadata."
98 )
99 }
100 )
101 public class DataSourcePropertySection extends PropertySection implements ConfigurationBuilder {
102
103 private static final long serialVersionUID = -4111897772847377832L;
104
105 public static final String NAME_SECTION = "gacl-datasource";
106
107 public static final String KEY_AUTOSELECT_NAMES = "autoselectNames";
108 public static final String KEY_AUTOSELECT_IMPLEMENTATION_BY_NAMES = "autoselectImplementationsByNames";
109
110 public static final String KEY_CREATE_VENDOR_IF_MISSING = "createVendorIfMissing";
111 public static final String KEY_CREATE_PACKAGE_FAMILY_IF_MISSING = "createPackageFamilyIfMissing";
112 public static final String KEY_CREATE_SOURCE_IF_MISSING = "createSourceIfMissing";
113 public static final String KEY_IGNORE_NULL_METADATA_UPDATES = "ignoreNullMetadataUpdates";
114 public static final String KEY_IGNORE_ALL_UPDATES = "ignoreAllUpdates";
115 public static final String KEY_UPDATE_TIMESTAMPS_WHEN_CONTENT_IS_SAME = "updatedTimestampsWhenContentIsSame";
116 public static final String KEY_UPDATE_SOURCES_FROM_PROCESS_RESULT = "updateSourcesFromProcessResult";
117 public static final String KEY_UPDATE_VENDOR_FROM_PROCESS_RESULT = "updateVendorFromProcessResult";
118 public static final String KEY_UPDATE_PACKAGE_FAMILY_FROM_PROCESS_RESULT = "updatePackageFamilyFromProcessResult";
119 public static final String KEY_ENABLE_HISTORY_RECORDING = "enableHistoryRecording";
120 public static final String KEY_IGNORE_STATISTICS_RECORDING = "ignoreStatisticsRecording";
121
122 public static PropertySection getPropertySection() {
123 Configuration config = ConfigurationContext.getInstance().getConfiguration();
124 PropertySection section = config.getPropertySection(NAME_SECTION);
125 return section == null ? new DataSourcePropertySection() : section;
126 }
127
128 {
129 setSection(NAME_SECTION);
130
131 String cifs = "(not empty cifsserver ? ' CIFS' : '')";
132 String msmq = "(not empty msmqbridgehost ? ' MSMQ' : '')";
133 addProperty(KEY_AUTOSELECT_NAMES, "dummy trivial logging jpa caching");
134 addProperty(KEY_AUTOSELECT_IMPLEMENTATION_BY_NAMES, String.format(
135 "${notNull(env('autoselect.ds.implementations'), concat(%s, concat(%s, %s)))}",
136 KEY_AUTOSELECT_NAMES, cifs, msmq));
137
138 addProperty(KEY_CREATE_VENDOR_IF_MISSING, Boolean.TRUE.toString());
139 addProperty(KEY_CREATE_PACKAGE_FAMILY_IF_MISSING, Boolean.TRUE.toString());
140 addProperty(KEY_CREATE_SOURCE_IF_MISSING, Boolean.TRUE.toString());
141
142 addProperty(KEY_UPDATE_TIMESTAMPS_WHEN_CONTENT_IS_SAME, Boolean.FALSE.toString());
143 addProperty(KEY_UPDATE_SOURCES_FROM_PROCESS_RESULT, Boolean.FALSE.toString());
144 addProperty(KEY_UPDATE_VENDOR_FROM_PROCESS_RESULT, Boolean.FALSE.toString());
145 addProperty(KEY_UPDATE_PACKAGE_FAMILY_FROM_PROCESS_RESULT, Boolean.FALSE.toString());
146
147 addProperty(KEY_IGNORE_ALL_UPDATES, Boolean.FALSE.toString());
148
149 addProperty(KEY_IGNORE_NULL_METADATA_UPDATES, Boolean.TRUE.toString());
150
151 addProperty(KEY_ENABLE_HISTORY_RECORDING, Boolean.TRUE.toString());
152
153 addProperty(KEY_IGNORE_STATISTICS_RECORDING, Boolean.FALSE.toString());
154 }
155
156
157
158
159 @Override
160 public Collection<PropertySection> buildDefaultSections() {
161 return Collections.singleton((PropertySection) new DataSourcePropertySection());
162 }
163
164
165
166
167 @Override
168 public Collection<? extends Resource> buildDefaultResources() {
169 return Collections.emptyList();
170 }
171 }
172