public BrowseResult getRootGroups( String repositoryId )
throws ArchivaRestServiceException
{
- List<String> selectedRepos = getObservableRepos();
- if ( CollectionUtils.isEmpty( selectedRepos ) )
- {
- // FIXME 403 ???
- return new BrowseResult();
- }
-
- if ( StringUtils.isNotEmpty( repositoryId ) )
- {
- // check user has karma on the repository
- if ( !selectedRepos.contains( repositoryId ) )
- {
- throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
- Response.Status.FORBIDDEN.getStatusCode() );
- }
- selectedRepos = Collections.singletonList( repositoryId );
- }
+ List<String> selectedRepos = getSelectedRepos( repositoryId );
Set<String> namespaces = new LinkedHashSet<String>();
public BrowseResult browseGroupId( String groupId, String repositoryId )
throws ArchivaRestServiceException
{
-
- List<String> selectedRepos = getObservableRepos();
- if ( CollectionUtils.isEmpty( selectedRepos ) )
- {
- // FIXME 403 ???
- return new BrowseResult();
- }
-
- if ( StringUtils.isNotEmpty( repositoryId ) )
- {
- // check user has karma on the repository
- if ( !selectedRepos.contains( repositoryId ) )
- {
- throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
- Response.Status.FORBIDDEN.getStatusCode() );
- }
- selectedRepos = Collections.singletonList( repositoryId );
- }
+ List<String> selectedRepos = getSelectedRepos( repositoryId );
Set<String> projects = new LinkedHashSet<String>();
public VersionsList getVersionsList( String groupId, String artifactId, String repositoryId )
throws ArchivaRestServiceException
{
- List<String> selectedRepos = getObservableRepos();
- if ( CollectionUtils.isEmpty( selectedRepos ) )
- {
- // FIXME 403 ???
- return new VersionsList();
- }
-
- if ( StringUtils.isNotEmpty( repositoryId ) )
- {
- // check user has karma on the repository
- if ( !selectedRepos.contains( repositoryId ) )
- {
- throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
- Response.Status.FORBIDDEN.getStatusCode() );
- }
- selectedRepos = Collections.singletonList( repositoryId );
- }
+ List<String> selectedRepos = getSelectedRepos( repositoryId );
try
{
String repositoryId )
throws ArchivaRestServiceException
{
- List<String> selectedRepos = getObservableRepos();
-
- if ( CollectionUtils.isEmpty( selectedRepos ) )
- {
- // FIXME 403 ???
- return null;
- }
-
- if ( StringUtils.isNotEmpty( repositoryId ) )
- {
- // check user has karma on the repository
- if ( !selectedRepos.contains( repositoryId ) )
- {
- throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
- Response.Status.FORBIDDEN.getStatusCode() );
- }
- selectedRepos = Collections.singletonList( repositoryId );
- }
+ List<String> selectedRepos = getSelectedRepos( repositoryId );
RepositorySession repositorySession = null;
try
throws ArchivaRestServiceException
{
- List<String> selectedRepos = getObservableRepos();
-
- if ( CollectionUtils.isEmpty( selectedRepos ) )
- {
- // FIXME 403 ???
- return null;
- }
-
- if ( StringUtils.isNotEmpty( repositoryId ) )
- {
- // check user has karma on the repository
- if ( !selectedRepos.contains( repositoryId ) )
- {
- throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
- Response.Status.FORBIDDEN.getStatusCode() );
- }
- selectedRepos = Collections.singletonList( repositoryId );
- }
+ List<String> selectedRepos = getSelectedRepos( repositoryId );
RepositorySession repositorySession = null;
try
public List<TreeEntry> getTreeEntries( String groupId, String artifactId, String version, String repositoryId )
throws ArchivaRestServiceException
{
- List<String> selectedRepos = getObservableRepos();
-
- if ( CollectionUtils.isEmpty( selectedRepos ) )
- {
- // FIXME 403 ???
- return null;
- }
-
- if ( StringUtils.isNotEmpty( repositoryId ) )
- {
- // check user has karma on the repository
- if ( !selectedRepos.contains( repositoryId ) )
- {
- throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
- Response.Status.FORBIDDEN.getStatusCode() );
- }
- selectedRepos = Collections.singletonList( repositoryId );
- }
+ List<String> selectedRepos = getSelectedRepos( repositoryId );
List<TreeEntry> treeEntries = new ArrayList<TreeEntry>();
TreeDependencyNodeVisitor treeDependencyNodeVisitor = new TreeDependencyNodeVisitor( treeEntries );
// internals
//---------------------------
+ private List<String> getSelectedRepos( String repositoryId )
+ throws ArchivaRestServiceException
+ {
+
+ List<String> selectedRepos = getObservableRepos();
+
+ if ( CollectionUtils.isEmpty( selectedRepos ) )
+ {
+ // FIXME 403 ???
+ return null;
+ }
+
+ if ( StringUtils.isNotEmpty( repositoryId ) )
+ {
+ // check user has karma on the repository
+ if ( !selectedRepos.contains( repositoryId ) )
+ {
+ throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
+ Response.Status.FORBIDDEN.getStatusCode() );
+ }
+ selectedRepos = Collections.singletonList( repositoryId );
+ }
+ return selectedRepos;
+ }
+
private List<String> getSortedList( Set<String> set )
{
List<String> list = new ArrayList<String>( set );