001/*
002 * (C) Copyright 2006-2009 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.admin.runtime;
023
024import java.util.List;
025
026/**
027 * Holds information about current deployed Nuxeo Platform
028 *
029 * @author tiry
030 */
031public class SimplifiedServerInfo {
032
033    protected List<SimplifiedBundleInfo> bundleInfos;
034
035    protected String runtimeVersion;
036
037    protected List<String> warnings;
038
039    public List<SimplifiedBundleInfo> getBundleInfos() {
040        return bundleInfos;
041    }
042
043    public void setBundleInfos(List<SimplifiedBundleInfo> bundleInfos) {
044        this.bundleInfos = bundleInfos;
045    }
046
047    public String getApplicationName() {
048        return PlatformVersionHelper.getApplicationName();
049    }
050
051    public String getApplicationVersion() {
052        return PlatformVersionHelper.getApplicationVersion();
053    }
054
055    public String getDistributionName() {
056        return PlatformVersionHelper.getDistributionName();
057    }
058
059    public String getDistributionVersion() {
060        return PlatformVersionHelper.getDistributionVersion();
061    }
062
063    public String getDistributionHost() {
064        return PlatformVersionHelper.getDistributionHost();
065    }
066
067    public String getDistributionDate() {
068        return PlatformVersionHelper.getDistributionDate();
069    }
070
071    public String getRuntimeVersion() {
072        return runtimeVersion;
073    }
074
075    public void setRuntimeVersion(String runtimeVersion) {
076        this.runtimeVersion = runtimeVersion;
077    }
078
079    public List<String> getWarnings() {
080        return warnings;
081    }
082
083    public void setWarnings(List<String> warnings) {
084        this.warnings = warnings;
085    }
086
087    public boolean hasWarnings() {
088        return warnings != null && !warnings.isEmpty();
089    }
090
091    @Override
092    public String toString() {
093        StringBuffer sb = new StringBuffer();
094
095        sb.append(getApplicationName());
096        sb.append("  ");
097        sb.append(getApplicationVersion());
098        sb.append("\n");
099
100        sb.append("runtime :  ");
101        sb.append(runtimeVersion);
102        sb.append("\n");
103
104        sb.append("warnings :  ");
105        if (warnings == null || warnings.isEmpty()) {
106            sb.append("none");
107        } else {
108            for (String warn : warnings) {
109                sb.append("\n  ");
110                sb.append(warn);
111            }
112        }
113
114        sb.append("\nbundles :  ");
115        for (SimplifiedBundleInfo bi : bundleInfos) {
116            sb.append("\n  ");
117            sb.append(bi.getName());
118            sb.append("    (");
119            sb.append(bi.getVersion());
120            sb.append(")");
121        }
122
123        return sb.toString();
124    }
125}