1 package org.apache.archiva.rest.api.v2.model.map;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 import org.apache.archiva.configuration.model.ManagedRepositoryConfiguration;
21 import org.apache.archiva.repository.ManagedRepository;
22 import org.apache.archiva.repository.ReleaseScheme;
23 import org.apache.archiva.repository.RepositoryType;
24 import org.apache.archiva.repository.features.ArtifactCleanupFeature;
25 import org.apache.archiva.repository.features.StagingRepositoryFeature;
26 import org.apache.archiva.rest.api.v2.model.MavenManagedRepository;
27 import org.springframework.stereotype.Service;
30 * Mapping implementation for Maven managed repository to managed repository configuration
32 * @author Martin Schreier <martin_s@apache.org>
34 @Service("mapper#managed_repository#maven")
35 public class MavenRepositoryMapper extends RestServiceMapper<MavenManagedRepository, ManagedRepositoryConfiguration, ManagedRepository>
38 private static final String TYPE = RepositoryType.MAVEN.name( );
41 public ManagedRepositoryConfiguration map( MavenManagedRepository source )
43 ManagedRepositoryConfiguration target = new ManagedRepositoryConfiguration( );
44 update( source, target );
49 public void update( MavenManagedRepository source, ManagedRepositoryConfiguration target )
51 target.setId( source.getId() );
52 target.setName( source.getName() );
53 target.setDescription( source.getDescription( ) );
54 target.setType( TYPE );
56 target.setBlockRedeployments( source.isBlocksRedeployments() );
57 target.setDeleteReleasedSnapshots( source.isDeleteSnapshotsOfRelease() );
58 target.setIndexDir( source.getIndexPath() );
59 target.setLayout( source.getLayout() );
60 target.setLocation( source.getLocation() );
61 target.setPackedIndexDir( source.getPackedIndexPath() );
62 target.setRefreshCronExpression( source.getSchedulingDefinition() );
63 target.setReleases( source.getReleaseSchemes( ).contains( ReleaseScheme.RELEASE ) );
64 target.setRetentionCount( source.getRetentionCount() );
65 target.setRetentionPeriod( source.getRetentionPeriod().getDays() );
66 target.setScanned( source.isScanned() );
67 target.setSkipPackedIndexCreation( source.isSkipPackedIndexCreation() );
68 target.setSnapshots( source.getReleaseSchemes( ).contains( ReleaseScheme.SNAPSHOT ) );
69 target.setStageRepoNeeded( source.hasStagingRepository() );
74 public MavenManagedRepository reverseMap( ManagedRepository source )
76 MavenManagedRepository result = new MavenManagedRepository( );
77 StagingRepositoryFeature srf = source.getFeature( StagingRepositoryFeature.class );
78 ArtifactCleanupFeature acf = source.getFeature( ArtifactCleanupFeature.class );
79 result.setHasStagingRepository( srf.isStageRepoNeeded() );
80 result.setBlocksRedeployments( source.blocksRedeployments() );
81 result.setIndex( source.hasIndex() );
82 result.setStagingRepository( srf.getStagingRepository().getId() );
87 public void reverseUpdate( ManagedRepository source, MavenManagedRepository target )
93 public Class<MavenManagedRepository> getBaseType( )
95 return MavenManagedRepository.class;
99 public Class<ManagedRepositoryConfiguration> getDestinationType( )
101 return ManagedRepositoryConfiguration.class;
105 public Class<ManagedRepository> getReverseSourceType( )
107 return ManagedRepository.class;