Sfoglia il codice sorgente

Add a service and use ajax to build menus


git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-MRM-1756@1477395 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-2.0.0-RC1
skygo 11 anni fa
parent
commit
a98c867b7f

+ 45
- 0
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/PluginsService.java Vedi File

@@ -0,0 +1,45 @@
package org.apache.archiva.rest.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.archiva.redback.authorization.RedbackAuthorization;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
* contains some services for plugins
*
* @author Eric Barboni
* @since 1.4-M4
*/
@Path( "/pluginsService/" )
public interface PluginsService
{

@Path( "getAdminPlugins" )
@GET
@Produces( { MediaType.TEXT_PLAIN } )
@RedbackAuthorization( noRestriction = true )
String getAdminPlugins( )
throws ArchivaRestServiceException;

}

+ 76
- 0
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java Vedi File

@@ -0,0 +1,76 @@
package org.apache.archiva.rest.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import org.apache.archiva.rest.api.services.PluginsService;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;

/**
* @author Eric Barboni
*/
@Service( "pluginsService#rest" )
public class DefaultPluginsServices
implements PluginsService
{

private List<String> repositoryType = new ArrayList<String>();
@Inject
public DefaultPluginsServices( ApplicationContext applicationContext )
{
Resource[] xmlResources;
try {
xmlResources = applicationContext.getResources( "/**/repository/**/main.js" );
for (Resource rc : xmlResources)
{
String tmp = rc.getURL().toString();
tmp = tmp.substring( tmp.lastIndexOf("repository") + 11, tmp.length() - 8 );
repositoryType.add( tmp );
}
} catch (IOException ex) {
}
}
@Override
public String getAdminPlugins()
throws ArchivaRestServiceException
{
// rebuild
String baseRepo = "archiva/admin/repository/";
StringBuilder sb = new StringBuilder();
for (String repoType : repositoryType)
{
sb.append( baseRepo ).append( repoType ).append( "/main" ).append( "|" );
}
return sb.substring( 0, sb.length() - 1);
}

}

+ 1
- 0
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml Vedi File

@@ -68,6 +68,7 @@
<ref bean="searchService#rest"/>
<ref bean="commonServices#rest"/>
<ref bean="browseService#rest"/>
<ref bean="pluginsService#rest"/>
<ref bean="systemStatusService#rest"/>
<ref bean="reportRepositoriesService#rest" />
<ref bean="mergeRepositoriesService#rest"/>

+ 11
- 5
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js Vedi File

@@ -226,15 +226,21 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
this.administrationMenuItems = ko.observableArray([
{text: $.i18n.prop('menu.administration'), id: null} ]);
var myrepplugins = "archiva/admin/repository/legacy/main|archiva/admin/repository/maven2/main";
$.each(myrepplugins.split("|"), function(key, value) {
alert(value);
require([value], function() {
var pluginsURL = "restServices/archivaServices/pluginsService/getAdminPlugins";
$.ajax(pluginsURL, {
type: "GET",
dataType: 'text',
success: function(data) {
$.each(data.split("|"), function(key, value) {
require([value], function() {
showMenu(self.administrationMenuItems);
});
});
}
});
//var myrepplugins = "archiva/admin/repository/legacy/main|archiva/admin/repository/maven2/main";
self.administrationMenuItems.push({ text : $.i18n.prop('menu.network-proxies') , id: "menu-network-proxies-list-a" , href: "#networkproxies" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkProxies()}});
self.administrationMenuItems.push({ text : $.i18n.prop('menu.repository-scanning') , id: "menu-repository-scanning-list-a" , href: "#scanningList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryScanning()}});
self.administrationMenuItems.push({ text : $.i18n.prop('menu.runtime-configuration') , id: "menu-runtime-configuration-list-a" , href: "#runtimeconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRuntimeConfiguration()}});

Loading…
Annulla
Salva