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

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