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;
25 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
26 import org.springframework.stereotype.Service;
28 import javax.inject.Inject;
30 import org.apache.archiva.rest.api.services.PluginsService;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.context.ApplicationContext;
34 import org.springframework.core.io.Resource;
37 * @author Eric Barboni
40 @Service("pluginsService#rest")
41 public class DefaultPluginsServices
42 implements PluginsService
45 private List<String> repositoryType = new ArrayList<>();
47 private List<String> adminFeatures = new ArrayList<>();
49 private ApplicationContext appCont;
51 private Logger log = LoggerFactory.getLogger( getClass() );
53 private String adminPlugins;
56 public DefaultPluginsServices( ApplicationContext applicationContext )
59 this.appCont = applicationContext;
62 feed( repositoryType, "repository" );
63 feed( adminFeatures, "features" );
64 StringBuilder sb = new StringBuilder();
65 for ( String repoType : repositoryType )
67 sb.append( repoType ).append( "|" );
69 for ( String repoType : adminFeatures )
71 sb.append( repoType ).append( "|" );
73 log.debug( "getAdminPlugins: {}", sb.toString() );
74 if ( sb.length() > 1 )
76 adminPlugins = sb.substring( 0, sb.length() - 1 );
80 adminPlugins = sb.toString();
84 private void feed( List<String> repository, String key )
87 log.info( "Feeding: {}", key );
89 Resource[] xmlResources;
91 xmlResources = appCont.getResources( "/**/" + key + "/**/main.js" );
92 for ( Resource rc : xmlResources )
94 String tmp = rc.getURL().toString();
95 tmp = tmp.substring( tmp.lastIndexOf( key ) + key.length() + 1, tmp.length() - 8 );
96 repository.add( "archiva/admin/" + key + "/" + tmp + "/main" );
102 public String getAdminPlugins()
103 throws ArchivaRestServiceException