001/* 002 * (C) Copyright 2006-2017 Nuxeo (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 */ 019package org.nuxeo.ecm.admin.runtime; 020 021import java.util.List; 022 023/** 024 * Holds information about current deployed Nuxeo Platform 025 * 026 * @author tiry 027 */ 028public class SimplifiedServerInfo { 029 030 protected List<SimplifiedBundleInfo> bundleInfos; 031 032 protected String runtimeVersion; 033 034 protected List<String> warnings; 035 036 protected List<String> errors; 037 038 public List<SimplifiedBundleInfo> getBundleInfos() { 039 return bundleInfos; 040 } 041 042 public void setBundleInfos(List<SimplifiedBundleInfo> bundleInfos) { 043 this.bundleInfos = bundleInfos; 044 } 045 046 public String getApplicationName() { 047 return PlatformVersionHelper.getApplicationName(); 048 } 049 050 public String getApplicationVersion() { 051 return PlatformVersionHelper.getApplicationVersion(); 052 } 053 054 public String getDistributionName() { 055 return PlatformVersionHelper.getDistributionName(); 056 } 057 058 public String getDistributionVersion() { 059 return PlatformVersionHelper.getDistributionVersion(); 060 } 061 062 public String getDistributionHost() { 063 return PlatformVersionHelper.getDistributionHost(); 064 } 065 066 public String getDistributionDate() { 067 return PlatformVersionHelper.getDistributionDate(); 068 } 069 070 public String getRuntimeVersion() { 071 return runtimeVersion; 072 } 073 074 public void setRuntimeVersion(String runtimeVersion) { 075 this.runtimeVersion = runtimeVersion; 076 } 077 078 public List<String> getWarnings() { 079 return warnings; 080 } 081 082 public void setWarnings(List<String> warnings) { 083 this.warnings = warnings; 084 } 085 086 public boolean hasWarnings() { 087 return warnings != null && !warnings.isEmpty(); 088 } 089 090 /** 091 * @since 9.1 092 */ 093 public List<String> getErrors() { 094 return errors; 095 } 096 097 /** 098 * @since 9.1 099 */ 100 public void setErrors(List<String> errors) { 101 this.errors = errors; 102 } 103 104 /** 105 * @since 9.1 106 */ 107 public boolean hasErrors() { 108 return errors != null && !errors.isEmpty(); 109 } 110 111 @Override 112 public String toString() { 113 StringBuilder sb = new StringBuilder(); 114 115 sb.append(getApplicationName()); 116 sb.append(" "); 117 sb.append(getApplicationVersion()); 118 sb.append("\n"); 119 120 sb.append("runtime : "); 121 sb.append(runtimeVersion); 122 sb.append("\n"); 123 124 sb.append("warnings : "); 125 if (warnings == null || warnings.isEmpty()) { 126 sb.append("none"); 127 } else { 128 for (String warn : warnings) { 129 sb.append("\n "); 130 sb.append(warn); 131 } 132 } 133 134 sb.append("errors : "); 135 if (errors == null || errors.isEmpty()) { 136 sb.append("none"); 137 } else { 138 for (String error : errors) { 139 sb.append("\n "); 140 sb.append(error); 141 } 142 } 143 144 sb.append("\nbundles : "); 145 for (SimplifiedBundleInfo bi : bundleInfos) { 146 sb.append("\n "); 147 sb.append(bi.getName()); 148 sb.append(" ("); 149 sb.append(bi.getVersion()); 150 sb.append(")"); 151 } 152 153 return sb.toString(); 154 } 155}