001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 */
012
013package org.nuxeo.ecm.core.management.api;
014
015import java.io.Serializable;
016import java.util.Calendar;
017
018/**
019 * Representation of the Administrative Status of a service or server
020 *
021 * @author tiry
022 */
023public class AdministrativeStatus implements Serializable {
024
025    private static final long serialVersionUID = 1L;
026
027    public static final String ACTIVE = "active";
028
029    public static final String PASSIVE = "passive";
030
031    protected final String state;
032
033    protected final String message;
034
035    protected final Calendar modificationDate;
036
037    protected final String userLogin;
038
039    protected final String instanceIdentifier;
040
041    protected final String serviceIdentifier;
042
043    protected String label;
044
045    protected String description;
046
047    public AdministrativeStatus(String state, String message, Calendar modificationDate, String userLogin,
048            String instanceIdentifier, String serviceIdentifier) {
049        this.state = state;
050        this.message = message;
051        this.modificationDate = modificationDate;
052        this.userLogin = userLogin;
053        this.instanceIdentifier = instanceIdentifier;
054        this.serviceIdentifier = serviceIdentifier;
055    }
056
057    public void setLabelAndDescription(String label, String description) {
058        this.label = label;
059        this.description = description;
060    }
061
062    public String getInstanceIdentifier() {
063        return instanceIdentifier;
064    }
065
066    public String getServiceIdentifier() {
067        return serviceIdentifier;
068    }
069
070    public String getState() {
071        return state;
072    }
073
074    public String getMessage() {
075        return message;
076    }
077
078    public Calendar getModificationDate() {
079        return modificationDate;
080    }
081
082    public String getUserLogin() {
083        return userLogin;
084    }
085
086    public boolean isActive() {
087        return state.equals(ACTIVE);
088    }
089
090    public boolean isPassive() {
091        return state.equals(PASSIVE);
092    }
093
094    public String getLabel() {
095        return label;
096    }
097
098    public String getDescription() {
099        return description;
100    }
101
102    @Override
103    public String toString() {
104        return String.format("administrativeStatus(%s,%s)", instanceIdentifier, state);
105    }
106
107}