001 /*
002 * ----------------------------------------------------------------------
003 * Copyright (C) 2009 Enrique Lara (k957@68k.org)
004 *
005 * TinLizard is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public License
007 * as published by the Free Software Foundation; either version 3.0
008 * of the License, or (at your option) any later version.
009 *
010 * TinLizard is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with TinLizard. If not, see http://www.gnu.org/licenses/.
017 * ----------------------------------------------------------------------
018 */
019 package tinlizard.web;
020
021 import tinlizard.model.Policy;
022
023 import tinlizard.util.Messages;
024
025 import java.util.Collection;
026
027 import org.jvnet.localizer.Localizable;
028
029 import org.kohsuke.stapler.export.Exported;
030
031 /**
032 * Web Accessible Policy Collection.
033 */
034 public final class PolicyCollectionWeb extends ObjectCollectionWeb {
035 public PolicyCollectionWeb(final Collection<Policy> c, final Localizable name) {
036 super(name);
037
038 if (c == null) {
039 throw new IllegalStateException(Messages.error_1019());
040 }
041
042 if (name == null) {
043 throw new IllegalStateException(Messages.error_1014());
044 }
045
046 for (Policy o : c) {
047 getSubject().add(o);
048 getDelegate().add(new PolicyWeb(o));
049 }
050 }
051
052 @Exported(name = "policys")
053 public PolicyCollectionWeb getPolicies() {
054 return this;
055 }
056 }