1 package org.apache.maven.archiva.web.action.admin;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import com.opensymphony.xwork2.Preparable;
23 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
24 import org.apache.maven.archiva.configuration.Configuration;
25 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
26 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
27 import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationComparator;
28 import org.apache.maven.archiva.database.ArchivaDAO;
29 import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
30 import org.apache.maven.archiva.model.RepositoryContentStatistics;
31 import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
32 import org.apache.maven.archiva.security.ArchivaRoleConstants;
33 import org.apache.maven.archiva.web.action.PlexusActionSupport;
34 import org.apache.maven.archiva.web.util.ContextUtils;
35 import org.apache.struts2.interceptor.ServletRequestAware;
36 import org.codehaus.plexus.cache.Cache;
37 import org.codehaus.plexus.redback.rbac.Resource;
38 import org.codehaus.plexus.taskqueue.TaskQueue;
39 import org.codehaus.redback.integration.interceptor.SecureAction;
40 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
41 import org.codehaus.redback.integration.interceptor.SecureActionException;
43 import java.util.ArrayList;
44 import java.util.Collections;
45 import java.util.HashMap;
46 import java.util.List;
48 import javax.servlet.http.HttpServletRequest;
51 * Shows system status information for the administrator.
54 * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="systemStatus" instantiation-strategy="per-lookup"
56 public class SystemStatusAction
57 extends PlexusActionSupport
58 implements SecureAction
61 * @plexus.requirement role="org.codehaus.plexus.taskqueue.TaskQueue"
63 private Map<String,TaskQueue> queues;
66 * @plexus.requirement role="org.codehaus.plexus.cache.Cache"
68 private Map<String,Cache> caches;
70 private String memoryStatus;
72 public SecureActionBundle getSecureActionBundle()
73 throws SecureActionException
75 SecureActionBundle bundle = new SecureActionBundle();
77 bundle.setRequiresAuthentication( true );
78 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
83 public String execute()
85 Runtime runtime = Runtime.getRuntime();
87 long total = runtime.totalMemory();
88 long used = total - runtime.freeMemory();
89 long max = runtime.maxMemory();
90 memoryStatus = formatMemory(used) + "/" + formatMemory(total) + " (Max: " + formatMemory(max) + ")";
95 private static String formatMemory( long l )
97 return l / ( 1024 * 1024 ) + "M";
100 public String getMemoryStatus()
105 public Map<String, Cache> getCaches()
110 public Map<String, TaskQueue> getQueues()