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 *     bstefanescu
011 */
012package org.nuxeo.runtime.model.persistence;
013
014import org.nuxeo.runtime.model.persistence.fs.FileSystemStorage;
015
016/**
017 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
018 */
019public abstract class AbstractContribution implements Contribution {
020
021    protected String id;
022
023    protected boolean loaded;
024
025    protected final String name;
026
027    protected String description;
028
029    protected boolean disabled;
030
031    protected AbstractContribution(String name) {
032        this.name = name;
033    }
034
035    @Override
036    public String getId() {
037        if (id == null) {
038            id = ContributionPersistenceComponent.getComponentName(getName());
039        }
040        return id;
041    }
042
043    protected void load() {
044        if (!loaded) {
045            FileSystemStorage.loadMetadata(this);
046            loaded = true;
047        }
048    }
049
050    @Override
051    public String getName() {
052        return name;
053    }
054
055    @Override
056    public String getDescription() {
057        load();
058        return description;
059    }
060
061    @Override
062    public void setDescription(String description) {
063        this.description = description;
064    }
065
066    @Override
067    public boolean isDisabled() {
068        load();
069        return disabled;
070    }
071
072    @Override
073    public void setDisabled(boolean isDisabled) {
074        this.disabled = isDisabled;
075    }
076
077}