001/*
002 * (C) Copyright 2006-2009 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.admin.runtime;
021
022import java.util.List;
023
024/**
025 * Holds information about current deployed Nuxeo Platform
026 *
027 * @author tiry
028 */
029public class SimplifiedServerInfo {
030
031    protected List<SimplifiedBundleInfo> bundleInfos;
032
033    protected String runtimeVersion;
034
035    protected List<String> warnings;
036
037    public List<SimplifiedBundleInfo> getBundleInfos() {
038        return bundleInfos;
039    }
040
041    public void setBundleInfos(List<SimplifiedBundleInfo> bundleInfos) {
042        this.bundleInfos = bundleInfos;
043    }
044
045    public String getApplicationName() {
046        return PlatformVersionHelper.getApplicationName();
047    }
048
049    public String getApplicationVersion() {
050        return PlatformVersionHelper.getApplicationVersion();
051    }
052
053    public String getDistributionName() {
054        return PlatformVersionHelper.getDistributionName();
055    }
056
057    public String getDistributionVersion() {
058        return PlatformVersionHelper.getDistributionVersion();
059    }
060
061    public String getDistributionHost() {
062        return PlatformVersionHelper.getDistributionHost();
063    }
064
065    public String getDistributionDate() {
066        return PlatformVersionHelper.getDistributionDate();
067    }
068
069    public String getRuntimeVersion() {
070        return runtimeVersion;
071    }
072
073    public void setRuntimeVersion(String runtimeVersion) {
074        this.runtimeVersion = runtimeVersion;
075    }
076
077    public List<String> getWarnings() {
078        return warnings;
079    }
080
081    public void setWarnings(List<String> warnings) {
082        this.warnings = warnings;
083    }
084
085    public boolean hasWarnings() {
086        return warnings != null && !warnings.isEmpty();
087    }
088
089    @Override
090    public String toString() {
091        StringBuffer sb = new StringBuffer();
092
093        sb.append(getApplicationName());
094        sb.append("  ");
095        sb.append(getApplicationVersion());
096        sb.append("\n");
097
098        sb.append("runtime :  ");
099        sb.append(runtimeVersion);
100        sb.append("\n");
101
102        sb.append("warnings :  ");
103        if (warnings == null || warnings.isEmpty()) {
104            sb.append("none");
105        } else {
106            for (String warn : warnings) {
107                sb.append("\n  ");
108                sb.append(warn);
109            }
110        }
111
112        sb.append("\nbundles :  ");
113        for (SimplifiedBundleInfo bi : bundleInfos) {
114            sb.append("\n  ");
115            sb.append(bi.getName());
116            sb.append("    (");
117            sb.append(bi.getVersion());
118            sb.append(")");
119        }
120
121        return sb.toString();
122    }
123}