001/* 002 * (C) Copyright 2006-2011 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 020package org.nuxeo.ecm.core.management.api; 021 022import java.io.Serializable; 023import java.util.Calendar; 024 025/** 026 * Representation of the Administrative Status of a service or server 027 * 028 * @author tiry 029 */ 030public class AdministrativeStatus implements Serializable { 031 032 private static final long serialVersionUID = 1L; 033 034 public static final String ACTIVE = "active"; 035 036 public static final String PASSIVE = "passive"; 037 038 protected final String state; 039 040 protected final String message; 041 042 protected final Calendar modificationDate; 043 044 protected final String userLogin; 045 046 protected final String instanceIdentifier; 047 048 protected final String serviceIdentifier; 049 050 protected String label; 051 052 protected String description; 053 054 public AdministrativeStatus(String state, String message, Calendar modificationDate, String userLogin, 055 String instanceIdentifier, String serviceIdentifier) { 056 this.state = state; 057 this.message = message; 058 this.modificationDate = modificationDate; 059 this.userLogin = userLogin; 060 this.instanceIdentifier = instanceIdentifier; 061 this.serviceIdentifier = serviceIdentifier; 062 } 063 064 public void setLabelAndDescription(String label, String description) { 065 this.label = label; 066 this.description = description; 067 } 068 069 public String getInstanceIdentifier() { 070 return instanceIdentifier; 071 } 072 073 public String getServiceIdentifier() { 074 return serviceIdentifier; 075 } 076 077 public String getState() { 078 return state; 079 } 080 081 public String getMessage() { 082 return message; 083 } 084 085 public Calendar getModificationDate() { 086 return modificationDate; 087 } 088 089 public String getUserLogin() { 090 return userLogin; 091 } 092 093 public boolean isActive() { 094 return state.equals(ACTIVE); 095 } 096 097 public boolean isPassive() { 098 return state.equals(PASSIVE); 099 } 100 101 public String getLabel() { 102 return label; 103 } 104 105 public String getDescription() { 106 return description; 107 } 108 109 @Override 110 public String toString() { 111 return String.format("administrativeStatus(%s,%s)", instanceIdentifier, state); 112 } 113 114}