This project has retired. For details please refer to its
Attic page.
DefaultArchivaRuntimeConfigurationService xref
1 package org.apache.archiva.rest.services;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.archiva.admin.model.RepositoryAdminException;
22 import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
23 import org.apache.archiva.admin.model.beans.CacheConfiguration;
24 import org.apache.archiva.admin.model.beans.FileLockConfiguration;
25 import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
26 import org.apache.archiva.common.filelock.FileLockManager;
27 import org.apache.archiva.redback.components.cache.Cache;
28 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
29 import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
30 import org.springframework.stereotype.Service;
31
32 import javax.inject.Inject;
33 import javax.inject.Named;
34
35
36
37
38
39 @Service( "archivaRuntimeConfigurationService#rest" )
40 public class DefaultArchivaRuntimeConfigurationService
41 extends AbstractRestService
42 implements ArchivaRuntimeConfigurationService
43 {
44 @Inject
45 private ArchivaRuntimeConfigurationAdmin archivaRuntimeConfigurationAdmin;
46
47 @Inject
48 @Named( value = "cache#url-failures-cache" )
49 private Cache usersCache;
50
51 @Inject
52 @Named( value = "fileLockManager#default" )
53 private FileLockManager fileLockManager;
54
55 @Override
56 public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
57 throws ArchivaRestServiceException
58 {
59 try
60 {
61 return archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration();
62 }
63 catch ( RepositoryAdminException e )
64 {
65 throw new ArchivaRestServiceException( e.getMessage(), e );
66 }
67 }
68
69 @Override
70 public Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
71 throws ArchivaRestServiceException
72 {
73 try
74 {
75 archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
76 CacheConfiguration cacheConfiguration = archivaRuntimeConfiguration.getUrlFailureCacheConfiguration();
77 if ( cacheConfiguration != null )
78 {
79 usersCache.setTimeToLiveSeconds( cacheConfiguration.getTimeToLiveSeconds() );
80 usersCache.setTimeToIdleSeconds( cacheConfiguration.getTimeToIdleSeconds() );
81 usersCache.setMaxElementsOnDisk( cacheConfiguration.getMaxElementsOnDisk() );
82 usersCache.setMaxElementsInMemory( cacheConfiguration.getMaxElementsInMemory() );
83 }
84
85 FileLockConfiguration fileLockConfiguration = archivaRuntimeConfiguration.getFileLockConfiguration();
86 if ( fileLockConfiguration != null )
87 {
88 fileLockManager.setTimeout( fileLockConfiguration.getLockingTimeout() );
89 fileLockManager.setSkipLocking( fileLockConfiguration.isSkipLocking() );
90 }
91
92
93 }
94 catch ( RepositoryAdminException e )
95 {
96 throw new ArchivaRestServiceException( e.getMessage(), e );
97 }
98 return Boolean.TRUE;
99 }
100 }