You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConfigurationRegistryWriter.java 52KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. package org.apache.archiva.configuration.provider.io.registry;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.components.registry.Registry;
  20. import org.apache.archiva.configuration.model.AbstractRepositoryConfiguration;
  21. import org.apache.archiva.configuration.model.AbstractRepositoryConnectorConfiguration;
  22. import org.apache.archiva.configuration.model.ArchivaDefaultConfiguration;
  23. import org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration;
  24. import org.apache.archiva.configuration.model.CacheConfiguration;
  25. import org.apache.archiva.configuration.model.Configuration;
  26. import org.apache.archiva.configuration.model.FileLockConfiguration;
  27. import org.apache.archiva.configuration.model.FileType;
  28. import org.apache.archiva.configuration.model.LdapConfiguration;
  29. import org.apache.archiva.configuration.model.LdapGroupMapping;
  30. import org.apache.archiva.configuration.model.LegacyArtifactPath;
  31. import org.apache.archiva.configuration.model.ManagedRepositoryConfiguration;
  32. import org.apache.archiva.configuration.model.NetworkConfiguration;
  33. import org.apache.archiva.configuration.model.NetworkProxyConfiguration;
  34. import org.apache.archiva.configuration.model.OrganisationInformation;
  35. import org.apache.archiva.configuration.model.ProxyConnectorConfiguration;
  36. import org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration;
  37. import org.apache.archiva.configuration.model.RedbackRuntimeConfiguration;
  38. import org.apache.archiva.configuration.model.RemoteRepositoryConfiguration;
  39. import org.apache.archiva.configuration.model.RepositoryCheckPath;
  40. import org.apache.archiva.configuration.model.RepositoryGroupConfiguration;
  41. import org.apache.archiva.configuration.model.RepositoryScanningConfiguration;
  42. import org.apache.archiva.configuration.model.SyncConnectorConfiguration;
  43. import org.apache.archiva.configuration.model.UserInterfaceOptions;
  44. import org.apache.archiva.configuration.model.WebappConfiguration;
  45. import java.util.Iterator;
  46. import java.util.List;
  47. // Util imports
  48. // Model class imports
  49. /**
  50. * Generate Plexus Registry output mechanism for model 'Configuration'.
  51. */
  52. public class ConfigurationRegistryWriter {
  53. public void write( Configuration model, Registry registry) {
  54. writeConfiguration("", model, registry);
  55. }
  56. private void writeList(Registry registry, List<String> subList, String subsetPath, String elementName) {
  57. if (subList != null && subList.size() > 0
  58. ) {
  59. registry.removeSubset(subsetPath);
  60. int count = 0;
  61. for (Iterator<String> iter = subList.iterator(); iter.hasNext(); count++) {
  62. String name = subsetPath + "." + elementName + "(" + count + ")";
  63. String value = iter.next();
  64. registry.setString(name, value);
  65. }
  66. }
  67. }
  68. private void writeConfiguration(String prefix, Configuration value, Registry registry) {
  69. if (value != null) {
  70. if (value.getVersion() != null
  71. ) {
  72. String version = "version";
  73. registry.setString(prefix + version, value.getVersion());
  74. }
  75. if (value.getMetadataStore() != null && !value.getMetadataStore().equals("jcr")
  76. ) {
  77. String metadataStore = "metadataStore";
  78. registry.setString(prefix + metadataStore, value.getMetadataStore());
  79. }
  80. if (value.getRepositoryGroups() != null && value.getRepositoryGroups().size() > 0
  81. ) {
  82. registry.removeSubset(prefix + "repositoryGroups");
  83. int count = 0;
  84. for (Iterator iter = value.getRepositoryGroups().iterator(); iter.hasNext(); count++) {
  85. String name = "repositoryGroups.repositoryGroup(" + count + ")";
  86. RepositoryGroupConfiguration o = (RepositoryGroupConfiguration) iter.next();
  87. writeRepositoryGroupConfiguration(prefix + name + ".", o, registry);
  88. }
  89. }
  90. if (value.getManagedRepositories() != null && value.getManagedRepositories().size() > 0
  91. ) {
  92. registry.removeSubset(prefix + "managedRepositories");
  93. int count = 0;
  94. for (Iterator iter = value.getManagedRepositories().iterator(); iter.hasNext(); count++) {
  95. String name = "managedRepositories.managedRepository(" + count + ")";
  96. ManagedRepositoryConfiguration o = (ManagedRepositoryConfiguration) iter.next();
  97. writeManagedRepositoryConfiguration(prefix + name + ".", o, registry);
  98. }
  99. }
  100. if (value.getRemoteRepositories() != null && value.getRemoteRepositories().size() > 0
  101. ) {
  102. registry.removeSubset(prefix + "remoteRepositories");
  103. int count = 0;
  104. for (Iterator iter = value.getRemoteRepositories().iterator(); iter.hasNext(); count++) {
  105. String name = "remoteRepositories.remoteRepository(" + count + ")";
  106. RemoteRepositoryConfiguration o = (RemoteRepositoryConfiguration) iter.next();
  107. writeRemoteRepositoryConfiguration(prefix + name + ".", o, registry);
  108. }
  109. }
  110. if (value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
  111. ) {
  112. registry.removeSubset(prefix + "proxyConnectors");
  113. int count = 0;
  114. for (Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++) {
  115. String name = "proxyConnectors.proxyConnector(" + count + ")";
  116. ProxyConnectorConfiguration o = (ProxyConnectorConfiguration) iter.next();
  117. writeProxyConnectorConfiguration(prefix + name + ".", o, registry);
  118. }
  119. }
  120. if (value.getNetworkProxies() != null && value.getNetworkProxies().size() > 0
  121. ) {
  122. registry.removeSubset(prefix + "networkProxies");
  123. int count = 0;
  124. for (Iterator iter = value.getNetworkProxies().iterator(); iter.hasNext(); count++) {
  125. String name = "networkProxies.networkProxy(" + count + ")";
  126. NetworkProxyConfiguration o = (NetworkProxyConfiguration) iter.next();
  127. writeNetworkProxyConfiguration(prefix + name + ".", o, registry);
  128. }
  129. }
  130. if (value.getLegacyArtifactPaths() != null && value.getLegacyArtifactPaths().size() > 0
  131. ) {
  132. registry.removeSubset(prefix + "legacyArtifactPaths");
  133. int count = 0;
  134. for (Iterator iter = value.getLegacyArtifactPaths().iterator(); iter.hasNext(); count++) {
  135. String name = "legacyArtifactPaths.legacyArtifactPath(" + count + ")";
  136. LegacyArtifactPath o = (LegacyArtifactPath) iter.next();
  137. writeLegacyArtifactPath(prefix + name + ".", o, registry);
  138. }
  139. }
  140. if (value.getRepositoryScanning() != null
  141. ) {
  142. writeRepositoryScanningConfiguration(prefix + "repositoryScanning.", value.getRepositoryScanning(), registry);
  143. }
  144. if (value.getWebapp() != null
  145. ) {
  146. writeWebappConfiguration(prefix + "webapp.", value.getWebapp(), registry);
  147. }
  148. if (value.getOrganisationInfo() != null
  149. ) {
  150. writeOrganisationInformation(prefix + "organisationInfo.", value.getOrganisationInfo(), registry);
  151. }
  152. if (value.getNetworkConfiguration() != null
  153. ) {
  154. writeNetworkConfiguration(prefix + "networkConfiguration.", value.getNetworkConfiguration(), registry);
  155. }
  156. if (value.getRedbackRuntimeConfiguration() != null
  157. ) {
  158. writeRedbackRuntimeConfiguration(prefix + "redbackRuntimeConfiguration.", value.getRedbackRuntimeConfiguration(), registry);
  159. }
  160. if (value.getArchivaRuntimeConfiguration() != null
  161. ) {
  162. writeArchivaRuntimeConfiguration(prefix + "archivaRuntimeConfiguration.", value.getArchivaRuntimeConfiguration(), registry);
  163. }
  164. if (value.getProxyConnectorRuleConfigurations() != null && value.getProxyConnectorRuleConfigurations().size() > 0
  165. ) {
  166. registry.removeSubset(prefix + "proxyConnectorRuleConfigurations");
  167. int count = 0;
  168. for (Iterator iter = value.getProxyConnectorRuleConfigurations().iterator(); iter.hasNext(); count++) {
  169. String name = "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration(" + count + ")";
  170. ProxyConnectorRuleConfiguration o = (ProxyConnectorRuleConfiguration) iter.next();
  171. writeProxyConnectorRuleConfiguration(prefix + name + ".", o, registry);
  172. }
  173. }
  174. if (value.getArchivaDefaultConfiguration() != null
  175. ) {
  176. writeArchivaDefaultConfiguration(prefix + "archivaDefaultConfiguration.", value.getArchivaDefaultConfiguration(), registry);
  177. }
  178. }
  179. }
  180. private void writeAbstractRepositoryConfiguration( String prefix, AbstractRepositoryConfiguration value, Registry registry) {
  181. if (value != null) {
  182. if (value.getId() != null
  183. ) {
  184. String id = "id";
  185. registry.setString(prefix + id, value.getId());
  186. }
  187. if (value.getType() != null && !value.getType().equals("MAVEN")
  188. ) {
  189. String type = "type";
  190. registry.setString(prefix + type, value.getType());
  191. }
  192. if (value.getName() != null
  193. ) {
  194. String name = "name";
  195. registry.setString(prefix + name, value.getName());
  196. }
  197. if (value.getLayout() != null && !value.getLayout().equals("default")
  198. ) {
  199. String layout = "layout";
  200. registry.setString(prefix + layout, value.getLayout());
  201. }
  202. if (value.getIndexDir() != null && !value.getIndexDir().equals("")
  203. ) {
  204. String indexDir = "indexDir";
  205. registry.setString(prefix + indexDir, value.getIndexDir());
  206. }
  207. if (value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals("")
  208. ) {
  209. String packedIndexDir = "packedIndexDir";
  210. registry.setString(prefix + packedIndexDir, value.getPackedIndexDir());
  211. }
  212. if (value.getDescription() != null && !value.getDescription().equals("")
  213. ) {
  214. String description = "description";
  215. registry.setString(prefix + description, value.getDescription());
  216. }
  217. }
  218. }
  219. private void writeRemoteRepositoryConfiguration(String prefix, RemoteRepositoryConfiguration value, Registry registry) {
  220. if (value != null) {
  221. if (value.getUrl() != null
  222. ) {
  223. String url = "url";
  224. registry.setString(prefix + url, value.getUrl());
  225. }
  226. if (value.getUsername() != null
  227. ) {
  228. String username = "username";
  229. registry.setString(prefix + username, value.getUsername());
  230. }
  231. if (value.getPassword() != null
  232. ) {
  233. String password = "password";
  234. registry.setString(prefix + password, value.getPassword());
  235. }
  236. if (value.getTimeout() != 60
  237. ) {
  238. String timeout = "timeout";
  239. registry.setInt(prefix + timeout, value.getTimeout());
  240. }
  241. if (value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals("0 0 08 ? * SUN")
  242. ) {
  243. String refreshCronExpression = "refreshCronExpression";
  244. registry.setString(prefix + refreshCronExpression, value.getRefreshCronExpression());
  245. }
  246. String downloadRemoteIndex = "downloadRemoteIndex";
  247. registry.setBoolean(prefix + downloadRemoteIndex, value.isDownloadRemoteIndex());
  248. if (value.getRemoteIndexUrl() != null
  249. ) {
  250. String remoteIndexUrl = "remoteIndexUrl";
  251. registry.setString(prefix + remoteIndexUrl, value.getRemoteIndexUrl());
  252. }
  253. if (value.getRemoteDownloadNetworkProxyId() != null
  254. ) {
  255. String remoteDownloadNetworkProxyId = "remoteDownloadNetworkProxyId";
  256. registry.setString(prefix + remoteDownloadNetworkProxyId, value.getRemoteDownloadNetworkProxyId());
  257. }
  258. if (value.getRemoteDownloadTimeout() != 300
  259. ) {
  260. String remoteDownloadTimeout = "remoteDownloadTimeout";
  261. registry.setInt(prefix + remoteDownloadTimeout, value.getRemoteDownloadTimeout());
  262. }
  263. String downloadRemoteIndexOnStartup = "downloadRemoteIndexOnStartup";
  264. registry.setBoolean(prefix + downloadRemoteIndexOnStartup, value.isDownloadRemoteIndexOnStartup());
  265. if (value.getExtraParameters() != null && value.getExtraParameters().size() > 0
  266. ) {
  267. registry.removeSubset(prefix + "extraParameters");
  268. for (Iterator iter = value.getExtraParameters().keySet().iterator(); iter.hasNext(); ) {
  269. String key = (String) iter.next();
  270. String v = (String) value.getExtraParameters().get(key);
  271. registry.setString(prefix + "extraParameters." + key, v);
  272. }
  273. }
  274. if (value.getExtraHeaders() != null && value.getExtraHeaders().size() > 0
  275. ) {
  276. registry.removeSubset(prefix + "extraHeaders");
  277. for (Iterator iter = value.getExtraHeaders().keySet().iterator(); iter.hasNext(); ) {
  278. String key = (String) iter.next();
  279. String v = (String) value.getExtraHeaders().get(key);
  280. registry.setString(prefix + "extraHeaders." + key, v);
  281. }
  282. }
  283. if (value.getCheckPath() != null
  284. ) {
  285. String checkPath = "checkPath";
  286. registry.setString(prefix + checkPath, value.getCheckPath());
  287. }
  288. if (value.getId() != null
  289. ) {
  290. String id = "id";
  291. registry.setString(prefix + id, value.getId());
  292. }
  293. if (value.getType() != null && !value.getType().equals("MAVEN")
  294. ) {
  295. String type = "type";
  296. registry.setString(prefix + type, value.getType());
  297. }
  298. if (value.getName() != null
  299. ) {
  300. String name = "name";
  301. registry.setString(prefix + name, value.getName());
  302. }
  303. if (value.getLayout() != null && !value.getLayout().equals("default")
  304. ) {
  305. String layout = "layout";
  306. registry.setString(prefix + layout, value.getLayout());
  307. }
  308. if (value.getIndexDir() != null && !value.getIndexDir().equals("")
  309. ) {
  310. String indexDir = "indexDir";
  311. registry.setString(prefix + indexDir, value.getIndexDir());
  312. }
  313. if (value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals("")
  314. ) {
  315. String packedIndexDir = "packedIndexDir";
  316. registry.setString(prefix + packedIndexDir, value.getPackedIndexDir());
  317. }
  318. if (value.getDescription() != null && !value.getDescription().equals("")
  319. ) {
  320. String description = "description";
  321. registry.setString(prefix + description, value.getDescription());
  322. }
  323. }
  324. }
  325. private void writeManagedRepositoryConfiguration(String prefix, ManagedRepositoryConfiguration value, Registry registry) {
  326. if (value != null) {
  327. if (value.getLocation() != null
  328. ) {
  329. String location = "location";
  330. registry.setString(prefix + location, value.getLocation());
  331. }
  332. String releases = "releases";
  333. registry.setBoolean(prefix + releases, value.isReleases());
  334. String blockRedeployments = "blockRedeployments";
  335. registry.setBoolean(prefix + blockRedeployments, value.isBlockRedeployments());
  336. String snapshots = "snapshots";
  337. registry.setBoolean(prefix + snapshots, value.isSnapshots());
  338. String scanned = "scanned";
  339. registry.setBoolean(prefix + scanned, value.isScanned());
  340. if (value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals("0 0 * * * ?")
  341. ) {
  342. String refreshCronExpression = "refreshCronExpression";
  343. registry.setString(prefix + refreshCronExpression, value.getRefreshCronExpression());
  344. }
  345. if (value.getRetentionCount() != 2
  346. ) {
  347. String retentionCount = "retentionCount";
  348. registry.setInt(prefix + retentionCount, value.getRetentionCount());
  349. }
  350. if (value.getRetentionPeriod() != 100
  351. ) {
  352. String retentionPeriod = "retentionPeriod";
  353. registry.setInt(prefix + retentionPeriod, value.getRetentionPeriod());
  354. }
  355. String deleteReleasedSnapshots = "deleteReleasedSnapshots";
  356. registry.setBoolean(prefix + deleteReleasedSnapshots, value.isDeleteReleasedSnapshots());
  357. String skipPackedIndexCreation = "skipPackedIndexCreation";
  358. registry.setBoolean(prefix + skipPackedIndexCreation, value.isSkipPackedIndexCreation());
  359. String stageRepoNeeded = "stageRepoNeeded";
  360. registry.setBoolean(prefix + stageRepoNeeded, value.isStageRepoNeeded());
  361. if (value.getId() != null
  362. ) {
  363. String id = "id";
  364. registry.setString(prefix + id, value.getId());
  365. }
  366. if (value.getType() != null && !value.getType().equals("MAVEN")
  367. ) {
  368. String type = "type";
  369. registry.setString(prefix + type, value.getType());
  370. }
  371. if (value.getName() != null
  372. ) {
  373. String name = "name";
  374. registry.setString(prefix + name, value.getName());
  375. }
  376. if (value.getLayout() != null && !value.getLayout().equals("default")
  377. ) {
  378. String layout = "layout";
  379. registry.setString(prefix + layout, value.getLayout());
  380. }
  381. if (value.getIndexDir() != null && !value.getIndexDir().equals("")
  382. ) {
  383. String indexDir = "indexDir";
  384. registry.setString(prefix + indexDir, value.getIndexDir());
  385. }
  386. if (value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals("")
  387. ) {
  388. String packedIndexDir = "packedIndexDir";
  389. registry.setString(prefix + packedIndexDir, value.getPackedIndexDir());
  390. }
  391. if (value.getDescription() != null && !value.getDescription().equals("")
  392. ) {
  393. String description = "description";
  394. registry.setString(prefix + description, value.getDescription());
  395. }
  396. }
  397. }
  398. private void writeLegacyArtifactPath(String prefix, LegacyArtifactPath value, Registry registry) {
  399. if (value != null) {
  400. if (value.getPath() != null
  401. ) {
  402. String path = "path";
  403. registry.setString(prefix + path, value.getPath());
  404. }
  405. if (value.getArtifact() != null
  406. ) {
  407. String artifact = "artifact";
  408. registry.setString(prefix + artifact, value.getArtifact());
  409. }
  410. }
  411. }
  412. private void writeRepositoryGroupConfiguration(String prefix, RepositoryGroupConfiguration value, Registry registry) {
  413. if (value != null) {
  414. if (value.getId() != null
  415. ) {
  416. String id = "id";
  417. registry.setString(prefix + id, value.getId());
  418. }
  419. if (value.getName() != null) {
  420. registry.setString(prefix + "name", value.getName());
  421. }
  422. if (value.getType() != null) {
  423. registry.setString(prefix + "type", value.getType());
  424. }
  425. if (value.getLocation()!=null) {
  426. registry.setString( prefix+"location", value.getType( ) );
  427. }
  428. if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer")
  429. ) {
  430. String mergedIndexPath = "mergedIndexPath";
  431. registry.setString(prefix + mergedIndexPath, value.getMergedIndexPath());
  432. }
  433. if (value.getMergedIndexTtl() != 30
  434. ) {
  435. String mergedIndexTtl = "mergedIndexTtl";
  436. registry.setInt(prefix + mergedIndexTtl, value.getMergedIndexTtl());
  437. }
  438. if (value.getCronExpression() != null && !value.getCronExpression().equals("")
  439. ) {
  440. String cronExpression = "cronExpression";
  441. registry.setString(prefix + cronExpression, value.getCronExpression());
  442. }
  443. if (value.getRepositories() != null && value.getRepositories().size() > 0
  444. ) {
  445. registry.removeSubset(prefix + "repositories");
  446. int count = 0;
  447. for (Iterator iter = value.getRepositories().iterator(); iter.hasNext(); count++) {
  448. String name = "repositories.repository(" + count + ")";
  449. String repository = (String) iter.next();
  450. registry.setString(prefix + name, repository);
  451. }
  452. }
  453. }
  454. }
  455. private void writeRepositoryCheckPath( String prefix, RepositoryCheckPath value, Registry registry) {
  456. if (value != null) {
  457. if (value.getUrl() != null
  458. ) {
  459. String url = "url";
  460. registry.setString(prefix + url, value.getUrl());
  461. }
  462. if (value.getPath() != null
  463. ) {
  464. String path = "path";
  465. registry.setString(prefix + path, value.getPath());
  466. }
  467. }
  468. }
  469. private void writeAbstractRepositoryConnectorConfiguration( String prefix, AbstractRepositoryConnectorConfiguration value, Registry registry) {
  470. if (value != null) {
  471. if (value.getSourceRepoId() != null
  472. ) {
  473. String sourceRepoId = "sourceRepoId";
  474. registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
  475. }
  476. if (value.getTargetRepoId() != null
  477. ) {
  478. String targetRepoId = "targetRepoId";
  479. registry.setString(prefix + targetRepoId, value.getTargetRepoId());
  480. }
  481. if (value.getProxyId() != null
  482. ) {
  483. String proxyId = "proxyId";
  484. registry.setString(prefix + proxyId, value.getProxyId());
  485. }
  486. if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
  487. ) {
  488. registry.removeSubset(prefix + "blackListPatterns");
  489. int count = 0;
  490. for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
  491. String name = "blackListPatterns.blackListPattern(" + count + ")";
  492. String blackListPattern = (String) iter.next();
  493. registry.setString(prefix + name, blackListPattern);
  494. }
  495. }
  496. if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
  497. ) {
  498. registry.removeSubset(prefix + "whiteListPatterns");
  499. int count = 0;
  500. for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
  501. String name = "whiteListPatterns.whiteListPattern(" + count + ")";
  502. String whiteListPattern = (String) iter.next();
  503. registry.setString(prefix + name, whiteListPattern);
  504. }
  505. }
  506. if (value.getPolicies() != null && value.getPolicies().size() > 0
  507. ) {
  508. registry.removeSubset(prefix + "policies");
  509. for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
  510. String key = (String) iter.next();
  511. String v = (String) value.getPolicies().get(key);
  512. registry.setString(prefix + "policies." + key, v);
  513. }
  514. }
  515. if (value.getProperties() != null && value.getProperties().size() > 0
  516. ) {
  517. registry.removeSubset(prefix + "properties");
  518. for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
  519. String key = (String) iter.next();
  520. String v = (String) value.getProperties().get(key);
  521. registry.setString(prefix + "properties." + key, v);
  522. }
  523. }
  524. String disabled = "disabled";
  525. registry.setBoolean(prefix + disabled, value.isDisabled());
  526. }
  527. }
  528. private void writeProxyConnectorRuleConfiguration(String prefix, ProxyConnectorRuleConfiguration value, Registry registry) {
  529. if (value != null) {
  530. if (value.getRuleType() != null
  531. ) {
  532. String ruleType = "ruleType";
  533. registry.setString(prefix + ruleType, value.getRuleType());
  534. }
  535. if (value.getPattern() != null
  536. ) {
  537. String pattern = "pattern";
  538. registry.setString(prefix + pattern, value.getPattern());
  539. }
  540. if (value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
  541. ) {
  542. registry.removeSubset(prefix + "proxyConnectors");
  543. int count = 0;
  544. for (Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++) {
  545. String name = "proxyConnectors.proxyConnector(" + count + ")";
  546. ProxyConnectorConfiguration o = (ProxyConnectorConfiguration) iter.next();
  547. writeProxyConnectorConfiguration(prefix + name + ".", o, registry);
  548. }
  549. }
  550. }
  551. }
  552. private void writeProxyConnectorConfiguration(String prefix, ProxyConnectorConfiguration value, Registry registry) {
  553. if (value != null) {
  554. if (value.getOrder() != 0
  555. ) {
  556. String order = "order";
  557. registry.setInt(prefix + order, value.getOrder());
  558. }
  559. if (value.getSourceRepoId() != null
  560. ) {
  561. String sourceRepoId = "sourceRepoId";
  562. registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
  563. }
  564. if (value.getTargetRepoId() != null
  565. ) {
  566. String targetRepoId = "targetRepoId";
  567. registry.setString(prefix + targetRepoId, value.getTargetRepoId());
  568. }
  569. if (value.getProxyId() != null
  570. ) {
  571. String proxyId = "proxyId";
  572. registry.setString(prefix + proxyId, value.getProxyId());
  573. }
  574. if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
  575. ) {
  576. registry.removeSubset(prefix + "blackListPatterns");
  577. int count = 0;
  578. for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
  579. String name = "blackListPatterns.blackListPattern(" + count + ")";
  580. String blackListPattern = (String) iter.next();
  581. registry.setString(prefix + name, blackListPattern);
  582. }
  583. }
  584. if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
  585. ) {
  586. registry.removeSubset(prefix + "whiteListPatterns");
  587. int count = 0;
  588. for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
  589. String name = "whiteListPatterns.whiteListPattern(" + count + ")";
  590. String whiteListPattern = (String) iter.next();
  591. registry.setString(prefix + name, whiteListPattern);
  592. }
  593. }
  594. if (value.getPolicies() != null && value.getPolicies().size() > 0
  595. ) {
  596. registry.removeSubset(prefix + "policies");
  597. for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
  598. String key = (String) iter.next();
  599. String v = (String) value.getPolicies().get(key);
  600. registry.setString(prefix + "policies." + key, v);
  601. }
  602. }
  603. if (value.getProperties() != null && value.getProperties().size() > 0
  604. ) {
  605. registry.removeSubset(prefix + "properties");
  606. for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
  607. String key = (String) iter.next();
  608. String v = (String) value.getProperties().get(key);
  609. registry.setString(prefix + "properties." + key, v);
  610. }
  611. }
  612. String disabled = "disabled";
  613. registry.setBoolean(prefix + disabled, value.isDisabled());
  614. }
  615. }
  616. private void writeSyncConnectorConfiguration( String prefix, SyncConnectorConfiguration value, Registry registry) {
  617. if (value != null) {
  618. if (value.getCronExpression() != null && !value.getCronExpression().equals("0 0 * * * ?")
  619. ) {
  620. String cronExpression = "cronExpression";
  621. registry.setString(prefix + cronExpression, value.getCronExpression());
  622. }
  623. if (value.getMethod() != null && !value.getMethod().equals("rsync")
  624. ) {
  625. String method = "method";
  626. registry.setString(prefix + method, value.getMethod());
  627. }
  628. if (value.getSourceRepoId() != null
  629. ) {
  630. String sourceRepoId = "sourceRepoId";
  631. registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
  632. }
  633. if (value.getTargetRepoId() != null
  634. ) {
  635. String targetRepoId = "targetRepoId";
  636. registry.setString(prefix + targetRepoId, value.getTargetRepoId());
  637. }
  638. if (value.getProxyId() != null
  639. ) {
  640. String proxyId = "proxyId";
  641. registry.setString(prefix + proxyId, value.getProxyId());
  642. }
  643. if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
  644. ) {
  645. registry.removeSubset(prefix + "blackListPatterns");
  646. int count = 0;
  647. for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
  648. String name = "blackListPatterns.blackListPattern(" + count + ")";
  649. String blackListPattern = (String) iter.next();
  650. registry.setString(prefix + name, blackListPattern);
  651. }
  652. }
  653. if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
  654. ) {
  655. registry.removeSubset(prefix + "whiteListPatterns");
  656. int count = 0;
  657. for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
  658. String name = "whiteListPatterns.whiteListPattern(" + count + ")";
  659. String whiteListPattern = (String) iter.next();
  660. registry.setString(prefix + name, whiteListPattern);
  661. }
  662. }
  663. if (value.getPolicies() != null && value.getPolicies().size() > 0
  664. ) {
  665. registry.removeSubset(prefix + "policies");
  666. for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
  667. String key = (String) iter.next();
  668. String v = (String) value.getPolicies().get(key);
  669. registry.setString(prefix + "policies." + key, v);
  670. }
  671. }
  672. if (value.getProperties() != null && value.getProperties().size() > 0
  673. ) {
  674. registry.removeSubset(prefix + "properties");
  675. for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
  676. String key = (String) iter.next();
  677. String v = (String) value.getProperties().get(key);
  678. registry.setString(prefix + "properties." + key, v);
  679. }
  680. }
  681. String disabled = "disabled";
  682. registry.setBoolean(prefix + disabled, value.isDisabled());
  683. }
  684. }
  685. private void writeNetworkProxyConfiguration(String prefix, NetworkProxyConfiguration value, Registry registry) {
  686. if (value != null) {
  687. if (value.getId() != null
  688. ) {
  689. String id = "id";
  690. registry.setString(prefix + id, value.getId());
  691. }
  692. if (value.getProtocol() != null && !value.getProtocol().equals("http")
  693. ) {
  694. String protocol = "protocol";
  695. registry.setString(prefix + protocol, value.getProtocol());
  696. }
  697. if (value.getHost() != null
  698. ) {
  699. String host = "host";
  700. registry.setString(prefix + host, value.getHost());
  701. }
  702. if (value.getPort() != 8080
  703. ) {
  704. String port = "port";
  705. registry.setInt(prefix + port, value.getPort());
  706. }
  707. if (value.getUsername() != null
  708. ) {
  709. String username = "username";
  710. registry.setString(prefix + username, value.getUsername());
  711. }
  712. if (value.getPassword() != null
  713. ) {
  714. String password = "password";
  715. registry.setString(prefix + password, value.getPassword());
  716. }
  717. String useNtlm = "useNtlm";
  718. registry.setBoolean(prefix + useNtlm, value.isUseNtlm());
  719. }
  720. }
  721. private void writeRepositoryScanningConfiguration( String prefix, RepositoryScanningConfiguration value, Registry registry) {
  722. if (value != null) {
  723. if (value.getFileTypes() != null && value.getFileTypes().size() > 0
  724. ) {
  725. registry.removeSubset(prefix + "fileTypes");
  726. int count = 0;
  727. for (Iterator iter = value.getFileTypes().iterator(); iter.hasNext(); count++) {
  728. String name = "fileTypes.fileType(" + count + ")";
  729. FileType o = (FileType) iter.next();
  730. writeFileType(prefix + name + ".", o, registry);
  731. }
  732. }
  733. if (value.getKnownContentConsumers() != null && value.getKnownContentConsumers().size() > 0
  734. ) {
  735. registry.removeSubset(prefix + "knownContentConsumers");
  736. int count = 0;
  737. for (Iterator iter = value.getKnownContentConsumers().iterator(); iter.hasNext(); count++) {
  738. String name = "knownContentConsumers.knownContentConsumer(" + count + ")";
  739. String knownContentConsumer = (String) iter.next();
  740. registry.setString(prefix + name, knownContentConsumer);
  741. }
  742. }
  743. if (value.getInvalidContentConsumers() != null && value.getInvalidContentConsumers().size() > 0
  744. ) {
  745. registry.removeSubset(prefix + "invalidContentConsumers");
  746. int count = 0;
  747. for (Iterator iter = value.getInvalidContentConsumers().iterator(); iter.hasNext(); count++) {
  748. String name = "invalidContentConsumers.invalidContentConsumer(" + count + ")";
  749. String invalidContentConsumer = (String) iter.next();
  750. registry.setString(prefix + name, invalidContentConsumer);
  751. }
  752. }
  753. }
  754. }
  755. private void writeFileType(String prefix, FileType value, Registry registry) {
  756. if (value != null) {
  757. if (value.getId() != null
  758. ) {
  759. String id = "id";
  760. registry.setString(prefix + id, value.getId());
  761. }
  762. if (value.getPatterns() != null && value.getPatterns().size() > 0
  763. ) {
  764. registry.removeSubset(prefix + "patterns");
  765. int count = 0;
  766. for (Iterator iter = value.getPatterns().iterator(); iter.hasNext(); count++) {
  767. String name = "patterns.pattern(" + count + ")";
  768. String pattern = (String) iter.next();
  769. registry.setString(prefix + name, pattern);
  770. }
  771. }
  772. }
  773. }
  774. private void writeOrganisationInformation( String prefix, OrganisationInformation value, Registry registry) {
  775. if (value != null) {
  776. if (value.getName() != null
  777. ) {
  778. String name = "name";
  779. registry.setString(prefix + name, value.getName());
  780. }
  781. if (value.getUrl() != null
  782. ) {
  783. String url = "url";
  784. registry.setString(prefix + url, value.getUrl());
  785. }
  786. if (value.getLogoLocation() != null
  787. ) {
  788. String logoLocation = "logoLocation";
  789. registry.setString(prefix + logoLocation, value.getLogoLocation());
  790. }
  791. }
  792. }
  793. private void writeWebappConfiguration( String prefix, WebappConfiguration value, Registry registry) {
  794. if (value != null) {
  795. if (value.getUi() != null
  796. ) {
  797. writeUserInterfaceOptions(prefix + "ui.", value.getUi(), registry);
  798. }
  799. }
  800. }
  801. private void writeUserInterfaceOptions( String prefix, UserInterfaceOptions value, Registry registry) {
  802. if (value != null) {
  803. String showFindArtifacts = "showFindArtifacts";
  804. registry.setBoolean(prefix + showFindArtifacts, value.isShowFindArtifacts());
  805. String appletFindEnabled = "appletFindEnabled";
  806. registry.setBoolean(prefix + appletFindEnabled, value.isAppletFindEnabled());
  807. String disableEasterEggs = "disableEasterEggs";
  808. registry.setBoolean(prefix + disableEasterEggs, value.isDisableEasterEggs());
  809. if (value.getApplicationUrl() != null
  810. ) {
  811. String applicationUrl = "applicationUrl";
  812. registry.setString(prefix + applicationUrl, value.getApplicationUrl());
  813. }
  814. String disableRegistration = "disableRegistration";
  815. registry.setBoolean(prefix + disableRegistration, value.isDisableRegistration());
  816. }
  817. }
  818. private void writeNetworkConfiguration( String prefix, NetworkConfiguration value, Registry registry) {
  819. if (value != null) {
  820. if (value.getMaxTotal() != 30
  821. ) {
  822. String maxTotal = "maxTotal";
  823. registry.setInt(prefix + maxTotal, value.getMaxTotal());
  824. }
  825. if (value.getMaxTotalPerHost() != 30
  826. ) {
  827. String maxTotalPerHost = "maxTotalPerHost";
  828. registry.setInt(prefix + maxTotalPerHost, value.getMaxTotalPerHost());
  829. }
  830. String usePooling = "usePooling";
  831. registry.setBoolean(prefix + usePooling, value.isUsePooling());
  832. }
  833. }
  834. private void writeArchivaRuntimeConfiguration( String prefix, ArchivaRuntimeConfiguration value, Registry registry) {
  835. if (value != null) {
  836. if (value.getUrlFailureCacheConfiguration() != null
  837. ) {
  838. writeCacheConfiguration(prefix + "urlFailureCacheConfiguration.", value.getUrlFailureCacheConfiguration(), registry);
  839. }
  840. if (value.getFileLockConfiguration() != null
  841. ) {
  842. writeFileLockConfiguration(prefix + "fileLockConfiguration.", value.getFileLockConfiguration(), registry);
  843. }
  844. if (value.getDataDirectory() != null
  845. ) {
  846. String dataDirectory = "dataDirectory";
  847. registry.setString(prefix + dataDirectory, value.getDataDirectory());
  848. }
  849. if (value.getRepositoryBaseDirectory() != null
  850. ) {
  851. String repositoryBaseDirectory = "repositoryBaseDirectory";
  852. registry.setString(prefix + repositoryBaseDirectory, value.getRepositoryBaseDirectory());
  853. }
  854. if (value.getRemoteRepositoryBaseDirectory() != null
  855. ) {
  856. String remoteRepositoryBaseDirectory = "remoteRepositoryBaseDirectory";
  857. registry.setString(prefix + remoteRepositoryBaseDirectory, value.getRemoteRepositoryBaseDirectory());
  858. }
  859. if (value.getRepositoryGroupBaseDirectory() != null
  860. ) {
  861. String repositoryGroupBaseDirectory = "repositoryGroupBaseDirectory";
  862. registry.setString(prefix + repositoryGroupBaseDirectory, value.getRepositoryGroupBaseDirectory());
  863. }
  864. if (value.getDefaultLanguage() != null && !value.getDefaultLanguage().equals("en-US")
  865. ) {
  866. String defaultLanguage = "defaultLanguage";
  867. registry.setString(prefix + defaultLanguage, value.getDefaultLanguage());
  868. }
  869. if (value.getLanguageRange() != null && !value.getLanguageRange().equals("en,fr,de")
  870. ) {
  871. String languageRange = "languageRange";
  872. registry.setString(prefix + languageRange, value.getLanguageRange());
  873. }
  874. writeList(registry, value.getChecksumTypes(), prefix+"checksumTypes", "type");
  875. }
  876. }
  877. private void writeRedbackRuntimeConfiguration( String prefix, RedbackRuntimeConfiguration value, Registry registry) {
  878. if (value != null) {
  879. String migratedFromRedbackConfiguration = "migratedFromRedbackConfiguration";
  880. registry.setBoolean(prefix + migratedFromRedbackConfiguration, value.isMigratedFromRedbackConfiguration());
  881. if (value.getUserManagerImpls() != null && value.getUserManagerImpls().size() > 0
  882. ) {
  883. registry.removeSubset(prefix + "userManagerImpls");
  884. int count = 0;
  885. for (Iterator iter = value.getUserManagerImpls().iterator(); iter.hasNext(); count++) {
  886. String name = "userManagerImpls.userManagerImpl(" + count + ")";
  887. String userManagerImpl = (String) iter.next();
  888. registry.setString(prefix + name, userManagerImpl);
  889. }
  890. }
  891. if (value.getRbacManagerImpls() != null && value.getRbacManagerImpls().size() > 0
  892. ) {
  893. registry.removeSubset(prefix + "rbacManagerImpls");
  894. int count = 0;
  895. for (Iterator iter = value.getRbacManagerImpls().iterator(); iter.hasNext(); count++) {
  896. String name = "rbacManagerImpls.rbacManagerImpl(" + count + ")";
  897. String rbacManagerImpl = (String) iter.next();
  898. registry.setString(prefix + name, rbacManagerImpl);
  899. }
  900. }
  901. if (value.getLdapConfiguration() != null
  902. ) {
  903. writeLdapConfiguration(prefix + "ldapConfiguration.", value.getLdapConfiguration(), registry);
  904. }
  905. if (value.getLdapGroupMappings() != null && value.getLdapGroupMappings().size() > 0
  906. ) {
  907. registry.removeSubset(prefix + "ldapGroupMappings");
  908. int count = 0;
  909. for (Iterator iter = value.getLdapGroupMappings().iterator(); iter.hasNext(); count++) {
  910. String name = "ldapGroupMappings.ldapGroupMapping(" + count + ")";
  911. LdapGroupMapping o = (LdapGroupMapping) iter.next();
  912. writeLdapGroupMapping(prefix + name + ".", o, registry);
  913. }
  914. }
  915. if (value.getConfigurationProperties() != null && value.getConfigurationProperties().size() > 0
  916. ) {
  917. registry.removeSubset(prefix + "configurationProperties");
  918. for (Iterator iter = value.getConfigurationProperties().keySet().iterator(); iter.hasNext(); ) {
  919. String key = (String) iter.next();
  920. String v = (String) value.getConfigurationProperties().get(key);
  921. registry.setString(prefix + "configurationProperties." + key, v);
  922. }
  923. }
  924. String useUsersCache = "useUsersCache";
  925. registry.setBoolean(prefix + useUsersCache, value.isUseUsersCache());
  926. if (value.getUsersCacheConfiguration() != null
  927. ) {
  928. writeCacheConfiguration(prefix + "usersCacheConfiguration.", value.getUsersCacheConfiguration(), registry);
  929. }
  930. }
  931. }
  932. private void writeArchivaDefaultConfiguration( String prefix, ArchivaDefaultConfiguration value, Registry registry) {
  933. if (value != null) {
  934. if (value.getDefaultCheckPaths() != null && value.getDefaultCheckPaths().size() > 0
  935. ) {
  936. registry.removeSubset(prefix + "defaultCheckPaths");
  937. int count = 0;
  938. for (Iterator iter = value.getDefaultCheckPaths().iterator(); iter.hasNext(); count++) {
  939. String name = "defaultCheckPaths.defaultCheckPath(" + count + ")";
  940. RepositoryCheckPath o = (RepositoryCheckPath) iter.next();
  941. writeRepositoryCheckPath(prefix + name + ".", o, registry);
  942. }
  943. }
  944. }
  945. }
  946. private void writeLdapConfiguration( String prefix, LdapConfiguration value, Registry registry) {
  947. if (value != null) {
  948. if (value.getHostName() != null
  949. ) {
  950. String hostName = "hostName";
  951. registry.setString(prefix + hostName, value.getHostName());
  952. }
  953. if (value.getPort() != 0
  954. ) {
  955. String port = "port";
  956. registry.setInt(prefix + port, value.getPort());
  957. }
  958. String ssl = "ssl";
  959. registry.setBoolean(prefix + ssl, value.isSsl());
  960. if (value.getBaseDn() != null
  961. ) {
  962. String baseDn = "baseDn";
  963. registry.setString(prefix + baseDn, value.getBaseDn());
  964. }
  965. if (value.getBaseGroupsDn() != null
  966. ) {
  967. String baseGroupsDn = "baseGroupsDn";
  968. registry.setString(prefix + baseGroupsDn, value.getBaseGroupsDn());
  969. }
  970. if (value.getContextFactory() != null
  971. ) {
  972. String contextFactory = "contextFactory";
  973. registry.setString(prefix + contextFactory, value.getContextFactory());
  974. }
  975. if (value.getBindDn() != null
  976. ) {
  977. String bindDn = "bindDn";
  978. registry.setString(prefix + bindDn, value.getBindDn());
  979. }
  980. if (value.getPassword() != null
  981. ) {
  982. String password = "password";
  983. registry.setString(prefix + password, value.getPassword());
  984. }
  985. if (value.getAuthenticationMethod() != null
  986. ) {
  987. String authenticationMethod = "authenticationMethod";
  988. registry.setString(prefix + authenticationMethod, value.getAuthenticationMethod());
  989. }
  990. String bindAuthenticatorEnabled = "bindAuthenticatorEnabled";
  991. registry.setBoolean(prefix + bindAuthenticatorEnabled, value.isBindAuthenticatorEnabled());
  992. String writable = "writable";
  993. registry.setBoolean(prefix + writable, value.isWritable());
  994. String useRoleNameAsGroup = "useRoleNameAsGroup";
  995. registry.setBoolean(prefix + useRoleNameAsGroup, value.isUseRoleNameAsGroup());
  996. if (value.getExtraProperties() != null && value.getExtraProperties().size() > 0
  997. ) {
  998. registry.removeSubset(prefix + "extraProperties");
  999. for (Iterator iter = value.getExtraProperties().keySet().iterator(); iter.hasNext(); ) {
  1000. String key = (String) iter.next();
  1001. String v = (String) value.getExtraProperties().get(key);
  1002. registry.setString(prefix + "extraProperties." + key, v);
  1003. }
  1004. }
  1005. }
  1006. }
  1007. private void writeFileLockConfiguration( String prefix, FileLockConfiguration value, Registry registry) {
  1008. if (value != null) {
  1009. String skipLocking = "skipLocking";
  1010. registry.setBoolean(prefix + skipLocking, value.isSkipLocking());
  1011. if (value.getLockingTimeout() != 0
  1012. ) {
  1013. String lockingTimeout = "lockingTimeout";
  1014. registry.setInt(prefix + lockingTimeout, value.getLockingTimeout());
  1015. }
  1016. }
  1017. }
  1018. private void writeCacheConfiguration( String prefix, CacheConfiguration value, Registry registry) {
  1019. if (value != null) {
  1020. if (value.getTimeToIdleSeconds() != -1
  1021. ) {
  1022. String timeToIdleSeconds = "timeToIdleSeconds";
  1023. registry.setInt(prefix + timeToIdleSeconds, value.getTimeToIdleSeconds());
  1024. }
  1025. if (value.getTimeToLiveSeconds() != -1
  1026. ) {
  1027. String timeToLiveSeconds = "timeToLiveSeconds";
  1028. registry.setInt(prefix + timeToLiveSeconds, value.getTimeToLiveSeconds());
  1029. }
  1030. if (value.getMaxElementsInMemory() != -1
  1031. ) {
  1032. String maxElementsInMemory = "maxElementsInMemory";
  1033. registry.setInt(prefix + maxElementsInMemory, value.getMaxElementsInMemory());
  1034. }
  1035. if (value.getMaxElementsOnDisk() != -1
  1036. ) {
  1037. String maxElementsOnDisk = "maxElementsOnDisk";
  1038. registry.setInt(prefix + maxElementsOnDisk, value.getMaxElementsOnDisk());
  1039. }
  1040. }
  1041. }
  1042. private void writeLdapGroupMapping(String prefix, LdapGroupMapping value, Registry registry) {
  1043. if (value != null) {
  1044. if (value.getGroup() != null
  1045. ) {
  1046. String group = "group";
  1047. registry.setString(prefix + group, value.getGroup());
  1048. }
  1049. if (value.getRoleNames() != null && value.getRoleNames().size() > 0
  1050. ) {
  1051. registry.removeSubset(prefix + "roleNames");
  1052. int count = 0;
  1053. for (Iterator iter = value.getRoleNames().iterator(); iter.hasNext(); count++) {
  1054. String name = "roleNames.roleName(" + count + ")";
  1055. String roleName = (String) iter.next();
  1056. registry.setString(prefix + name, roleName);
  1057. }
  1058. }
  1059. }
  1060. }
  1061. }