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.

DefaultRepositoriesService.java 47KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. package org.apache.archiva.rest.services;
  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. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.admin.model.RepositoryAdminException;
  21. import org.apache.archiva.admin.model.admin.ArchivaAdministration;
  22. import org.apache.archiva.checksum.ChecksumAlgorithm;
  23. import org.apache.archiva.checksum.ChecksummedFile;
  24. import org.apache.archiva.common.utils.VersionComparator;
  25. import org.apache.archiva.common.utils.VersionUtil;
  26. import org.apache.archiva.maven2.metadata.MavenMetadataReader;
  27. import org.apache.archiva.maven2.model.Artifact;
  28. import org.apache.archiva.metadata.model.ArtifactMetadata;
  29. import org.apache.archiva.metadata.model.facets.AuditEvent;
  30. import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet;
  31. import org.apache.archiva.metadata.repository.*;
  32. import org.apache.archiva.model.ArchivaRepositoryMetadata;
  33. import org.apache.archiva.model.ArtifactReference;
  34. import org.apache.archiva.model.VersionedReference;
  35. import org.apache.archiva.redback.authentication.AuthenticationResult;
  36. import org.apache.archiva.redback.authorization.AuthorizationException;
  37. import org.apache.archiva.redback.components.cache.Cache;
  38. import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
  39. import org.apache.archiva.redback.system.DefaultSecuritySession;
  40. import org.apache.archiva.redback.system.SecuritySession;
  41. import org.apache.archiva.redback.system.SecuritySystem;
  42. import org.apache.archiva.redback.users.User;
  43. import org.apache.archiva.redback.users.UserManagerException;
  44. import org.apache.archiva.redback.users.UserNotFoundException;
  45. import org.apache.archiva.repository.ContentNotFoundException;
  46. import org.apache.archiva.repository.ManagedRepository;
  47. import org.apache.archiva.repository.ManagedRepositoryContent;
  48. import org.apache.archiva.repository.RepositoryException;
  49. import org.apache.archiva.repository.RepositoryNotFoundException;
  50. import org.apache.archiva.repository.RepositoryRegistry;
  51. import org.apache.archiva.repository.storage.RepositoryStorage;
  52. import org.apache.archiva.repository.storage.StorageAsset;
  53. import org.apache.archiva.repository.storage.StorageUtil;
  54. import org.apache.archiva.metadata.audit.RepositoryListener;
  55. import org.apache.archiva.repository.metadata.base.MetadataTools;
  56. import org.apache.archiva.repository.metadata.RepositoryMetadataException;
  57. import org.apache.archiva.repository.metadata.base.RepositoryMetadataWriter;
  58. import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
  59. import org.apache.archiva.repository.scanner.RepositoryScanner;
  60. import org.apache.archiva.repository.scanner.RepositoryScannerException;
  61. import org.apache.archiva.repository.scanner.RepositoryScannerInstance;
  62. import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
  63. import org.apache.archiva.rest.api.model.StringList;
  64. import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
  65. import org.apache.archiva.rest.api.services.RepositoriesService;
  66. import org.apache.archiva.scheduler.ArchivaTaskScheduler;
  67. import org.apache.archiva.scheduler.indexing.maven.ArchivaIndexingTaskExecutor;
  68. import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
  69. import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexException;
  70. import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexScheduler;
  71. import org.apache.archiva.scheduler.repository.model.RepositoryTask;
  72. import org.apache.archiva.security.ArchivaSecurityException;
  73. import org.apache.archiva.security.common.ArchivaRoleConstants;
  74. import org.apache.archiva.xml.XMLException;
  75. import org.apache.commons.io.FilenameUtils;
  76. import org.apache.commons.lang3.StringUtils;
  77. import org.slf4j.Logger;
  78. import org.slf4j.LoggerFactory;
  79. import org.springframework.beans.factory.annotation.Autowired;
  80. import org.springframework.stereotype.Service;
  81. import javax.inject.Inject;
  82. import javax.inject.Named;
  83. import javax.ws.rs.core.Response;
  84. import java.io.IOException;
  85. import java.io.OutputStreamWriter;
  86. import java.nio.file.Path;
  87. import java.text.DateFormat;
  88. import java.text.SimpleDateFormat;
  89. import java.util.ArrayList;
  90. import java.util.Arrays;
  91. import java.util.Calendar;
  92. import java.util.Collection;
  93. import java.util.Collections;
  94. import java.util.Date;
  95. import java.util.List;
  96. import java.util.Set;
  97. import java.util.TimeZone;
  98. /**
  99. * @author Olivier Lamy
  100. * @since 1.4-M1
  101. */
  102. @Service("repositoriesService#rest")
  103. public class DefaultRepositoriesService
  104. extends AbstractRestService
  105. implements RepositoriesService
  106. {
  107. private Logger log = LoggerFactory.getLogger( getClass() );
  108. @Inject
  109. @Named(value = "taskExecutor#indexing")
  110. private ArchivaIndexingTaskExecutor archivaIndexingTaskExecutor;
  111. @Inject
  112. private RepositoryRegistry repositoryRegistry;
  113. @Inject
  114. private SecuritySystem securitySystem;
  115. @Inject
  116. @Named(value = "archivaTaskScheduler#repository")
  117. private ArchivaTaskScheduler<RepositoryTask> scheduler;
  118. @Inject
  119. private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
  120. @Inject
  121. @Named(value = "repositorySessionFactory")
  122. protected RepositorySessionFactory repositorySessionFactory;
  123. @Inject
  124. @Autowired(required = false)
  125. protected List<RepositoryListener> listeners = new ArrayList<RepositoryListener>();
  126. @Inject
  127. private RepositoryScanner repoScanner;
  128. /**
  129. * Cache used for namespaces
  130. */
  131. @Inject
  132. @Named(value = "cache#namespaces")
  133. private Cache<String, Collection<String>> namespacesCache;
  134. private List<ChecksumAlgorithm> algorithms = Arrays.asList(ChecksumAlgorithm.SHA256, ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 );
  135. @Override
  136. public Boolean scanRepository( String repositoryId, boolean fullScan )
  137. {
  138. return doScanRepository( repositoryId, fullScan );
  139. }
  140. @Override
  141. public Boolean alreadyScanning( String repositoryId )
  142. {
  143. // check queue first to make sure it doesn't get dequeued between calls
  144. if ( repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId ) )
  145. {
  146. return true;
  147. }
  148. for ( RepositoryScannerInstance scan : repoScanner.getInProgressScans() )
  149. {
  150. if ( scan.getRepository().getId().equals( repositoryId ) )
  151. {
  152. return true;
  153. }
  154. }
  155. return false;
  156. }
  157. @Override
  158. public Boolean removeScanningTaskFromQueue( String repositoryId )
  159. {
  160. RepositoryTask task = new RepositoryTask();
  161. task.setRepositoryId( repositoryId );
  162. try
  163. {
  164. return repositoryTaskScheduler.unQueueTask( task );
  165. }
  166. catch ( TaskQueueException e )
  167. {
  168. log.error( "failed to unschedule scanning of repo with id {}", repositoryId, e );
  169. return false;
  170. }
  171. }
  172. private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
  173. {
  174. org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
  175. if (repo==null) {
  176. throw new RepositoryException( "Repository not found "+id );
  177. }
  178. return repo.getContent();
  179. }
  180. @Override
  181. public Boolean scanRepositoryNow( String repositoryId, boolean fullScan )
  182. throws ArchivaRestServiceException
  183. {
  184. try
  185. {
  186. org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository( repositoryId );
  187. ArtifactIndexingTask task =
  188. new ArtifactIndexingTask( repository, null, ArtifactIndexingTask.Action.FINISH, repository.getIndexingContext() );
  189. task.setExecuteOnEntireRepo( true );
  190. task.setOnlyUpdate( !fullScan );
  191. archivaIndexingTaskExecutor.executeTask( task );
  192. scheduler.queueTask( new RepositoryTask( repositoryId, fullScan ) );
  193. return Boolean.TRUE;
  194. }
  195. catch ( Exception e )
  196. {
  197. log.error( e.getMessage(), e );
  198. throw new ArchivaRestServiceException( e.getMessage(), e );
  199. }
  200. }
  201. @Override
  202. public Boolean scheduleDownloadRemoteIndex( String repositoryId, boolean now, boolean fullDownload )
  203. throws ArchivaRestServiceException
  204. {
  205. try
  206. {
  207. downloadRemoteIndexScheduler.scheduleDownloadRemote( repositoryId, now, fullDownload );
  208. }
  209. catch ( DownloadRemoteIndexException e )
  210. {
  211. log.error( e.getMessage(), e );
  212. throw new ArchivaRestServiceException( e.getMessage(), e );
  213. }
  214. return Boolean.TRUE;
  215. }
  216. @Override
  217. public Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest )
  218. throws ArchivaRestServiceException
  219. {
  220. // check parameters
  221. String userName = getAuditInformation().getUser().getUsername();
  222. if ( StringUtils.isBlank( userName ) )
  223. {
  224. throw new ArchivaRestServiceException( "copyArtifact call: userName not found", null );
  225. }
  226. if ( StringUtils.isBlank( artifactTransferRequest.getRepositoryId() ) )
  227. {
  228. throw new ArchivaRestServiceException( "copyArtifact call: sourceRepositoryId cannot be null", null );
  229. }
  230. if ( StringUtils.isBlank( artifactTransferRequest.getTargetRepositoryId() ) )
  231. {
  232. throw new ArchivaRestServiceException( "copyArtifact call: targetRepositoryId cannot be null", null );
  233. }
  234. ManagedRepository source = null;
  235. source = repositoryRegistry.getManagedRepository( artifactTransferRequest.getRepositoryId() );
  236. if ( source == null )
  237. {
  238. throw new ArchivaRestServiceException(
  239. "cannot find repository with id " + artifactTransferRequest.getRepositoryId(), null );
  240. }
  241. ManagedRepository target = null;
  242. target = repositoryRegistry.getManagedRepository( artifactTransferRequest.getTargetRepositoryId() );
  243. if ( target == null )
  244. {
  245. throw new ArchivaRestServiceException(
  246. "cannot find repository with id " + artifactTransferRequest.getTargetRepositoryId(), null );
  247. }
  248. if ( StringUtils.isBlank( artifactTransferRequest.getGroupId() ) )
  249. {
  250. throw new ArchivaRestServiceException( "groupId is mandatory", null );
  251. }
  252. if ( StringUtils.isBlank( artifactTransferRequest.getArtifactId() ) )
  253. {
  254. throw new ArchivaRestServiceException( "artifactId is mandatory", null );
  255. }
  256. if ( StringUtils.isBlank( artifactTransferRequest.getVersion() ) )
  257. {
  258. throw new ArchivaRestServiceException( "version is mandatory", null );
  259. }
  260. if ( VersionUtil.isSnapshot( artifactTransferRequest.getVersion() ) )
  261. {
  262. throw new ArchivaRestServiceException( "copy of SNAPSHOT not supported", null );
  263. }
  264. // end check parameters
  265. User user = null;
  266. try
  267. {
  268. user = securitySystem.getUserManager().findUser( userName );
  269. }
  270. catch ( UserNotFoundException e )
  271. {
  272. throw new ArchivaRestServiceException( "user " + userName + " not found", e );
  273. }
  274. catch ( UserManagerException e )
  275. {
  276. throw new ArchivaRestServiceException( "ArchivaRestServiceException:" + e.getMessage(), e );
  277. }
  278. // check karma on source : read
  279. AuthenticationResult authn = new AuthenticationResult( true, userName, null );
  280. SecuritySession securitySession = new DefaultSecuritySession( authn, user );
  281. try
  282. {
  283. boolean authz =
  284. securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS,
  285. artifactTransferRequest.getRepositoryId() );
  286. if ( !authz )
  287. {
  288. throw new ArchivaRestServiceException(
  289. "not authorized to access repo:" + artifactTransferRequest.getRepositoryId(), null );
  290. }
  291. }
  292. catch ( AuthorizationException e )
  293. {
  294. log.error( "error reading permission: {}", e.getMessage(), e );
  295. throw new ArchivaRestServiceException( e.getMessage(), e );
  296. }
  297. // check karma on target: write
  298. try
  299. {
  300. boolean authz =
  301. securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD,
  302. artifactTransferRequest.getTargetRepositoryId() );
  303. if ( !authz )
  304. {
  305. throw new ArchivaRestServiceException(
  306. "not authorized to write to repo:" + artifactTransferRequest.getTargetRepositoryId(), null );
  307. }
  308. }
  309. catch ( AuthorizationException e )
  310. {
  311. log.error( "error reading permission: {}", e.getMessage(), e );
  312. throw new ArchivaRestServiceException( e.getMessage(), e );
  313. }
  314. // sounds good we can continue !
  315. ArtifactReference artifactReference = new ArtifactReference();
  316. artifactReference.setArtifactId( artifactTransferRequest.getArtifactId() );
  317. artifactReference.setGroupId( artifactTransferRequest.getGroupId() );
  318. artifactReference.setVersion( artifactTransferRequest.getVersion() );
  319. artifactReference.setClassifier( artifactTransferRequest.getClassifier() );
  320. String packaging = StringUtils.trim( artifactTransferRequest.getPackaging() );
  321. artifactReference.setType( StringUtils.isEmpty( packaging ) ? "jar" : packaging );
  322. try
  323. {
  324. ManagedRepositoryContent sourceRepository =
  325. getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
  326. String artifactSourcePath = sourceRepository.toPath( artifactReference );
  327. if ( StringUtils.isEmpty( artifactSourcePath ) )
  328. {
  329. log.error( "cannot find artifact {}", artifactTransferRequest );
  330. throw new ArchivaRestServiceException( "cannot find artifact " + artifactTransferRequest.toString(),
  331. null );
  332. }
  333. StorageAsset artifactFile = source.getAsset( artifactSourcePath );
  334. if ( !artifactFile.exists() )
  335. {
  336. log.error( "cannot find artifact {}", artifactTransferRequest );
  337. throw new ArchivaRestServiceException( "cannot find artifact " + artifactTransferRequest.toString(),
  338. null );
  339. }
  340. ManagedRepositoryContent targetRepository =
  341. getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );
  342. String artifactPath = targetRepository.toPath( artifactReference );
  343. int lastIndex = artifactPath.lastIndexOf( '/' );
  344. String path = artifactPath.substring( 0, lastIndex );
  345. StorageAsset targetDir = target.getAsset( path );
  346. Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
  347. int newBuildNumber = 1;
  348. String timestamp = null;
  349. StorageAsset versionMetadataFile = target.getAsset(path + "/" + MetadataTools.MAVEN_METADATA );
  350. /* unused */ getMetadata( versionMetadataFile );
  351. if ( !targetDir.exists() )
  352. {
  353. targetDir = target.addAsset(targetDir.getPath(), true);
  354. targetDir.create();
  355. }
  356. String filename = artifactPath.substring( lastIndex + 1 );
  357. boolean fixChecksums =
  358. !( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) );
  359. StorageAsset targetFile = target.getAsset(targetDir.getPath() + "/" + filename );
  360. if ( targetFile.exists() && target.blocksRedeployments())
  361. {
  362. throw new ArchivaRestServiceException(
  363. "artifact already exists in target repo: " + artifactTransferRequest.getTargetRepositoryId()
  364. + " and redeployment blocked", null
  365. );
  366. }
  367. else
  368. {
  369. copyFile(artifactFile, targetFile, fixChecksums );
  370. queueRepositoryTask( target.getId(), targetFile );
  371. }
  372. // copy source pom to target repo
  373. String pomFilename = filename;
  374. if ( StringUtils.isNotBlank( artifactTransferRequest.getClassifier() ) )
  375. {
  376. pomFilename = StringUtils.remove( pomFilename, "-" + artifactTransferRequest.getClassifier() );
  377. }
  378. pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom";
  379. StorageAsset pomFile = source.getAsset(
  380. artifactSourcePath.substring( 0, artifactPath.lastIndexOf( '/' ) )+"/"+ pomFilename );
  381. if ( pomFile != null && pomFile.exists() )
  382. {
  383. StorageAsset targetPomFile = target.getAsset( targetDir.getPath() + "/" + pomFilename );
  384. copyFile(pomFile, targetPomFile, fixChecksums );
  385. queueRepositoryTask( target.getId(), targetPomFile );
  386. }
  387. // explicitly update only if metadata-updater consumer is not enabled!
  388. if ( !archivaAdministration.getKnownContentConsumers().contains( "metadata-updater" ) )
  389. {
  390. updateProjectMetadata( target, targetDir, lastUpdatedTimestamp, timestamp, newBuildNumber,
  391. fixChecksums, artifactTransferRequest );
  392. }
  393. String msg =
  394. "Artifact \'" + artifactTransferRequest.getGroupId() + ":" + artifactTransferRequest.getArtifactId()
  395. + ":" + artifactTransferRequest.getVersion() + "\' was successfully deployed to repository \'"
  396. + artifactTransferRequest.getTargetRepositoryId() + "\'";
  397. log.debug("copyArtifact {}", msg);
  398. }
  399. catch ( RepositoryException e )
  400. {
  401. log.error( "RepositoryException: {}", e.getMessage(), e );
  402. throw new ArchivaRestServiceException( e.getMessage(), e );
  403. }
  404. catch ( RepositoryAdminException e )
  405. {
  406. log.error( "RepositoryAdminException: {}", e.getMessage(), e );
  407. throw new ArchivaRestServiceException( e.getMessage(), e );
  408. }
  409. catch ( IOException e )
  410. {
  411. log.error( "IOException: {}", e.getMessage(), e );
  412. throw new ArchivaRestServiceException( e.getMessage(), e );
  413. }
  414. return true;
  415. }
  416. private void queueRepositoryTask( String repositoryId, StorageAsset localFile )
  417. {
  418. RepositoryTask task = new RepositoryTask();
  419. task.setRepositoryId( repositoryId );
  420. task.setResourceFile( localFile );
  421. task.setUpdateRelatedArtifacts( true );
  422. //task.setScanAll( true );
  423. try
  424. {
  425. scheduler.queueTask( task );
  426. }
  427. catch ( TaskQueueException e )
  428. {
  429. log.error( "Unable to queue repository task to execute consumers on resource file ['{}"
  430. + "'].", localFile.getName());
  431. }
  432. }
  433. private ArchivaRepositoryMetadata getMetadata( StorageAsset metadataFile )
  434. throws RepositoryMetadataException
  435. {
  436. ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
  437. if ( metadataFile.exists() )
  438. {
  439. try
  440. {
  441. metadata = MavenMetadataReader.read( metadataFile.getFilePath() );
  442. }
  443. catch (XMLException e )
  444. {
  445. throw new RepositoryMetadataException( e.getMessage(), e );
  446. }
  447. }
  448. return metadata;
  449. }
  450. private StorageAsset getMetadata( RepositoryStorage storage, String targetPath )
  451. {
  452. return storage.getAsset( targetPath + "/" + MetadataTools.MAVEN_METADATA );
  453. }
  454. /*
  455. * Copies the asset to the new target.
  456. */
  457. private void copyFile(StorageAsset sourceFile, StorageAsset targetPath, boolean fixChecksums)
  458. throws IOException
  459. {
  460. StorageUtil.copyAsset( sourceFile, targetPath, true );
  461. if ( fixChecksums )
  462. {
  463. fixChecksums( targetPath );
  464. }
  465. }
  466. private void fixChecksums( StorageAsset file )
  467. {
  468. Path destinationFile = file.getFilePath();
  469. if (destinationFile!=null)
  470. {
  471. ChecksummedFile checksum = new ChecksummedFile( destinationFile );
  472. checksum.fixChecksums( algorithms );
  473. }
  474. }
  475. private void updateProjectMetadata( RepositoryStorage storage, StorageAsset targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber,
  476. boolean fixChecksums, ArtifactTransferRequest artifactTransferRequest )
  477. throws RepositoryMetadataException
  478. {
  479. List<String> availableVersions = new ArrayList<>();
  480. String latestVersion = artifactTransferRequest.getVersion();
  481. StorageAsset projectDir = targetPath.getParent();
  482. StorageAsset projectMetadataFile = storage.getAsset( projectDir.getPath()+"/"+MetadataTools.MAVEN_METADATA );
  483. ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetadataFile );
  484. if ( projectMetadataFile.exists() )
  485. {
  486. availableVersions = projectMetadata.getAvailableVersions();
  487. Collections.sort( availableVersions, VersionComparator.getInstance() );
  488. if ( !availableVersions.contains( artifactTransferRequest.getVersion() ) )
  489. {
  490. availableVersions.add( artifactTransferRequest.getVersion() );
  491. }
  492. latestVersion = availableVersions.get( availableVersions.size() - 1 );
  493. }
  494. else
  495. {
  496. availableVersions.add( artifactTransferRequest.getVersion() );
  497. projectMetadata.setGroupId( artifactTransferRequest.getGroupId() );
  498. projectMetadata.setArtifactId( artifactTransferRequest.getArtifactId() );
  499. }
  500. if ( projectMetadata.getGroupId() == null )
  501. {
  502. projectMetadata.setGroupId( artifactTransferRequest.getGroupId() );
  503. }
  504. if ( projectMetadata.getArtifactId() == null )
  505. {
  506. projectMetadata.setArtifactId( artifactTransferRequest.getArtifactId() );
  507. }
  508. projectMetadata.setLatestVersion( latestVersion );
  509. projectMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
  510. projectMetadata.setAvailableVersions( availableVersions );
  511. if ( !VersionUtil.isSnapshot( artifactTransferRequest.getVersion() ) )
  512. {
  513. projectMetadata.setReleasedVersion( latestVersion );
  514. }
  515. try(OutputStreamWriter writer = new OutputStreamWriter(projectMetadataFile.getWriteStream(true))) {
  516. RepositoryMetadataWriter.write(projectMetadata, writer);
  517. } catch (IOException e) {
  518. throw new RepositoryMetadataException(e);
  519. }
  520. if ( fixChecksums )
  521. {
  522. fixChecksums( projectMetadataFile );
  523. }
  524. }
  525. @Override
  526. public Boolean removeProjectVersion( String repositoryId, String namespace, String projectId, String version )
  527. throws ArchivaRestServiceException
  528. {
  529. // if not a generic we can use the standard way to delete artifact
  530. if ( !VersionUtil.isGenericSnapshot( version ) )
  531. {
  532. Artifact artifact = new Artifact( namespace, projectId, version );
  533. artifact.setRepositoryId( repositoryId );
  534. artifact.setContext( repositoryId );
  535. return deleteArtifact( artifact );
  536. }
  537. if ( StringUtils.isEmpty( repositoryId ) )
  538. {
  539. throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null );
  540. }
  541. if ( !isAuthorizedToDeleteArtifacts( repositoryId ) )
  542. {
  543. throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null );
  544. }
  545. if ( StringUtils.isEmpty( namespace ) )
  546. {
  547. throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
  548. }
  549. if ( StringUtils.isEmpty( projectId ) )
  550. {
  551. throw new ArchivaRestServiceException( "artifactId cannot be null", 400, null );
  552. }
  553. if ( StringUtils.isEmpty( version ) )
  554. {
  555. throw new ArchivaRestServiceException( "version cannot be null", 400, null );
  556. }
  557. RepositorySession repositorySession = null;
  558. try
  559. {
  560. repositorySession = repositorySessionFactory.createSession();
  561. }
  562. catch ( MetadataRepositoryException e )
  563. {
  564. e.printStackTrace( );
  565. }
  566. try
  567. {
  568. ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
  569. VersionedReference ref = new VersionedReference();
  570. ref.setArtifactId( projectId );
  571. ref.setGroupId( namespace );
  572. ref.setVersion( version );
  573. repository.deleteVersion( ref );
  574. /*
  575. ProjectReference projectReference = new ProjectReference();
  576. projectReference.setGroupId( namespace );
  577. projectReference.setArtifactId( projectId );
  578. repository.getVersions( )
  579. */
  580. ArtifactReference artifactReference = new ArtifactReference();
  581. artifactReference.setGroupId( namespace );
  582. artifactReference.setArtifactId( projectId );
  583. artifactReference.setVersion( version );
  584. MetadataRepository metadataRepository = repositorySession.getRepository();
  585. Set<ArtifactReference> related = repository.getRelatedArtifacts( artifactReference );
  586. log.debug( "related: {}", related );
  587. for ( ArtifactReference artifactRef : related )
  588. {
  589. repository.deleteArtifact( artifactRef );
  590. }
  591. Collection<ArtifactMetadata> artifacts =
  592. metadataRepository.getArtifacts(repositorySession , repositoryId, namespace, projectId, version );
  593. for ( ArtifactMetadata artifactMetadata : artifacts )
  594. {
  595. metadataRepository.removeTimestampedArtifact(repositorySession , artifactMetadata, version );
  596. }
  597. metadataRepository.removeProjectVersion(repositorySession , repositoryId, namespace, projectId, version );
  598. }
  599. catch ( MetadataRepositoryException e )
  600. {
  601. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  602. }
  603. catch ( MetadataResolutionException e )
  604. {
  605. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  606. }
  607. catch ( RepositoryException e )
  608. {
  609. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  610. }
  611. finally
  612. {
  613. try {
  614. repositorySession.save();
  615. } catch (MetadataSessionException e) {
  616. log.error("Session save failed {}", e.getMessage());
  617. }
  618. repositorySession.close();
  619. }
  620. return Boolean.TRUE;
  621. }
  622. @Override
  623. public Boolean deleteArtifact( Artifact artifact )
  624. throws ArchivaRestServiceException
  625. {
  626. String repositoryId = artifact.getContext();
  627. // some rest call can use context or repositoryId
  628. // so try both!!
  629. if ( StringUtils.isEmpty( repositoryId ) )
  630. {
  631. repositoryId = artifact.getRepositoryId();
  632. }
  633. if ( StringUtils.isEmpty( repositoryId ) )
  634. {
  635. throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null );
  636. }
  637. if ( !isAuthorizedToDeleteArtifacts( repositoryId ) )
  638. {
  639. throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null );
  640. }
  641. if ( artifact == null )
  642. {
  643. throw new ArchivaRestServiceException( "artifact cannot be null", 400, null );
  644. }
  645. if ( StringUtils.isEmpty( artifact.getGroupId() ) )
  646. {
  647. throw new ArchivaRestServiceException( "artifact.groupId cannot be null", 400, null );
  648. }
  649. if ( StringUtils.isEmpty( artifact.getArtifactId() ) )
  650. {
  651. throw new ArchivaRestServiceException( "artifact.artifactId cannot be null", 400, null );
  652. }
  653. // TODO more control on artifact fields
  654. boolean snapshotVersion =
  655. VersionUtil.isSnapshot( artifact.getVersion() ) | VersionUtil.isGenericSnapshot( artifact.getVersion() );
  656. RepositorySession repositorySession = null;
  657. try
  658. {
  659. repositorySession = repositorySessionFactory.createSession();
  660. }
  661. catch ( MetadataRepositoryException e )
  662. {
  663. e.printStackTrace( );
  664. }
  665. try
  666. {
  667. Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
  668. TimeZone timezone = TimeZone.getTimeZone( "UTC" );
  669. DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
  670. fmt.setTimeZone( timezone );
  671. ManagedRepository repo = repositoryRegistry.getManagedRepository( repositoryId );
  672. VersionedReference ref = new VersionedReference();
  673. ref.setArtifactId( artifact.getArtifactId() );
  674. ref.setGroupId( artifact.getGroupId() );
  675. ref.setVersion( artifact.getVersion() );
  676. ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
  677. ArtifactReference artifactReference = new ArtifactReference();
  678. artifactReference.setArtifactId( artifact.getArtifactId() );
  679. artifactReference.setGroupId( artifact.getGroupId() );
  680. artifactReference.setVersion( artifact.getVersion() );
  681. artifactReference.setClassifier( artifact.getClassifier() );
  682. artifactReference.setType( artifact.getPackaging() );
  683. MetadataRepository metadataRepository = repositorySession.getRepository();
  684. String path = repository.toMetadataPath( ref );
  685. if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
  686. {
  687. if ( StringUtils.isBlank( artifact.getPackaging() ) )
  688. {
  689. throw new ArchivaRestServiceException( "You must configure a type/packaging when using classifier",
  690. 400, null );
  691. }
  692. repository.deleteArtifact( artifactReference );
  693. }
  694. else
  695. {
  696. int index = path.lastIndexOf( '/' );
  697. path = path.substring( 0, index );
  698. StorageAsset targetPath = repo.getAsset( path );
  699. if ( !targetPath.exists() )
  700. {
  701. //throw new ContentNotFoundException(
  702. // artifact.getNamespace() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() );
  703. log.warn( "targetPath {} not found skip file deletion", targetPath );
  704. return false;
  705. }
  706. // TODO: this should be in the storage mechanism so that it is all tied together
  707. // delete from file system
  708. if ( !snapshotVersion )
  709. {
  710. repository.deleteVersion( ref );
  711. }
  712. else
  713. {
  714. Set<ArtifactReference> related = repository.getRelatedArtifacts( artifactReference );
  715. log.debug( "related: {}", related );
  716. for ( ArtifactReference artifactRef : related )
  717. {
  718. repository.deleteArtifact( artifactRef );
  719. }
  720. StorageAsset metadataFile = getMetadata( repo, targetPath.getPath() );
  721. ArchivaRepositoryMetadata metadata = getMetadata( metadataFile );
  722. updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, artifact );
  723. }
  724. }
  725. Collection<ArtifactMetadata> artifacts = Collections.emptyList();
  726. if ( snapshotVersion )
  727. {
  728. String baseVersion = VersionUtil.getBaseVersion( artifact.getVersion() );
  729. artifacts =
  730. metadataRepository.getArtifacts(repositorySession , repositoryId, artifact.getGroupId(),
  731. artifact.getArtifactId(), baseVersion );
  732. }
  733. else
  734. {
  735. artifacts =
  736. metadataRepository.getArtifacts(repositorySession , repositoryId, artifact.getGroupId(),
  737. artifact.getArtifactId(), artifact.getVersion() );
  738. }
  739. log.debug( "artifacts: {}", artifacts );
  740. if ( artifacts.isEmpty() )
  741. {
  742. if ( !snapshotVersion )
  743. {
  744. // verify metata repository doesn't contains anymore the version
  745. Collection<String> projectVersions =
  746. metadataRepository.getProjectVersions(repositorySession , repositoryId,
  747. artifact.getGroupId(), artifact.getArtifactId() );
  748. if ( projectVersions.contains( artifact.getVersion() ) )
  749. {
  750. log.warn( "artifact not found when deleted but version still here ! so force cleanup" );
  751. metadataRepository.removeProjectVersion(repositorySession , repositoryId,
  752. artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
  753. }
  754. }
  755. }
  756. for ( ArtifactMetadata artifactMetadata : artifacts )
  757. {
  758. // TODO: mismatch between artifact (snapshot) version and project (base) version here
  759. if ( artifactMetadata.getVersion().equals( artifact.getVersion() ) )
  760. {
  761. if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
  762. {
  763. if ( StringUtils.isBlank( artifact.getPackaging() ) )
  764. {
  765. throw new ArchivaRestServiceException(
  766. "You must configure a type/packaging when using classifier", 400, null );
  767. }
  768. // cleanup facet which contains classifier information
  769. MavenArtifactFacet mavenArtifactFacet =
  770. (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
  771. if ( StringUtils.equals( artifact.getClassifier(), mavenArtifactFacet.getClassifier() ) )
  772. {
  773. artifactMetadata.removeFacet( MavenArtifactFacet.FACET_ID );
  774. String groupId = artifact.getGroupId(), artifactId = artifact.getArtifactId(), version =
  775. artifact.getVersion();
  776. MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet();
  777. mavenArtifactFacetToCompare.setClassifier( artifact.getClassifier() );
  778. metadataRepository.removeFacetFromArtifact(repositorySession , repositoryId, groupId, artifactId,
  779. version, mavenArtifactFacetToCompare );
  780. repositorySession.save();
  781. }
  782. }
  783. else
  784. {
  785. if ( snapshotVersion )
  786. {
  787. metadataRepository.removeTimestampedArtifact(repositorySession ,
  788. artifactMetadata, VersionUtil.getBaseVersion( artifact.getVersion() ) );
  789. }
  790. else
  791. {
  792. metadataRepository.removeArtifact(repositorySession ,
  793. artifactMetadata.getRepositoryId(),
  794. artifactMetadata.getNamespace(), artifactMetadata.getProject(),
  795. artifact.getVersion(), artifactMetadata.getId() );
  796. }
  797. }
  798. // TODO: move into the metadata repository proper - need to differentiate attachment of
  799. // repository metadata to an artifact
  800. for ( RepositoryListener listener : listeners )
  801. {
  802. listener.deleteArtifact( metadataRepository, repository.getId(),
  803. artifactMetadata.getNamespace(), artifactMetadata.getProject(),
  804. artifactMetadata.getVersion(), artifactMetadata.getId() );
  805. }
  806. triggerAuditEvent( repositoryId, path, AuditEvent.REMOVE_FILE );
  807. }
  808. }
  809. }
  810. catch ( ContentNotFoundException e )
  811. {
  812. throw new ArchivaRestServiceException( "Artifact does not exist: " + e.getMessage(), 400, e );
  813. }
  814. catch ( RepositoryNotFoundException e )
  815. {
  816. throw new ArchivaRestServiceException( "Target repository cannot be found: " + e.getMessage(), 400, e );
  817. }
  818. catch ( RepositoryException e )
  819. {
  820. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  821. }
  822. catch (MetadataResolutionException | MetadataSessionException e )
  823. {
  824. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  825. }
  826. catch ( MetadataRepositoryException e )
  827. {
  828. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  829. }
  830. finally
  831. {
  832. try {
  833. repositorySession.save();
  834. } catch (MetadataSessionException e) {
  835. log.error("Could not save sesion {}", e.getMessage());
  836. }
  837. repositorySession.close();
  838. }
  839. return Boolean.TRUE;
  840. }
  841. @Override
  842. public Boolean deleteGroupId( String groupId, String repositoryId )
  843. throws ArchivaRestServiceException
  844. {
  845. if ( StringUtils.isEmpty( repositoryId ) )
  846. {
  847. throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null );
  848. }
  849. if ( !isAuthorizedToDeleteArtifacts( repositoryId ) )
  850. {
  851. throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null );
  852. }
  853. if ( StringUtils.isEmpty( groupId ) )
  854. {
  855. throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
  856. }
  857. RepositorySession repositorySession = null;
  858. try
  859. {
  860. repositorySession = repositorySessionFactory.createSession();
  861. }
  862. catch ( MetadataRepositoryException e )
  863. {
  864. e.printStackTrace( );
  865. }
  866. try
  867. {
  868. ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
  869. repository.deleteGroupId( groupId );
  870. MetadataRepository metadataRepository = repositorySession.getRepository();
  871. metadataRepository.removeNamespace(repositorySession , repositoryId, groupId );
  872. // just invalidate cache entry
  873. String cacheKey = repositoryId + "-" + groupId;
  874. namespacesCache.remove( cacheKey );
  875. namespacesCache.remove( repositoryId );
  876. repositorySession.save();
  877. }
  878. catch (MetadataRepositoryException | MetadataSessionException e )
  879. {
  880. log.error( e.getMessage(), e );
  881. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  882. }
  883. catch ( RepositoryException e )
  884. {
  885. log.error( e.getMessage(), e );
  886. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  887. }
  888. finally
  889. {
  890. repositorySession.close();
  891. }
  892. return true;
  893. }
  894. @Override
  895. public Boolean deleteProject( String groupId, String projectId, String repositoryId )
  896. throws ArchivaRestServiceException
  897. {
  898. if ( StringUtils.isEmpty( repositoryId ) )
  899. {
  900. throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null );
  901. }
  902. if ( !isAuthorizedToDeleteArtifacts( repositoryId ) )
  903. {
  904. throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null );
  905. }
  906. if ( StringUtils.isEmpty( groupId ) )
  907. {
  908. throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
  909. }
  910. if ( StringUtils.isEmpty( projectId ) )
  911. {
  912. throw new ArchivaRestServiceException( "artifactId cannot be null", 400, null );
  913. }
  914. RepositorySession repositorySession = null;
  915. try
  916. {
  917. repositorySession = repositorySessionFactory.createSession();
  918. }
  919. catch ( MetadataRepositoryException e )
  920. {
  921. e.printStackTrace( );
  922. }
  923. try
  924. {
  925. ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
  926. repository.deleteProject( groupId, projectId );
  927. }
  928. catch ( ContentNotFoundException e )
  929. {
  930. log.warn( "skip ContentNotFoundException: {}", e.getMessage() );
  931. }
  932. catch ( RepositoryException e )
  933. {
  934. log.error( e.getMessage(), e );
  935. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  936. }
  937. try
  938. {
  939. MetadataRepository metadataRepository = repositorySession.getRepository();
  940. metadataRepository.removeProject(repositorySession , repositoryId, groupId, projectId );
  941. repositorySession.save();
  942. }
  943. catch (MetadataRepositoryException | MetadataSessionException e )
  944. {
  945. log.error( e.getMessage(), e );
  946. throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
  947. }
  948. finally
  949. {
  950. repositorySession.close();
  951. }
  952. return true;
  953. }
  954. @Override
  955. public Boolean isAuthorizedToDeleteArtifacts( String repoId )
  956. throws ArchivaRestServiceException
  957. {
  958. String userName =
  959. getAuditInformation().getUser() == null ? "guest" : getAuditInformation().getUser().getUsername();
  960. try
  961. {
  962. return userRepositories.isAuthorizedToDeleteArtifacts( userName, repoId );
  963. }
  964. catch ( ArchivaSecurityException e )
  965. {
  966. throw new ArchivaRestServiceException( e.getMessage(),
  967. Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
  968. }
  969. }
  970. @Override
  971. public RepositoryScanStatistics scanRepositoryDirectoriesNow( String repositoryId )
  972. throws ArchivaRestServiceException
  973. {
  974. long sinceWhen = RepositoryScanner.FRESH_SCAN;
  975. try
  976. {
  977. return repoScanner.scan( repositoryRegistry.getManagedRepository( repositoryId ), sinceWhen );
  978. }
  979. catch ( RepositoryScannerException e )
  980. {
  981. log.error( e.getMessage(), e );
  982. throw new ArchivaRestServiceException( "RepositoryScannerException exception: " + e.getMessage(), 500, e );
  983. }
  984. }
  985. /**
  986. * Update artifact level metadata. Creates one if metadata does not exist after artifact deletion.
  987. *
  988. * @param metadata
  989. */
  990. private void updateMetadata( ArchivaRepositoryMetadata metadata, StorageAsset metadataFile, Date lastUpdatedTimestamp,
  991. Artifact artifact )
  992. throws RepositoryMetadataException
  993. {
  994. List<String> availableVersions = new ArrayList<>();
  995. String latestVersion = "";
  996. if ( metadataFile.exists() )
  997. {
  998. if ( metadata.getAvailableVersions() != null )
  999. {
  1000. availableVersions = metadata.getAvailableVersions();
  1001. if ( availableVersions.size() > 0 )
  1002. {
  1003. Collections.sort( availableVersions, VersionComparator.getInstance() );
  1004. if ( availableVersions.contains( artifact.getVersion() ) )
  1005. {
  1006. availableVersions.remove( availableVersions.indexOf( artifact.getVersion() ) );
  1007. }
  1008. if ( availableVersions.size() > 0 )
  1009. {
  1010. latestVersion = availableVersions.get( availableVersions.size() - 1 );
  1011. }
  1012. }
  1013. }
  1014. }
  1015. if ( metadata.getGroupId() == null )
  1016. {
  1017. metadata.setGroupId( artifact.getGroupId() );
  1018. }
  1019. if ( metadata.getArtifactId() == null )
  1020. {
  1021. metadata.setArtifactId( artifact.getArtifactId() );
  1022. }
  1023. if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
  1024. {
  1025. if ( metadata.getReleasedVersion() != null && metadata.getReleasedVersion().equals(
  1026. artifact.getVersion() ) )
  1027. {
  1028. metadata.setReleasedVersion( latestVersion );
  1029. }
  1030. }
  1031. metadata.setLatestVersion( latestVersion );
  1032. metadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
  1033. metadata.setAvailableVersions( availableVersions );
  1034. try (OutputStreamWriter writer = new OutputStreamWriter(metadataFile.getWriteStream(true))) {
  1035. RepositoryMetadataWriter.write(metadata, writer);
  1036. } catch (IOException e) {
  1037. throw new RepositoryMetadataException(e);
  1038. }
  1039. ChecksummedFile checksum = new ChecksummedFile( metadataFile.getFilePath() );
  1040. checksum.fixChecksums( algorithms );
  1041. }
  1042. @Override
  1043. public StringList getRunningRemoteDownloadIds()
  1044. {
  1045. return new StringList( downloadRemoteIndexScheduler.getRunningRemoteDownloadIds() );
  1046. }
  1047. public RepositorySessionFactory getRepositorySessionFactory()
  1048. {
  1049. return repositorySessionFactory;
  1050. }
  1051. public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )
  1052. {
  1053. this.repositorySessionFactory = repositorySessionFactory;
  1054. }
  1055. public List<RepositoryListener> getListeners()
  1056. {
  1057. return listeners;
  1058. }
  1059. public void setListeners( List<RepositoryListener> listeners )
  1060. {
  1061. this.listeners = listeners;
  1062. }
  1063. public ArchivaAdministration getArchivaAdministration()
  1064. {
  1065. return archivaAdministration;
  1066. }
  1067. public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
  1068. {
  1069. this.archivaAdministration = archivaAdministration;
  1070. }
  1071. }