You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kalumet-commits@incubator.apache.org by jb...@apache.org on 2011/10/22 13:10:04 UTC
svn commit: r1187711 [4/5] - in /incubator/kalumet/trunk: ./ common/
common/src/ common/src/main/ common/src/main/java/
common/src/main/java/org/ common/src/main/java/org/apache/
common/src/main/java/org/apache/kalumet/ common/src/main/java/org/apache/...
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Kalumet.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Kalumet.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Kalumet.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Kalumet.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,765 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.FileOutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
+import org.apache.kalumet.KalumetException;
+import org.apache.kalumet.FileManipulator;
+
+import org.apache.commons.digester.Digester;
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>kalumet</code> root tag in the main Kalumet DOM.
+ */
+public class Kalumet implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -3237352886418250595L;
+
+ private static WriterPreferenceReadWriteLock lock = new WriterPreferenceReadWriteLock();
+
+ private LinkedList properties;
+ private Security security;
+ private LinkedList agents;
+ private LinkedList environments;
+
+ public Kalumet() {
+ this.properties = new LinkedList();
+ this.security = new Security();
+ this.agents = new LinkedList();
+ this.environments = new LinkedList();
+ }
+
+ /**
+ * Adds a new <code>Property</code> in the <code>Kalumet</code>
+ * container.
+ *
+ * @param property the <code>Property</code> to add.
+ */
+ public void addProperty(Property property) throws ModelObjectAlreadyExistsException {
+ if (this.getProperty(property.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Property name already exists in Kalumet configuration.");
+ }
+ this.properties.add(property);
+ }
+
+ /**
+ * Gets the <code>Property</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Property</code> list.
+ */
+ public List getProperties() {
+ return this.properties;
+ }
+
+ /**
+ * Overwrites the <code>Property</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @param properties the new <code>Property</code> list.
+ */
+ public void setProperties(LinkedList properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Get the <code>Property</code> identified by a given name in the
+ * <code>Kalumet</code> container.
+ *
+ * @param name the <code>Property</code> name.
+ * @return the found <code>Property</code> or null if no <code>Property</code> found.
+ */
+ public Property getProperty(String name) {
+ for (Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); ) {
+ Property property = (Property) propertyIterator.next();
+ if (property.getName().equals(name)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Set the <code>Security</code> definition of the <code>Kalumet</code>
+ * container.
+ *
+ * @param security the <code>Security</code> definition.
+ */
+ public void setSecurity(Security security) {
+ this.security = security;
+ }
+
+ /**
+ * Get the <code>Security</code> definition of the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Security</code> definition.
+ */
+ public Security getSecurity() {
+ return this.security;
+ }
+
+ /**
+ * Add a new <code>Agent</code> in the <code>Kalumet</code> container.
+ *
+ * @param agent the <code>Agent</code> to add.
+ */
+ public void addAgent(Agent agent) throws ModelObjectAlreadyExistsException {
+ if (this.getAgent(agent.getId()) != null) {
+ throw new ModelObjectAlreadyExistsException("Agent id already exists in Kalumet configuration.");
+ }
+ this.agents.add(agent);
+ }
+
+ /**
+ * Overwrite the <code>Agent</code> list in the <code>Kalumet</code>
+ * container with a new list.
+ *
+ * @param agents the new <code>Agent</code> list.
+ */
+ public void setAgents(LinkedList agents) {
+ this.agents = agents;
+ }
+
+ /**
+ * Return the <code>Agent</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Agent</code> list.
+ */
+ public List getAgents() {
+ return this.agents;
+ }
+
+ /**
+ * Get the <code>Agent</code> identified by a given id in the
+ * <code>Kalumet</code> container.
+ *
+ * @param id the <code>Agent</code> id.
+ * @return the found <code>Agent</code> or null if no <code>Agent</code> found.
+ */
+ public Agent getAgent(String id) {
+ for (Iterator agentIterator = this.getAgents().iterator(); agentIterator.hasNext(); ) {
+ Agent agent = (Agent) agentIterator.next();
+ if (agent.getId().equals(id)) {
+ return agent;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>Environment</code> to the <code>Kalumet</code>
+ * container.
+ *
+ * @param environment the <code>Environment</code> to add.
+ */
+ public void addEnvironment(Environment environment) throws ModelObjectAlreadyExistsException {
+ if (this.getEnvironment(environment.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Environment name already exists in Kalumet configuration.");
+ }
+ this.environments.add(environment);
+ }
+
+ /**
+ * Get the <code>Environment</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Environment</code> list.
+ */
+ public List getEnvironments() {
+ return this.environments;
+ }
+
+ /**
+ * Overwrite the <code>Environment</code> list in the
+ * <code>Kalumet</code> container.
+ *
+ * @param environments the new <code>Environment</code> list.
+ */
+ public void setEnvironments(LinkedList environments) {
+ this.environments = environments;
+ }
+
+ /**
+ * Get the <code>Environment</code> identified by the given name in the
+ * <code>Kalumet</code> container.
+ *
+ * @param name the <code>Environment</code> name.
+ * @return the found <code>Environment</code> or null if no <code>Environment</code> found.
+ */
+ public Environment getEnvironment(String name) {
+ for (Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext();) {
+ Environment environment = (Environment) environmentIterator.next();
+ if (environment.getName().equals(name)) {
+ return environment;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the <code>Environment</code> map order by group.
+ *
+ * @return the groups/environments map.
+ */
+ public Map getEnvironmentsByGroups() {
+ HashMap map = new HashMap();
+ for (Iterator environmentIterator = environments.iterator(); environmentIterator.hasNext();) {
+ Environment current = (Environment) environmentIterator.next();
+ if (!map.containsKey(current.getGroup())) {
+ map.put(current.getGroup(), new LinkedList());
+ }
+ ((List) map.get(current.getGroup())).add(current);
+ }
+ return map;
+ }
+
+ /**
+ * Get the <code>Environment</code> list for a given <code>User</code> id.
+ *
+ * @param userid the <code>User</code> id.
+ * @return the <code>Environment</code> list of the user.
+ */
+ public List getUserEnvironments(String userid) {
+ LinkedList userEnvironments = new LinkedList();
+ Security security = this.getSecurity();
+ for (Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext();) {
+ Environment environment = (Environment) environmentIterator.next();
+ if (security.checkEnvironmentUserAccess(environment, userid, null)) {
+ userEnvironments.add(environment);
+ }
+ }
+ return userEnvironments;
+ }
+
+ /**
+ * Get the <code>Environment</code> user map order by group.
+ *
+ * @param userid the <code>User</code> id.
+ * @return the groups/environments user map.
+ */
+ public Map getUserEnvironmentsByGroups(String userid) {
+ HashMap map = new HashMap();
+ for (Iterator userEnvironmentIterator = this.getUserEnvironments(userid).iterator(); userEnvironmentIterator.hasNext();) {
+ Environment environment = (Environment) userEnvironmentIterator.next();
+ if (!map.containsKey(environment.getGroup())) {
+ map.put(environment.getGroup(), new LinkedList());
+ }
+ ((List) map.get(environment.getGroup())).add(environment);
+ }
+ return map;
+ }
+
+ /**
+ * Get the <code>Environment</code> list for a given <code>Agent</code> id.
+ *
+ * @param id the <code>Agent</code> id.
+ * @return the <code>Environment</code> list managed by the <code>Agent</code>.
+ */
+ public List getEnvironmentsByAgent(String id) {
+ LinkedList list = new LinkedList();
+ for (Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext();) {
+ Environment current = (Environment) environmentIterator.next();
+ if (current.getAgent().equals(id)) {
+ list.add(current);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Digeste a given XML file and return the main kalumet root tag.
+ *
+ * @param path the Kalumet XML file to parse.
+ * @return the main <code>Kalumet</code> corresponding with the root tag.
+ */
+ public static Kalumet digeste(String path) throws KalumetException {
+ if (!path.startsWith("http:") && !path.startsWith("HTTP:") && !path.startsWith("file:") && !path.startsWith("FILE:")) {
+ path = "file:" + path;
+ }
+ Kalumet kalumet = null;
+ try {
+ lock.readLock().acquire();
+
+ // init the digester with no validation on the XML file (no DTD)
+ Digester digester = new Digester();
+ digester.setValidating(false);
+
+ // kalumet tag rules
+ digester.addObjectCreate("kalumet", "org.apache.kalumet.model.Kalumet");
+ digester.addSetProperties("kalumet");
+
+ // properties/property tag rules
+ digester.addObjectCreate("kalumet/properties/property", "org.apache.kalumet.model.Property");
+ digester.addSetProperties("kalumet/properties/property");
+
+ // add property in the kalumet tag rule
+ digester.addSetNext("kalumet/properties/property", "addProperty", "org.apache.kalumet.model.Property");
+
+ // security tag rules
+ digester.addObjectCreate("kalumet/security", "org.apache.kalumet.model.Security");
+ digester.addSetProperties("kalumet/security");
+
+ // user tag rules
+ digester.addObjectCreate("kalumet/security/users/user", "org.apache.kalumet.model.User");
+ digester.addSetProperties("kalumet/security/users/user");
+
+ // add user to security tag rule
+ digester.addSetNext("kalumet/security/users/user", "addUser", "org.apache.kalumet.model.User");
+
+ // group tag rules
+ digester.addObjectCreate("kalumet/security/groups/group", "org.apache.kalumet.model.Group");
+ digester.addSetProperties("kalumet/security/groups/group");
+
+ // user group tag rules
+ digester.addObjectCreate("kalumet/security/groups/group/users/user", "org.apache.kalumet.model.User");
+ digester.addSetProperties("kalumet/security/groups/group/users/user");
+
+ // add user in group tag rule
+ digester.addSetNext("kalumet/security/groups/group/users/user", "addUser", "org.apache.kalumet.model.User");
+
+ // add group to security tag rule
+ digester.addSetNext("kalumet/security/groups/group", "addGroup", "org.apache.kalumet.model.Group");
+
+ // add security to kalumet tag rule
+ digester.addSetNext("kalumet/security", "setSecurity", "org.apache.kalumet.model.Security");
+
+ // agent tag rules
+ digester.addObjectCreate("kalumet/agents/agent", "org.apache.kalumet.model.Agent");
+ digester.addSetProperties("kalumet/agents/agent");
+
+ // add agent to kalumet tag rule
+ digester.addSetNext("kalumet/agents/agent", "addAgent", "org.apache.kalumet.model.Agent");
+
+ // environment tag rules
+ digester.addObjectCreate("kalumet/environments/environment", "org.apache.kalumet.model.Environment");
+ digester.addSetProperties("kalumet/environments/environment");
+
+ // variables tag rules
+ digester.addObjectCreate("kalumet/environments/environment/variables/variable", "org.apache.kalumet.model.Variable");
+ digester.addSetProperties("kalumet/environments/environment/variables/variable");
+
+ // add variable to environment tag rule
+ digester.addSetNext("kalumet/environments/environment/variables/variable", "addVariable", "org.apache.kalumet.model.Variable");
+
+ // freefield tag rules
+ digester.addObjectCreate("kalumet/environments/environment/freefields/freefield", "org.apache.kalumet.model.FreeField");
+ digester.addSetProperties("kalumet/environments/environment/freefields/freefield");
+ // add freefield content
+ digester.addCallMethod("kalumet/environments/environment/freefields/freefield", "setContent", 0);
+
+ // add freefield to environment tag rule
+ digester.addSetNext("kalumet/environments/environment/freefields/freefield", "addFreeField", "org.apache.kalumet.model.FreeField");
+
+ // access tag rules
+ digester.addObjectCreate("kalumet/environments/environment/accesses/access", "org.apache.kalumet.model.Access");
+ digester.addSetProperties("kalumet/environments/environment/accesses/access");
+
+ // access properties rules
+ digester.addObjectCreate("kalumet/environments/environment/accesses/access/properties/property", "org.apache.kalumet.model.Property");
+ digester.addSetProperties("kalumet/environments/environment/accesses/access/properties/property");
+
+ // add property in access tag rule
+ digester.addSetNext("kalumet/environments/environment/accesses/access/properties/property", "addProperty", "org.apache.kalumet.model.Property");
+
+ // add access to environment tag rule
+ digester.addSetNext("kalumet/environments/environment/accesses/access", "addAccess", "org.apache.kalumet.model.Access");
+
+ // environment notes and weblinks tag rules
+ digester.addCallMethod("kalumet/environments/environment/notes", "setNotes", 0);
+ digester.addCallMethod("kalumet/environments/environment/weblinks", "setWeblinks", 0);
+
+ // applicationservers tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers", "org.apache.kalumet.model.ApplicationServers");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers");
+
+ // applicationserver tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver", "org.apache.kalumet.model.ApplicationServer");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver");
+
+ // applicationserver startupcommand and shutdowncommand tag rules
+ digester.addCallMethod("kalumet/environments/environment/applicationservers/applicationserver/startupcommand", "setStartupcommand", 0);
+ digester.addCallMethod("kalumet/environments/environment/applicationservers/applicationserver/shutdowncommand", "setShutdowncommand", 0);
+
+ // connectionpool tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/connectionpools/connectionpool", "org.apache.kalumet.model.ConnectionPool");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/connectionpools/connectionpool");
+
+ // add connectionpool to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/connectionpools/connectionpool", "addConnectionPool", "org.apache.kalumet.model.ConnectionPool");
+
+ // datasource tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/datasources/datasource", "org.apache.kalumet.model.DataSource");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/datasources/datasource");
+
+ // add datasource to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/datasources/datasource", "addDataSource", "org.apache.kalumet.model.DataSource");
+
+ // jmsconnectionfactory tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/jmsconnectionfactories/jmsconnectionfactory", "org.apache.kalumet.model.JMSConnectionFactory");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/jmsconnectionfactories/jmsconnectionfactory");
+
+ // add jmsconnectionfactory to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/jmsconnectionfactories/jmsconnectionfactory", "addJMSConnectionFactory", "org.apache.kalumet.model.JMSConnectionFactory");
+
+ // jmsserver tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver", "org.apache.kalumet.model.JMSServer");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver");
+
+ // jmsqueue tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue", "org.apache.kalumet.model.JMSQueue");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue");
+
+ // add jmsqueue to jmsserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue", "addJMSQueue", "org.apache.kalumet.model.JMSQueue");
+
+ // jmstopic tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver/jmstopics/jmstopic", "org.apache.kalumet.model.JMSTopic");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver/jmstopics/jmstopic");
+
+ // add jmstopic to jmsserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver/jmstopics/jmstopic", "addJMSTopic", "org.apache.kalumet.model.JMSTopic");
+
+ // add jmsserver to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/jmsservers/jmsserver", "addJMSServer", "org.apache.kalumet.model.JMSServer");
+
+ // namespacebinding tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/namespacebindings/namespacebinding", "org.apache.kalumet.model.NameSpaceBinding");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/namespacebindings/namespacebinding");
+
+ // add namespacebinding to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/namespacebindings/namespacebinding", "addNameSpaceBinding", "org.apache.kalumet.model.NameSpaceBinding");
+
+ // sharedlibrary tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/sharedlibrairies/sharedlibrary", "org.apache.kalumet.model.SharedLibrary");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/sharedlibrairies/sharedlibrary");
+
+ // add sharedlibrary to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/sharedlibrairies/sharedlibrary", "addSharedLibrary", "org.apache.kalumet.model.SharedLibrary");
+
+ // application tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application", "org.apache.kalumet.model.Application");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application");
+
+ // archive tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/archives/archive", "org.apache.kalumet.model.Archive");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/archives/archive");
+
+ // add archive archive to application
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/archives/archive", "addArchive", "org.apache.kalumet.model.Archive");
+
+ // contentmanager tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/contentmanagers/contentmanager", "org.apache.kalumet.model.ContentManager");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/contentmanagers/contentmanager");
+
+ // contentmanager property tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/contentmanagers/contentmanager/properties/property", "org.apache.kalumet.model.Property");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/contentmanagers/contentmanager/properties/property");
+
+ // add property in contentmanager
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/contentmanagers/contentmanager/properties/property", "addProperty", "org.apache.kalumet.model.Property");
+
+ // add contentmanager to application
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/contentmanagers/contentmanager", "addContentManager", "org.apache.kalumet.model.ContentManager");
+
+ // configurationfile tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/configurationfiles/configurationfile", "org.apache.kalumet.model.ConfigurationFile");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/configurationfiles/configurationfile");
+
+ // mapping tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/configurationfiles/configurationfile/mappings/mapping", "org.apache.kalumet.model.Mapping");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/configurationfiles/configurationfile/mappings/mapping");
+
+ // add mapping to configurationfile
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/configurationfiles/configurationfile/mappings/mapping", "addMapping", "org.apache.kalumet.model.Mapping");
+
+ // add configurationfile to application
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/configurationfiles/configurationfile", "addConfigurationFile",
+ "org.apache.kalumet.model.ConfigurationFile");
+
+ // database tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database", "org.apache.kalumet.model.Database");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database");
+
+ // sqlscript tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database/sqlscripts/sqlscript", "org.apache.kalumet.model.SqlScript");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database/sqlscripts/sqlscript");
+
+ // sqlscript mapping tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database/sqlscripts/sqlscript/mappings/mapping", "org.apache.kalumet.model.Mapping");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database/sqlscripts/sqlscript/mappings/mapping");
+
+ // add mapping to sqlscript
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database/sqlscripts/sqlscript/mappings/mapping", "addMapping",
+ "org.apache.kalumet.model.Mapping");
+
+ // add sqlscript to database
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database/sqlscripts/sqlscript", "addSqlScript", "org.apache.kalumet.model.SqlScript");
+
+ // add database to application
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application/databases/database", "addDatabase", "org.apache.kalumet.model.Database");
+
+ // add application to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/applications/application", "addApplication", "org.apache.kalumet.model.Application");
+
+ // cache tag rules
+ digester.addObjectCreate("kalumet/environments/environment/applicationservers/applicationserver/caches/cache", "org.apache.kalumet.model.Cache");
+ digester.addSetProperties("kalumet/environments/environment/applicationservers/applicationserver/caches/cache");
+
+ // add cache to applicationserver
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver/caches/cache", "addCache", "org.apache.kalumet.model.Cache");
+
+ // add applicationserver to applicationservers tag rule
+ digester.addSetNext("kalumet/environments/environment/applicationservers/applicationserver", "addApplicationServer", "org.apache.kalumet.model.ApplicationServer");
+
+ // add applicationservers to environment tag rule
+ digester.addSetNext("kalumet/environments/environment/applicationservers", "setApplicationServers", "org.apache.kalumet.model.ApplicationServers");
+
+ // logfile tag rules
+ digester.addObjectCreate("kalumet/environments/environment/logfiles/logfile", "org.apache.kalumet.model.LogFile");
+ digester.addSetProperties("kalumet/environments/environment/logfiles/logfile");
+
+ // add logfile to environment tag rule
+ digester.addSetNext("kalumet/environments/environment/logfiles/logfile", "addLogFile", "org.apache.kalumet.model.LogFile");
+
+ // software tag rules
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software", "org.apache.kalumet.model.Software");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software");
+
+ // software update plan command item
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/command", "org.apache.kalumet.model.Command");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/command");
+ digester.addCallMethod("kalumet/environments/environment/softwares/software/updateplan/command", "setCommand", 0);
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/command", "addCommand", "org.apache.kalumet.model.Command");
+
+ // software update plan location item
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/location", "org.apache.kalumet.model.Location");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/location");
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/location", "addLocation", "org.apache.kalumet.model.Location");
+
+ // software update plan configuration file item
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/configurationfile", "org.apache.kalumet.model.ConfigurationFile");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/configurationfile");
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping", "org.apache.kalumet.model.Mapping");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping");
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping", "addMapping", "org.apache.kalumet.model.Mapping");
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/configurationfile", "addConfigurationFile", "org.apache.kalumet.model.ConfigurationFile");
+
+ // software update plan database item
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/database", "org.apache.kalumet.model.Database");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/database");
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript", "org.apache.kalumet.model.SqlScript");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript");
+ digester.addObjectCreate("kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping", "org.apache.kalumet.model.Mapping");
+ digester.addSetProperties("kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping");
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping", "addMapping", "org.apache.kalumet.model.Mapping");
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript", "addSqlScript", "org.apache.kalumet.model.SqlScript");
+ digester.addSetNext("kalumet/environments/environment/softwares/software/updateplan/database", "addDatabase", "org.apache.kalumet.model.Database");
+
+ // add software to environment
+ digester.addSetNext("kalumet/environments/environment/softwares/software", "addSoftware", "org.apache.kalumet.model.Software");
+
+ // notifiers tag rules
+ digester.addObjectCreate("kalumet/environments/environment/notifiers", "org.apache.kalumet.model.Notifiers");
+ digester.addSetProperties("kalumet/environments/environment/notifiers");
+
+ // email tag rules
+ digester.addObjectCreate("kalumet/environments/environment/notifiers/email", "org.apache.kalumet.model.Email");
+ digester.addSetProperties("kalumet/environments/environment/notifiers/email");
+
+ // destination tag rules
+ digester.addObjectCreate("kalumet/environments/environment/notifiers/email/destinations/destination", "org.apache.kalumet.model.Destination");
+ digester.addSetProperties("kalumet/environments/environment/notifiers/email/destinations/destination");
+
+ // add destination to email notifier
+ digester.addSetNext("kalumet/environments/environment/notifiers/email/destinations/destination", "addDestination", "org.apache.kalumet.model.Destination");
+
+ // add email to notifiers
+ digester.addSetNext("kalumet/environments/environment/notifiers/email", "addNotifier", "org.apache.kalumet.model.Email");
+
+ // add notifiers to environment
+ digester.addSetNext("kalumet/environments/environment/notifiers", "setNotifiers", "org.apache.kalumet.model.Notifiers");
+
+ // email publisher tag rules
+ digester.addObjectCreate("kalumet/environments/environment/publishers/email", "org.apache.kalumet.model.Email");
+ digester.addSetProperties("kalumet/environments/environment/publishers/email");
+
+ // destination email publisher tag rules
+ digester.addObjectCreate("kalumet/environments/environment/publishers/email/destinations/destination", "org.apache.kalumet.model.Destination");
+ digester.addSetProperties("kalumet/environments/environment/publishers/email/destinations/destination");
+
+ // add destination to email publisher
+ digester.addSetNext("kalumet/environments/environment/publishers/email/destinations/destination", "addDestination", "org.apache.kalumet.model.Destination");
+
+ // add email publisher to environment
+ digester.addSetNext("kalumet/environments/environment/publishers/email", "addPublisher", "org.apache.kalumet.model.Email");
+
+ // statistics tag rules
+ digester.addObjectCreate("kalumet/environments/environment/statistics", "org.apache.kalumet.model.Statistics");
+ digester.addSetProperties("kalumet/environments/environment/statistics");
+
+ // add statistics to environment
+ digester.addSetNext("kalumet/environments/environment/statistics", "setStatistics", "org.apache.kalumet.model.Statistics");
+
+ // add environment to kalumet tag rule
+ digester.addSetNext("kalumet/environments/environment", "addEnvironment", "org.apache.kalumet.model.Environment");
+
+ // parse the XML file
+ kalumet = (Kalumet) digester.parse(path);
+ }
+ catch(Exception e) {
+ throw new KalumetException("Can't read Kalumet configuration.", e);
+ } finally {
+ lock.readLock().release();
+ }
+ return kalumet;
+ }
+
+ /**
+ * Transform the <code>Kalumet</code> POJO to a DOM Element.
+ *
+ * @param document the XML core document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "kalumet");
+ // properties element
+ ElementImpl properties = new ElementImpl(document, "properties");
+ // add property in properties container
+ for (Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext();) {
+ Property property = (Property) propertyIterator.next();
+ properties.appendChild(property.toDOMElement(document));
+ }
+ // add properties in kalumet
+ element.appendChild(properties);
+ // add security in kalumet
+ element.appendChild(this.getSecurity().toDOMElement(document));
+ // agents element
+ ElementImpl agents = new ElementImpl(document, "agents");
+ // add agent in agents container
+ for (Iterator agentIterator = this.getAgents().iterator(); agentIterator.hasNext();) {
+ Agent agent = (Agent) agentIterator.next();
+ agents.appendChild(agent.toDOMElement(document));
+ }
+ // add agents in kalumet
+ element.appendChild(agents);
+ // environments element
+ ElementImpl environments = new ElementImpl(document, "environments");
+ // add environment in environments container
+ for (Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext();) {
+ Environment environment = (Environment) environmentIterator.next();
+ environments.appendChild(environment.toDOMElement(document));
+ }
+ // add environments in kalumet
+ element.appendChild(environments);
+ return element;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Kalumet clone = new Kalumet();
+ for (Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); ) {
+ Property property = (Property)propertyIterator.next();
+ clone.properties.add((Property)property.clone());
+ }
+ clone.setSecurity((Security) this.getSecurity().clone());
+ for (Iterator agentIterator = this.agents.iterator(); agentIterator.hasNext(); ) {
+ Agent agent = (Agent)agentIterator.next();
+ clone.agents.add((Agent)agent.clone());
+ }
+ for (Iterator environmentIterator = this.environments.iterator(); environmentIterator.hasNext(); ) {
+ Environment environment = (Environment)environmentIterator.next();
+ clone.environments.add((Environment)environment.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Write a Kalumet XML file with the content of the in-memory
+ * configuration.
+ *
+ * @param path the path to the file to write.
+ * @param backup a flag indicated if a previous backup must be copied before writing.
+ */
+ public synchronized void writeXMLFile(String path, boolean backup) throws KalumetException {
+ if (backup) {
+ this.backupXMLFile(path);
+ }
+ try {
+ lock.writeLock().acquire();
+ OutputFormat format = new OutputFormat();
+ format.setLineWidth(72);
+ format.setIndenting(true);
+ format.setIndent(3);
+ format.setEncoding("ISO-8859-1");
+ if (path.startsWith("http:") || path.startsWith("http:")) {
+ throw new KalumetException("Can't write Kalumet XML file over a HTTP URL.");
+ }
+ if (path.startsWith("file:") || path.startsWith("FILE:")) {
+ path = path.substring(5);
+ }
+ XMLSerializer serializer = new XMLSerializer(new FileOutputStream(path), format);
+ serializer.serialize(this.toDOMElement(new CoreDocumentImpl(true)));
+ }
+ catch (Exception e) {
+ throw new KalumetException("Can't write Kalumet XML file.", e);
+ } finally {
+ lock.writeLock().release();
+ }
+ }
+
+ /**
+ * Write a Kalumet XML file with the content of the in-memory
+ * configuration.
+ *
+ * @param path the path to the file to write.
+ */
+ public void writeXMLFile(String path) throws KalumetException {
+ this.writeXMLFile(path, false);
+ }
+
+ /**
+ * Make a backup of the old Kalumet XML configuration to avoid file
+ * corruption (for example when disk full).
+ *
+ * @param path the path to the Kalumet XML file.
+ */
+ public void backupXMLFile(String path) throws KalumetException {
+ FileManipulator fileManipulator = FileManipulator.getInstance();
+ fileManipulator.copy(path, path + ".backup");
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Location.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Location.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Location.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Location.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * A <code>location</code> is a general wrapper for files and directories.
+ */
+public class Location implements Cloneable, Serializable, Comparable {
+
+ private static final long serialVersionUID = 3632838715316673949L;
+
+ private String name;
+ private boolean active;
+ private boolean blocker;
+ private String uri;
+ private String path;
+ private String agent;
+
+ public Location() { }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Location clone = new Location();
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setName(this.getName());
+ clone.setUri(this.getUri());
+ clone.setPath(this.getPath());
+ clone.setAgent(this.getAgent());
+ return clone;
+ }
+
+ /**
+ * Transform a <code>location</code> into a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ public Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "location");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("uri", this.getUri());
+ element.setAttribute("path", this.getPath());
+ element.setAttribute("agent", this.getAgent());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherLocation) {
+ return this.getName().compareTo(((Location)anotherLocation).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/LogFile.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/LogFile.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/LogFile.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/LogFile.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Define the access to a log file.
+ */
+public class LogFile implements Cloneable, Serializable, Comparable {
+
+ private static final long serialVersionUID = -544824580684870083L;
+
+ private String name;
+ private String path;
+ private String agent;
+
+ public LogFile() {}
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ LogFile logFile = new LogFile();
+ logFile.setAgent(this.getAgent());
+ logFile.setName(this.getName());
+ logFile.setPath(this.getPath());
+ return logFile;
+ }
+
+ /**
+ * Transform a <code>logfile</code> into a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ public Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "logfile");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("path", this.getPath());
+ element.setAttribute("agent", this.getAgent());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherLogFile) {
+ return this.getName().compareTo(((LogFile)anotherLogFile).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Mapping.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Mapping.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Mapping.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Mapping.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>mapping</code> tag in the Kalumet configuration DOM.
+ */
+public class Mapping implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = 6313869273116904013L;
+
+ private String key;
+ private String value;
+
+ public Mapping() { }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Mapping clone = new Mapping();
+ clone.setKey(this.getKey());
+ clone.setValue(this.getValue());
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Mapping</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "mapping");
+ element.setAttribute("key", this.getKey());
+ element.setAttribute("value", this.getValue());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherMapping) {
+ return this.getKey().compareTo(((Mapping)anotherMapping).getKey());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import org.apache.kalumet.KalumetException;
+
+/**
+ * Exception class handler to manage when a model component already exists in
+ * the Kalumet configuration.
+ */
+public final class ModelObjectAlreadyExistsException extends KalumetException {
+
+ private static final long serialVersionUID = -6461646659257275924L;
+
+ /**
+ * Creates a <code>ModelObjectAlreadyExistsException</code> with an explanation message.
+ *
+ * @param message the explanation message.
+ */
+ public ModelObjectAlreadyExistsException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a <code>ModelObjectAlreadyExistsException</code> with the underlying cause.
+ *
+ * @param cause the underlying cause.
+ */
+ public ModelObjectAlreadyExistsException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Creates a <code>ModelObjectAlreadyExistsException</code> with an explanation message and the underlying cause.
+ *
+ * @param message the explanation message.
+ * @param cause the underlying cause.
+ */
+ public ModelObjectAlreadyExistsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/NameSpaceBinding.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/NameSpaceBinding.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/NameSpaceBinding.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/NameSpaceBinding.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>namespacebinding</code> tag in the Kalumet configuration DOM.
+ */
+public class NameSpaceBinding implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -2336476111740231781L;
+
+ private String name;
+ private String jndiname;
+ private String jndialias;
+ private String providerurl;
+ private boolean active;
+ private boolean blocker;
+
+ public NameSpaceBinding() { }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getJndiname() {
+ return this.jndiname;
+ }
+
+ public void setJndiname(String jndiname) {
+ this.jndiname = jndiname;
+ }
+
+ public String getJndialias() {
+ return this.jndialias;
+ }
+
+ public void setJndialias(String jndialias) {
+ this.jndialias = jndialias;
+ }
+
+ public String getProviderurl() {
+ return this.providerurl;
+ }
+
+ public void setProviderurl(String providerurl) {
+ this.providerurl = providerurl;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ NameSpaceBinding clone = new NameSpaceBinding();
+ clone.setName(this.getName());
+ clone.setJndiname(this.getJndiname());
+ clone.setJndialias(this.getJndialias());
+ clone.setProviderurl(this.getProviderurl());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ return clone;
+ }
+
+ /**
+ * Transform the <code>NameSpaceBinding</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "namespacebinding");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("jndiname", this.getJndiname());
+ element.setAttribute("jndialias", this.getJndialias());
+ element.setAttribute("providerurl", this.getProviderurl());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherNameSpaceBinding) {
+ return this.getName().compareTo(((NameSpaceBinding)anotherNameSpaceBinding).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Notifiers.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Notifiers.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Notifiers.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Notifiers.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>notifiers</code> tag in the Kalumet configuration DOM.
+ */
+public class Notifiers implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -5087839972754579270L;
+
+ private int countdown;
+ private LinkedList notifiers;
+
+ public Notifiers() {
+ this.notifiers = new LinkedList();
+ }
+
+ public int getCountdown() {
+ return this.countdown;
+ }
+
+ public void setCountdown(int countdown) {
+ this.countdown = countdown;
+ }
+
+ /**
+ * Add a new <code>Email</code> notifier in the <code>Notifiers</code>
+ * notifiers container.
+ *
+ * @param email the <code>Email</code> to add.
+ */
+ public void addNotifier(Email email) throws ModelObjectAlreadyExistsException {
+ if (this.getNotifier(email.getMailhost()) != null) {
+ throw new ModelObjectAlreadyExistsException("Email notifier mailhost already exists in notifiers.");
+ }
+ this.notifiers.add(email);
+ }
+
+ /**
+ * Get the <code>Email</code> notifier list in the <code>Notifiers</code>
+ * notifiers container.
+ *
+ * @return the <code>Email</code> notifier list.
+ */
+ public List getNotifiers() {
+ return this.notifiers;
+ }
+
+ /**
+ * Set the <code>Email</code> notifier list in the
+ * <code>Notifiers</code> notifiers container.
+ *
+ * @param notifiers the new <code>Email</code> notifier list.
+ */
+ public void setNotifiers(LinkedList notifiers) {
+ this.notifiers = notifiers;
+ }
+
+ /**
+ * Get the <code>Email</code> notifier identified by a given mail host in
+ * the <code>Notifiers</code> notifiers container.
+ *
+ * @param mailhost the <code>Email</code> notifier mail host.
+ * @return the <code>Email</code> found or null if not found.
+ */
+ public Email getNotifier(String mailhost) {
+ for (Iterator notifierIterator = this.getNotifiers().iterator(); notifierIterator.hasNext();) {
+ Email email = (Email) notifierIterator.next();
+ if (email.getMailhost().equals(mailhost)) {
+ return email;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Notifiers clone = new Notifiers();
+ clone.setCountdown(this.getCountdown());
+ for(Iterator notifierIterator = this.notifiers.iterator(); notifierIterator.hasNext(); ) {
+ Email notifier = (Email)notifierIterator.next();
+ clone.notifiers.add((Email)notifier.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Notifiers</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "notifiers");
+ element.setAttribute("countdown", new Integer(this.getCountdown()).toString());
+ // email notifier child nodes
+ for (Iterator notifierIterator = this.getNotifiers().iterator(); notifierIterator.hasNext();) {
+ Email email = (Email) notifierIterator.next();
+ element.appendChild(email.toDOMElement(document));
+ }
+ return element;
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Property.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Property.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Property.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Property.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent a <code>property</code> tag in the Kalumet configuration DOM.
+ */
+public class Property implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -1044229953052391950L;
+
+ private String name;
+ private String value;
+
+ public Property() { }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Property clone = new Property();
+ clone.setName(this.getName());
+ clone.setValue(this.getValue());
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Property</code> POJO to a DOM Element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "property");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("value", this.getValue());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherProperty) {
+ return this.getName().compareTo(((Property)anotherProperty).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Security.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Security.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Security.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Security.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.kalumet.KalumetException;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>security</code> tag in the Kalumet configuration DOM.
+ */
+public class Security implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = 1323976117053191122L;
+
+ private LinkedList users;
+ private LinkedList groups;
+
+ public Security() {
+ this.users = new LinkedList();
+ this.groups = new LinkedList();
+ }
+
+ /**
+ * Add a new <code>User</code> in the <code>Security</code> container.
+ *
+ * @param user the <code>User</code> to add.
+ */
+ public void addUser(User user) throws ModelObjectAlreadyExistsException {
+ if (this.getUser(user.getId()) != null) {
+ throw new ModelObjectAlreadyExistsException("User id already exists in the security user configuration.");
+ }
+ this.users.add(user);
+ }
+
+ /**
+ * Get the <code>User</code> list in the <code>Security</code>
+ * container.
+ *
+ * @return the <code>User</code> list.
+ */
+ public List getUsers() {
+ return this.users;
+ }
+
+ /**
+ * Set the <code>User</code> list in the <code>Security</code>
+ * container.
+ *
+ * @param users the new <code>User</code> list.
+ */
+ public void setUsers(LinkedList users) {
+ this.users = users;
+ }
+
+ /**
+ * Get the <code>User</code> identified by a given id in the
+ * <code>Security</code> container.
+ *
+ * @param id the <code>User</code> id.
+ * @return the found <code>User</code> or null if not found.
+ */
+ public User getUser(String id) {
+ for (Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext();) {
+ User user = (User) userIterator.next();
+ if (user.getId().equals(id)) {
+ return user;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Identify a user.
+ *
+ * @param id the user id.
+ * @param password the user password (in clear).
+ * @return true if the user is identified, false else.
+ */
+ public boolean identifyUser(String id, String password) throws KalumetException {
+ String encryptedPassword = User.md5PasswordCrypt(password);
+ User user = this.getUser(id);
+ if (user == null) {
+ return false;
+ }
+ if (!user.getPassword().equals(encryptedPassword)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Add a new <code>Group</code> in the <code>Security</code> container.
+ *
+ * @param group the <code>Group</code> to add.
+ */
+ public void addGroup(Group group) throws ModelObjectAlreadyExistsException {
+ if (this.getGroup(group.getId()) != null) {
+ throw new ModelObjectAlreadyExistsException("Group id already exists in security definition.");
+ }
+ this.groups.add(group);
+ }
+
+ /**
+ * Get the <code>Group</code> list in the <code>Security</code> container.
+ *
+ * @return the <code>Group</code> list.
+ */
+ public List getGroups() {
+ return this.groups;
+ }
+
+ /**
+ * Set the <code>Group</code> list in the <code>Security</code>
+ * container.
+ *
+ * @param groups the new <code>Group</code>list.
+ */
+ public void setGroups(LinkedList groups) {
+ this.groups = groups;
+ }
+
+ /**
+ * Get a <code>Group</code> identified by a given id in the
+ * <code>Security</code> container.
+ *
+ * @param id the <code>Group</code> id.
+ * @return the found <code>Group</code> or null if not found.
+ */
+ public Group getGroup(String id) {
+ for (Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext();) {
+ Group group = (Group) groupIterator.next();
+ if (group.getId().equals(id)) {
+ return group;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get all groups of a user.
+ *
+ * @param userid the user id.
+ * @return the user groups.
+ */
+ public List getUserGroups(String userid) {
+ if (userid.equals("admin")) {
+ return this.getGroups();
+ }
+ LinkedList userGroups = new LinkedList();
+ for (Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext();) {
+ Group group = (Group) groupIterator.next();
+ if (group.getUser(userid) != null) {
+ userGroups.add(group);
+ }
+ }
+ return userGroups;
+ }
+
+ /**
+ * Check user in group.
+ *
+ * @param userid the user id.
+ * @param groupid the group id.
+ * @return true if the user is a member of the group, false else.
+ */
+ public boolean checkUserInGroup(String userid, String groupid) {
+ if (userid.equals("admin")) {
+ return true;
+ }
+ for (Iterator userGroupIterator = this.getUserGroups(userid).iterator(); userGroupIterator.hasNext();) {
+ Group group = (Group) userGroupIterator.next();
+ if (group.getId().equals(groupid)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if a user has an access to a given environment.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param userid the <code>User</code> id.
+ * @param property the <code>Access</code> property.
+ * @return true if the user has access to the environment, false else.
+ */
+ public boolean checkEnvironmentUserAccess(Environment environment, String userid, String property) {
+ if (this.checkUserInGroup(userid, "admin")) {
+ return true;
+ }
+ for (Iterator accessIterator = environment.getAccesses().iterator(); accessIterator.hasNext();) {
+ Access access = (Access) accessIterator.next();
+ if (property == null) {
+ if (this.checkUserInGroup(userid, access.getGroup())) {
+ return true;
+ }
+ } else {
+ if (access.getProperty(property) != null && access.getProperty(property).getValue().equals("true")) {
+ if (this.checkUserInGroup(userid, access.getGroup())) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Security clone = new Security();
+ for (Iterator userIterator = this.users.iterator(); userIterator.hasNext(); ) {
+ User user = (User)userIterator.next();
+ clone.users.add((User)user.clone());
+ }
+ for (Iterator groupIterator = this.groups.iterator(); groupIterator.hasNext(); ) {
+ Group group = (Group)groupIterator.next();
+ clone.groups.add((Group)group.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Security</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "security");
+ // users element
+ ElementImpl users = new ElementImpl(document, "users");
+ // add user in the users container
+ for (Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext();) {
+ User user = (User) userIterator.next();
+ users.appendChild(user.toDOMElement(document));
+ }
+ // add users in security
+ element.appendChild(users);
+ // groups element
+ ElementImpl groups = new ElementImpl(document, "groups");
+ // add group in the groups container
+ for (Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext();) {
+ Group group = (Group) groupIterator.next();
+ groups.appendChild(group.toDOMElement(document));
+ }
+ // add groups in security
+ element.appendChild(groups);
+ return element;
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>sharedlibrary</code> tag in the Kalumet configuration DOM.
+ */
+public class SharedLibrary implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -16763008144930653L;
+
+ private String name;
+ private String classpath;
+ private boolean active;
+ private boolean blocker;
+
+ public SharedLibrary() { }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getClasspath() {
+ return this.classpath;
+ }
+
+ public void setClasspath(String classpath) {
+ this.classpath = classpath;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ SharedLibrary clone = new SharedLibrary();
+ clone.setName(this.getName());
+ clone.setClasspath(this.getClasspath());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ return clone;
+ }
+
+ /**
+ * Transform the <code>SharedLibrary</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "sharedlibrary");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("classpath", this.getClasspath());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherSharedLibrary) {
+ return this.getName().compareTo(((SharedLibrary)anotherSharedLibrary).getName());
+ }
+
+}
\ No newline at end of file