1 package org.apache.archiva.rest.services;
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
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
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.List;
24 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
25 import org.springframework.stereotype.Service;
27 import javax.inject.Inject;
28 import org.apache.archiva.rest.api.services.PluginsService;
29 import org.springframework.context.ApplicationContext;
30 import org.springframework.core.io.Resource;
33 * @author Eric Barboni
35 @Service( "pluginsService#rest" )
36 public class DefaultPluginsServices
37 implements PluginsService
40 private List<String> repositoryType = new ArrayList<String>();
41 private List<String> adminFeatures = new ArrayList<String>();
44 public DefaultPluginsServices( ApplicationContext applicationContext )
46 feed( repositoryType, "repository", applicationContext );
47 feed( adminFeatures, "features", applicationContext );
50 private void feed( List<String> repository, String key, ApplicationContext applicationContext )
52 Resource[] xmlResources;
55 xmlResources = applicationContext.getResources( "/**/" + key + "/**/main.js" );
56 for ( Resource rc : xmlResources )
58 String tmp = rc.getURL().toString();
59 tmp = tmp.substring( tmp.lastIndexOf( key ) + key.length() + 1, tmp.length() - 8 );
60 repository.add( "archiva/admin/" + key + "/" + tmp + "/main" );
63 catch ( IOException ex )
69 public String getAdminPlugins()
70 throws ArchivaRestServiceException
73 StringBuilder sb = new StringBuilder();
74 for ( String repoType : repositoryType )
76 sb.append( repoType ).append( "|" );
78 for ( String repoType : adminFeatures )
80 sb.append( repoType ).append( "|" );
83 return sb.substring( 0, sb.length() - 1 );