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 [1/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/...
Author: jbonofre
Date: Sat Oct 22 13:10:01 2011
New Revision: 1187711
URL: http://svn.apache.org/viewvc?rev=1187711&view=rev
Log:
Start the refactoring/renaming of AutoDeploy to Kalumet.
Added:
incubator/kalumet/trunk/BUILDING
incubator/kalumet/trunk/LICENSE
incubator/kalumet/trunk/NOTICE
incubator/kalumet/trunk/README
incubator/kalumet/trunk/RELEASE-NOTES
incubator/kalumet/trunk/common/
incubator/kalumet/trunk/common/NOTICE
incubator/kalumet/trunk/common/common.iml
incubator/kalumet/trunk/common/pom.xml
incubator/kalumet/trunk/common/src/
incubator/kalumet/trunk/common/src/main/
incubator/kalumet/trunk/common/src/main/java/
incubator/kalumet/trunk/common/src/main/java/org/
incubator/kalumet/trunk/common/src/main/java/org/apache/
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulator.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulatorException.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetException.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/WeakFileReference.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Access.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Agent.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Application.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServer.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServers.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Archive.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Cache.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Command.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConnectionPool.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ContentManager.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/DataSource.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Database.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Destination.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Email.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Environment.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/FreeField.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Group.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/JMSConnectionFactory.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/JMSQueue.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/JMSServer.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/JMSTopic.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Kalumet.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Location.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/LogFile.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Mapping.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/NameSpaceBinding.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Notifiers.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Property.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Security.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Software.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/SqlScript.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Statistics.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/User.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Variable.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/AbstractClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/AgentClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/ApplicationClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/ArchiveClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/ClientException.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/CommandClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/ConfigurationFileClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/ConnectionPoolClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/ContentManagerClient.java
incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/ws/client/DatabaseClient.java
incubator/kalumet/trunk/pom.xml
Added: incubator/kalumet/trunk/BUILDING
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/BUILDING?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/BUILDING (added)
+++ incubator/kalumet/trunk/BUILDING Sat Oct 22 13:10:01 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+Apache Kalumet Build Instructions
+=================================
+
+ Getting Source
+ --------------
+To be able to build Apache Kalumet agent, you need to checkout the source code or download the source distribution.
+
+To browse the raw SVN repository, use the following URL:
+
+ http://svn.apache.org/repos/asf/incubator/kalumet/trunk/
+
+You can checkout the source code using the following command:
+
+ svn co http://svn.apache.org/repos/asf/incubator/kalumet/trunk/
+
+ Building
+ --------
+Apache Kalumet uses Maven as its build and management tool.
+You need to download and install Maven 3.0.3 (see http://maven.apache.org for details).
+
+Go into your Apache Kalumet source local copy and run:
+
+ mvn install
Added: incubator/kalumet/trunk/LICENSE
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/LICENSE?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/LICENSE (added)
+++ incubator/kalumet/trunk/LICENSE Sat Oct 22 13:10:01 2011
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
Added: incubator/kalumet/trunk/NOTICE
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/NOTICE?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/NOTICE (added)
+++ incubator/kalumet/trunk/NOTICE Sat Oct 22 13:10:01 2011
@@ -0,0 +1,19 @@
+Apache Kalumet
+Copyright 2011 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+III. License Summary
+- Apache License 2.0
Added: incubator/kalumet/trunk/README
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/README?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/README (added)
+++ incubator/kalumet/trunk/README Sat Oct 22 13:10:01 2011
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+Welcome to Apache Kalumet
+=========================
+Apache Kalumet is a complete deployment platform. It's able to manage all kind of environments (J2EE, OSGi,
+custom, etc).
+It's the perfect tool for softwares, middlewares, and data center administrators.
+It's also a good complement to continuous integration (managed by Maven, Continuum, or Jenkins for instance) by adding
+continuous deployment. The whole factory chain is covered and the administrators manages all environments in a secure
+and safe way.
+
+Apache Kalumet is a small OSGi based kernel which provides a
+lightweight container onto which various bundles can be deployed.
+
+Apache Kalumet provides two components:
+ * the agents are installed locally on the target platform
+ * the console controls and manages the agents, allowing the administrator to manipulate, update, install, deploy
+ the target platform and software components.
+
+Getting Started
+===============
+For an Apache Kalumet source distribution, please read
+BUILDING for instructions on building Apache Kalumet.
+
+ Apache Kalumet Agent
+ ---------------------
+ J2SE 1.6
+Apache Lalumet Agent requires at least a Java 1.6 environment to run.
+Refer to http://java.sun.com for detail on how to download and install J2SE 1.6.
+
+ Uncompress binaries
+Select the Kalumet agent file compression format compatible with your system (zip, tar.gz) by clicking directly on
+the link, download it and expand the binary to your hard drive in a new directory ;
+for example /opt/apache-kalumet-agent - from now on this directory will be referenced as <kalumet_agent_home>.
+Please remember the restrictions concerning illegal characters in Java paths, e.g. !, % etc.
+
+ Start agent
+With Apache Kalumet agent already installed, open a command line console and change directory to <kalumet_agent_home>.
+To start the agent, run the following command in Windows:
+
+ bin\apache-kalumet-agent.bat
+
+respectively in Linux/Unix:
+
+ bin/apache-kalumet-agent
+
+The agent launcher expects some arguments:
+ -config <config> The path/url to the configuration file (e.g. http://<hostname>/kalumet/ConfiugrationWrapper)
+ -id <id> The agent id as defined in the configuration
+
+ Apache Kalumet Console
+ -----------------------
+ JSP/Servlet Engine
+Apache Kalumet console has to be deployed into a JSP/Servlet Engine (like Apache Tomcat or Jetty) or a J2EE application
+server (like RedHat JBoss, Oracle Weblogic, IBM WebSphere).
+
+ Download binaries
+Select the file compression format compatible with your system (zip, tar.gz) by clicking directly on the link,
+download it and expand the binary to your hard drive in a new directory ; for example /tmp/kalumet_console -
+from now on this directory will be referenced as <kalumet_console_home>. Please remember the restrictions concerning
+illegal characters in Java paths, e.g. !, % etc.
+
+ Apache Kalumet Console Configuration
+By default, Apache Kalumet console uses the following configuration:
+- it reads/writes the Kalumet configuration file located in /var/lib/apache-kalumet/conf/autodeploy.xml.
+Create the directory /var/lib/apache-kalumet/conf
+ (with the permission given to the application server user) and copy the initial Kalumet configuration provided in
+ <kalumet_console_home>/conf/sample/apache-kalumet-store.xml.
+- it reads/writes the Kalumet events journal log files in /var/lib/apache-kalumet/journals. Create this directory
+with the permission given to the application server user.
+
+If this default configuration is not compliant with your environment, you can override this setup using a
+apache-kalumet-console-config.xml file.
+
+You can find this file in the Apache Kalumet console configuration in
+<kalumet_console_home>/conf/apache-kalumet-console-config.xml.
+You need to copy this file into the JSP/Servlet engine classpath. For example, using Apache Tomcat, you can
+copy the apache-kalumet-console-config.xml into the <tomcat_home>/lib directory.
+
+Configure the apache-kalumet-console-config.xml to match your environment settings.
+
+ Deploy Apache Kalumet Console
+Copy <kalumet_console_home>/webapp/apache-kalumet-console.war into the JSP/Servlet Engine or J2EE application server
+deploy directory. For example, to deploy on Apache Tomcat, simply copy the war archive into the <tomcat_home>/webapps
+directory.
+
+ Using Apache Kalumet Console
+You should now be able to access to Apache Kalumet console, for example using http://localhost:8080/kalumet/console.
+The default admin user password is admin.
+
+
+Support and Contribution
+========================
+Alternatively, you can also find out how to get started here:
+ http://incubator.apache.org/kalumet/
+
+If you need more help try talking to us on our mailing lists
+ http://incubator.apache.org/kalumet/mailinglists.html
+
+If you find any issues with Apache Kalumet, please submit reports
+with JIRA here:
+ http://issues.apache.org/jira/browse/KALUMET
+
+We welcome contributions, and encourage you to get involved in the
+Kalumet community. If you'd like to learn more about how you can
+contribute, please see:
+ http://incubator.apache.org/kalumet/contributing.html
+
+Many thanks for using Apache Kalumet.
+
+
+The Kalumet Team
\ No newline at end of file
Added: incubator/kalumet/trunk/RELEASE-NOTES
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/RELEASE-NOTES?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/RELEASE-NOTES (added)
+++ incubator/kalumet/trunk/RELEASE-NOTES Sat Oct 22 13:10:01 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+ Apache Kalumet 0.6-incubating
+ =============================
+
+ Overview
+ --------
+
+ The Apache Kalumet 0.6-incubating is the first release since Kalumet has been accepted in the Apache incubator.
+ This release brings new features, improvements and bug fixes. The changelog below contains the whole
+ list of changes.
+
+ Changelog
+ ---------
+
+ The following list shows the bug fixes and enhancements included in this release:
Added: incubator/kalumet/trunk/common/NOTICE
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/NOTICE?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/NOTICE (added)
+++ incubator/kalumet/trunk/common/NOTICE Sat Oct 22 13:10:01 2011
@@ -0,0 +1,19 @@
+Apache Kalumet
+Copyright 2011 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+III. License Summary
+- Apache License 2.0
Added: incubator/kalumet/trunk/common/common.iml
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/common.iml?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/common.iml (added)
+++ incubator/kalumet/trunk/common/common.iml Sat Oct 22 13:10:01 2011
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="Maven: axis:axis:1.4" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.axis:axis-jaxrpc:1.4" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.axis:axis-saaj:1.4" level="project" />
+ <orderEntry type="library" scope="RUNTIME" name="Maven: axis:axis-wsdl4j:1.5.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+ <orderEntry type="library" scope="RUNTIME" name="Maven: commons-discovery:commons-discovery:0.2" level="project" />
+ <orderEntry type="library" name="Maven: concurrent:concurrent:1.3.4" level="project" />
+ <orderEntry type="library" name="Maven: commons-digester:commons-digester:1.8.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.0" level="project" />
+ <orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
+ <orderEntry type="library" name="Maven: commons-vfs:commons-vfs:1.0" level="project" />
+ <orderEntry type="library" name="Maven: oro:oro:2.0.8" level="project" />
+ <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.3" level="project" />
+ <orderEntry type="library" name="Maven: xerces:xercesImpl:2.9.1" level="project" />
+ <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.3.04" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: log4j:log4j:1.2.16" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: org.slf4j:slf4j-log4j12:1.6.3" level="project" />
+ </component>
+</module>
+
Added: incubator/kalumet/trunk/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/pom.xml?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/pom.xml (added)
+++ incubator/kalumet/trunk/common/pom.xml Sat Oct 22 13:10:01 2011
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.kalumet</groupId>
+ <artifactId>kalumet</artifactId>
+ <version>0.6-incubating</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.kalumet.common</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Kalumet :: Common Library</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-vfs</groupId>
+ <artifactId>commons-vfs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulator.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulator.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulator.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulator.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,613 @@
+/*
+ * 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;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.vfs.*;
+import org.apache.kalumet.model.Application;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.Software;
+import org.apache.oro.text.regex.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+
+/**
+ * Virtual file system (VFS) wrapper to perform various actions on files or directories (local or remote).
+ */
+public class FileManipulator {
+
+ private final static transient Logger LOGGER = LoggerFactory.getLogger(FileManipulator.class);
+
+ private static final String BASE_DIR = SystemUtils.USER_DIR;
+ private static final String WORKING_DIR = "work";
+ private static final String PROTOCOL_REGEX = "(.+):(.+)";
+
+ private static final String JAR_EXTENSION = ".jar";
+ private static final String ZIP_EXTENSION = ".zip";
+ private static final String TGZ_EXTENSION = ".tgz";
+ private static final String TARGZ_EXTENSION = ".tar.gz";
+ private static final String TBZ2_EXTENSION = ".tbz2";
+
+ private static final String JAR_PROTOCOL = "jar:";
+ private static final String ZIP_PROTOCOL = "zip:";
+ private static final String TGZ_PROTOCOL = "tgz:";
+ private static final String TARGZ_PROTOCOL = "tgz:";
+ private static final String TBZ2_PROTOCOL = "tbz2:";
+
+ private static FileManipulator _singleton = null;
+ private FileSystemManager fileSystemManager;
+
+ /**
+ * Private constructor to init the singleton.
+ *
+ * @throws FileManipulatorException in <code>FileManipulator</code> init failed.
+ */
+ private FileManipulator() throws FileManipulatorException {
+ try {
+ LOGGER.debug("Creating VFS file system manager ...");
+ this.fileSystemManager = VFS.getManager();
+ // this.fileSystemManager = new StandardFileSystemManager();
+ // fileSystemManager.setCacheStrategy(CacheStrategy.ON_CALL);
+ // fileSystemManager.setReplicator(new KalumetFileReplicator());
+ // fileSystemManager.init();
+ } catch (Exception e) {
+ throw new FileManipulatorException(e);
+ }
+ }
+
+ /**
+ * Get a single instance of the <code>FileManipulator</code>.
+ *
+ * @return the <code>FileManipulator</code> instance.
+ * @throws FileManipulatorException in case of init failure.
+ */
+ public static FileManipulator getInstance() throws FileManipulatorException {
+ try {
+ if (_singleton == null) {
+ _singleton = new FileManipulator();
+ LOGGER.debug("File manipulator initialized");
+ }
+ return _singleton;
+ } catch (Exception e) {
+ LOGGER.error("File manipulator initialization failure", e);
+ throw new FileManipulatorException("File manipulator initialization failure", e);
+ }
+ }
+
+ /**
+ * Get the current basedir path.
+ *
+ * @return the path of the local basedir directory.
+ * @throws FileManipulatorException
+ */
+ public static String getBaseDir() throws FileManipulatorException {
+ try {
+ File baseDir = new File(FileManipulator.BASE_DIR);
+ return baseDir.getPath();
+ } catch (Exception e) {
+ LOGGER.error("Can't get basedir", e);
+ throw new FileManipulatorException("Can't get basedir", e);
+ }
+ }
+
+ /**
+ * Resolve VFS path to add filename regex selector.
+ *
+ * @param vfsPath the file to resolve (can look like /tmp/folder/file*).
+ * @return the resolved file object.
+ * @throws FileSystemException if the VFS file object can't be resolved.
+ * @throws FileManipulatorException if the regex is not valid (regex is allowed only on files, not directories).
+ */
+ public FileObject resolveFile(String vfsPath) throws FileSystemException, FileManipulatorException {
+ LOGGER.debug("Resolve VFS path {}", vfsPath);
+ LOGGER.debug("Check if the file name regex selector is required");
+ if ((vfsPath.indexOf("/") == -1) || (vfsPath.indexOf("*") == -1)) {
+ LOGGER.debug("Regex select is not required for {}", vfsPath);
+ return fileSystemManager.resolveFile(vfsPath);
+ }
+ LOGGER.debug("Isolating the path end");
+ LOGGER.debug("Finding the last index of / separator");
+ int separatorIndex = vfsPath.lastIndexOf('/');
+ int tokenIndex = vfsPath.lastIndexOf('*');
+ if (tokenIndex < separatorIndex) {
+ LOGGER.error("Wildcard * is only supported on the file name, not on directories");
+ throw new FileManipulatorException("Wildcard * is only supported on the file name, not on directories");
+ }
+ String pattern = vfsPath.substring(separatorIndex + 1);
+ LOGGER.debug("{} pattern found", pattern);
+ String baseName = vfsPath.substring(0, separatorIndex + 1);
+ LOGGER.debug("Getting the base name {}", baseName);
+ LOGGER.debug("Looking for the file (first found is returned)");
+ FileObject baseUrl = fileSystemManager.resolveFile(baseName);
+ FileObject[] fileObjects = baseUrl.findFiles(new FileNameRegexSelector(pattern));
+ if (fileObjects.length < 1) {
+ LOGGER.error("No file matching {} found on {}", pattern, baseName);
+ throw new FileManipulatorException("No file matching " + pattern + " found on " + baseName);
+ }
+ return fileObjects[0];
+ }
+
+ /**
+ * Check if the given VFS path is available (exists).
+ *
+ * @param vfsPath the VFS path
+ * @return true if the VFS path exists, false else
+ */
+ public boolean pathAvailable(String vfsPath) {
+ FileObject fileObject = null;
+ try {
+ fileObject = this.resolveFile(vfsPath);
+ return fileObject.exists();
+ } catch (Exception e) {
+ LOGGER.warn("Can't check if the VFS path {} exists", vfsPath, e);
+ return false;
+ } finally {
+ if (fileObject != null) {
+ try {
+ fileObject.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Compare the content of two files.
+ *
+ * @param src the source file to compare.
+ * @param dest the destination file to compare with.
+ * @return true if the two files have exactly the same content, false else.
+ * @throws FileManipulatorException if the compare failed.
+ */
+ public boolean contentEquals(String src, String dest) throws FileManipulatorException {
+ FileObject srcFile = null;
+ FileObject destFile = null;
+ try {
+ LOGGER.debug("Comparing the content of {} and {}", src, dest);
+ srcFile = this.resolveFile(src);
+ destFile = this.resolveFile(dest);
+ if (!srcFile.exists() || !destFile.exists()) {
+ LOGGER.debug("{} or {} don't exist", src, dest);
+ return false;
+ }
+ if (!srcFile.getType().equals(FileType.FILE)) {
+ LOGGER.error("The source {} is not a file", src);
+ throw new IllegalArgumentException("The source URI " + src + " is not a file");
+ }
+ if (!destFile.getType().equals(FileType.FILE)) {
+ LOGGER.error("The destination {} is not a file", dest);
+ throw new IllegalArgumentException("The destination URI " + dest + " is not a file");
+ }
+ return IOUtils.contentEquals(srcFile.getContent().getInputStream(), destFile.getContent().getInputStream());
+ } catch (Exception e) {
+ LOGGER.error("Can't compare content of {} and {}", new Object[]{ src, dest }, e);
+ throw new FileManipulatorException("Can't compare content of " + src + " and " + dest, e);
+ } finally {
+ if (srcFile != null) {
+ try {
+ srcFile.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ if (destFile != null) {
+ try {
+ destFile.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Compare checksum of two files.
+ *
+ * @param src the source file.
+ * @param dest the destination file.
+ * @return true if the two files are the same (same signature), false else.
+ * @throws FileManipulatorException
+ */
+ public boolean checksumEquals(String src, String dest) throws FileManipulatorException {
+ FileObject srcFile = null;
+ FileObject destFile = null;
+ try {
+ if (!srcFile.exists()) {
+ LOGGER.error("Source {} doesn't exist", src);
+ throw new FileManipulatorException("Source " + src + " doesn't exist");
+ }
+ if (destFile.exists() && destFile.getType().equals(FileType.FOLDER)) {
+ destFile = this.resolveFile(dest + "/" + srcFile.getName().getBaseName());
+ }
+ if (!destFile.exists()) {
+ return false;
+ }
+ if (!srcFile.getType().equals(FileType.FILE)) {
+ LOGGER.error("Source {} is not a file", src);
+ throw new FileManipulatorException("Source " + src + " is not a file");
+ }
+ if (!destFile.getType().equals(FileType.FILE)) {
+ LOGGER.error("Destination {} is not a file", dest);
+ throw new FileManipulatorException("Destination " + dest + " is not a file");
+ }
+ LOGGER.debug("Create the message digest");
+ MessageDigest messageDigest = MessageDigest.getInstance("MD5");
+ LOGGER.debug("Generate the checksum for the source");
+ DigestInputStream srcStream = new DigestInputStream(srcFile.getContent().getInputStream(), messageDigest);
+ byte[] srcBuffer = new byte[8192];
+ while (srcStream.read(srcBuffer) != -1) ;
+ byte[] srcMd5 = messageDigest.digest();
+ // reset the message digest
+ messageDigest.reset();
+ LOGGER.debug("Generate the checksum for the destination");
+ DigestInputStream destStream = new DigestInputStream(destFile.getContent().getInputStream(), messageDigest);
+ byte[] destBuffer = new byte[8192];
+ while (destStream.read(destBuffer) != -1) ;
+ byte[] destMd5 = messageDigest.digest();
+ LOGGER.debug("Compare the checksum");
+ return MessageDigest.isEqual(srcMd5, destMd5);
+ } catch (Exception e) {
+ LOGGER.error("Can't compare checksum of {} and {}", new Object[]{ src, dest }, e);
+ throw new FileManipulatorException("Can't compare checksum of " + src + " and " + dest, e);
+ } finally {
+ if (srcFile != null) {
+ try {
+ srcFile.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ if (destFile != null) {
+ try {
+ destFile.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Copy files.
+ *
+ * @param src the source VFS path.
+ * @param dest the destination VFS path.
+ * @throws FileManipulatorException in case of copy failure.
+ */
+ public void copy(String src, String dest) throws FileManipulatorException {
+ FileObject srcFile = null;
+ FileObject destFile = null;
+ try {
+ srcFile = this.resolveFile(src);
+ destFile = this.resolveFile(dest);
+ if (srcFile.getType().equals(FileType.FOLDER)) {
+ LOGGER.debug("Source {} is a folder", src);
+ if (!destFile.exists()) {
+ LOGGER.debug("Destination folder {} doesn't exist, create it", dest);
+ destFile.createFolder();
+ }
+ if (!destFile.getType().equals(FileType.FOLDER)) {
+ LOGGER.error("Destination {} must be a folder", dest);
+ throw new IllegalArgumentException("Destination " + dest + " must be a folder");
+ }
+ LOGGER.debug("Copy source folder {} to {} using SELECT_ALL selector", src, dest);
+ destFile.copyFrom(srcFile, Selectors.SELECT_ALL);
+ } else {
+ LOGGER.debug("Source {} is a file");
+ if (destFile.exists() && destFile.getType().equals(FileType.FOLDER)) {
+ destFile = this.resolveFile(dest + "/" + srcFile.getName().getBaseName());
+ }
+ destFile.copyFrom(srcFile, Selectors.SELECT_SELF);
+ }
+ } catch (Exception e) {
+ LOGGER.error("Can't copy from {} to {}", new Object[]{ src, dest }, e);
+ throw new FileManipulatorException("Can't copy from " + src + " to " + dest, e);
+ } finally {
+ if (srcFile != null) {
+ try {
+ srcFile.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ if (destFile != null) {
+ try {
+ destFile.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if a given path is a directory.
+ *
+ * @param vfsPath the VFS path to check.
+ * @return true if the path is a folder, false else.
+ */
+ public boolean isFolder(String vfsPath) {
+ FileObject file = null;
+ try {
+ file = this.resolveFile(vfsPath);
+ return (file.getType().equals(FileType.FOLDER));
+ } catch (Exception e) {
+ LOGGER.warn("Can't check if {} is a folder", vfsPath, e);
+ } finally {
+ if (file != null) {
+ try {
+ file.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Browse (Return the children) of a give VFS path
+ *
+ * @param vfsPath the VFS path.
+ * @return the children array.
+ */
+ public FileObject[] browse(String vfsPath) {
+ FileObject file = null;
+ try {
+ file = this.resolveFile(vfsPath);
+ if (!file.getType().equals(FileType.FOLDER)) {
+ throw new IllegalArgumentException("{} is not a directory");
+ }
+ return file.getChildren();
+ } catch (Exception e) {
+ LOGGER.warn("Can't get {} children", vfsPath, e);
+ } finally {
+ if (file != null) {
+ try {
+ file.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Read a VFS path and return the input stream content.
+ *
+ * @param vfsPath the VFS path.
+ * @return the input stream content.
+ * @throws FileManipulatorException in case of read failure.
+ */
+ public InputStream read(String vfsPath) throws FileManipulatorException {
+ FileObject file = null;
+ try {
+ file = this.resolveFile(vfsPath);
+ if (!file.exists() || !file.getType().equals(FileType.FILE)) {
+ LOGGER.error("{} doesn't exist or is not a file");
+ throw new IllegalArgumentException(vfsPath + " doesn't exist or is not a file");
+ }
+ return file.getContent().getInputStream();
+ } catch (Exception e) {
+ LOGGER.error("Can't read {}", vfsPath, e);
+ throw new FileManipulatorException("Can't read " + vfsPath, e);
+ }
+ }
+
+ /**
+ * Get the VFS path output stream to write into.
+ *
+ * @param vfsPath the VFS path.
+ * @return the output stream.
+ * @throws FileManipulatorException in case of writing failure.
+ */
+ public OutputStream write(String vfsPath) throws FileManipulatorException {
+ FileObject file = null;
+ try {
+ file = this.resolveFile(vfsPath);
+ if (file.exists() && !file.getType().equals(FileType.FILE)) {
+ LOGGER.error("{} is not a file", vfsPath);
+ throw new IllegalArgumentException(vfsPath + " is not a file");
+ }
+ return file.getContent().getOutputStream();
+ } catch (Exception e) {
+ LOGGER.error("Can't write {}", vfsPath, e);
+ throw new FileManipulatorException("Can't write " + vfsPath, e);
+ }
+ }
+
+ /**
+ * Creates the environment cache directory.
+ *
+ * @param environment the <code>Environment</code>.
+ * @return the environment cache directory path.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public static String createEnvironmentCacheDir(Environment environment) throws FileManipulatorException {
+ String directory = FileManipulator.getBaseDir() + "/" + FileManipulator.WORKING_DIR + "/" + environment.getName();
+ FileManipulator fileManipulator = FileManipulator.getInstance();
+ fileManipulator.createDirectory(directory);
+ return directory;
+ }
+
+ /**
+ * Creates an environment application cache directory.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param application the <code>Application</code>.
+ * @return the environment application cache directory path.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public static String createEnvironmentApplicationCacheDir(Environment environment, Application application) throws FileManipulatorException {
+ String directory = FileManipulator.createEnvironmentCacheDir(environment);
+ directory = directory + "/applications/" + application.getName();
+ FileManipulator fileManipulator = FileManipulator.getInstance();
+ fileManipulator.createDirectory(directory);
+ return directory;
+ }
+
+ /**
+ * Creates an environment software cache directory.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param software the <code>Software</code>.
+ * @return the environment software cache directory path.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public static String createEnvironmentSoftwareCacheDir(Environment environment, Software software) throws FileManipulatorException {
+ String directory = FileManipulator.createEnvironmentCacheDir(environment);
+ directory = directory + "/softwares/" + software.getName();
+ FileManipulator fileManipulator = FileManipulator.getInstance();
+ fileManipulator.createDirectory(directory);
+ return directory;
+ }
+
+ /**
+ * Creates a directory.
+ *
+ * @param path the directory path to create.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public void createDirectory(String path) throws FileManipulatorException {
+ FileObject directory = null;
+ try {
+ directory = this.resolveFile(path);
+ directory.createFolder();
+ } catch (Exception e) {
+ LOGGER.error("Can't create directory {}", path, e);
+ throw new FileManipulatorException("Can't create directory " + path, e);
+ } finally {
+ if (directory != null) {
+ try {
+ directory.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if the given VFS path begins with a protocol (file:, http:, ...).
+ *
+ * @param path the VFS path to check.
+ * @return true
+ */
+ public static boolean protocolExists(String path) {
+ // make a regex on the path
+ LOGGER.debug("Looking for protocol in {}", path);
+ PatternMatcher matcher = new Perl5Matcher();
+ PatternCompiler compiler = new Perl5Compiler();
+ Pattern pattern = null;
+ try {
+ pattern = compiler.compile(FileManipulator.PROTOCOL_REGEX);
+ } catch (MalformedPatternException malformedPatternException) {
+ LOGGER.warn("URL protocol check failed", malformedPatternException);
+ return false;
+ }
+ PatternMatcherInput input = new PatternMatcherInput(path);
+ if (matcher.contains(input, pattern)) {
+ LOGGER.debug("{} matches the protocol regex");
+ return true;
+ }
+ LOGGER.debug("{} doesn't match the protocol regex");
+ return false;
+ }
+
+ /**
+ * Format an URL to a VFS compliant URL (finding the protocol corresponding to the extension).
+ *
+ * @param url source URL
+ * @return the VFS formatted URL.
+ */
+ public static String format(String url) {
+ String formattedUrl = url.trim();
+ if (formattedUrl.endsWith(JAR_EXTENSION) && !formattedUrl.startsWith(JAR_PROTOCOL)) {
+ return JAR_PROTOCOL + formattedUrl;
+ }
+ if (formattedUrl.endsWith(ZIP_EXTENSION) && !formattedUrl.startsWith(ZIP_PROTOCOL)) {
+ return ZIP_PROTOCOL + formattedUrl;
+ }
+ if (formattedUrl.endsWith(TGZ_EXTENSION) && !formattedUrl.startsWith(TGZ_PROTOCOL)) {
+ return TGZ_PROTOCOL + formattedUrl;
+ }
+ if (formattedUrl.endsWith(TARGZ_EXTENSION) && !formattedUrl.startsWith(TARGZ_PROTOCOL)) {
+ return TARGZ_PROTOCOL + formattedUrl;
+ }
+ if (formattedUrl.endsWith(TBZ2_EXTENSION) && !formattedUrl.startsWith(TBZ2_PROTOCOL)) {
+ return TBZ2_PROTOCOL + formattedUrl;
+ }
+ return formattedUrl;
+ }
+
+ /**
+ * Delete a VFS path.
+ *
+ * @param path the VFS path.
+ * @throws FileManipulatorException in case of deletion failure.
+ */
+ public void delete(String path) throws FileManipulatorException {
+ FileObject file = null;
+ try {
+ file = this.resolveFile(path);
+ file.delete(Selectors.SELECT_ALL);
+ } catch (Exception e) {
+ LOGGER.error("Can't delete {}", path, e);
+ throw new FileManipulatorException("Can't delete " + path, e);
+ } finally {
+ if (file != null) {
+ try {
+ file.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Search and replace a regex in a given VFS path.
+ *
+ * @param regex the regexp to search.
+ * @param substitute the replacement string.
+ * @param path the VFS path where to search and replace.
+ */
+ public static void searchAndReplace(String path, String regex, String substitute) {
+ try {
+ String content = FileUtils.readFileToString(new File(path), null);
+ content = StringUtils.replace(content, regex, substitute);
+ FileUtils.writeStringToFile(new File(path), content, null);
+ } catch (IOException ioException) {
+ LOGGER.warn("Can't replace {} with {} in {}", new Object[]{ regex, substitute, path }, ioException);
+ }
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulatorException.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulatorException.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulatorException.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileManipulatorException.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ * Exception wrapper for all file manipulation failures.
+ */
+public class FileManipulatorException extends KalumetException {
+
+ public FileManipulatorException(String message) {
+ super(message);
+ }
+
+ public FileManipulatorException(Throwable cause) {
+ super(cause);
+ }
+
+ public FileManipulatorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileSelectInfo;
+import org.apache.commons.vfs.FileSelector;
+import org.apache.oro.text.GlobCompiler;
+import org.apache.oro.text.regex.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * VFS file selector based on name regex.
+ */
+public class FileNameRegexSelector implements FileSelector {
+
+ private static final transient Logger LOGGER = LoggerFactory.getLogger(FileNameRegexSelector.class);
+
+ private Pattern pattern;
+ private PatternMatcher matcher;
+
+ /**
+ * Default constructor with the matcher pattern.
+ *
+ * @param pattern the file name regex pattern to use.
+ * @throws FileManipulatorException if the regex pattern is malformed.
+ */
+ public FileNameRegexSelector(String pattern) throws FileManipulatorException {
+ LOGGER.debug("Creating the glob regex");
+ PatternCompiler compiler = new GlobCompiler();
+ try {
+ this.pattern = compiler.compile(pattern);
+ this.matcher = new Perl5Matcher();
+ } catch (MalformedPatternException malformedPatternException) {
+ LOGGER.error("Invalid regex pattern " + pattern, malformedPatternException);
+ throw new FileManipulatorException("Invalid regex pattern " + pattern, malformedPatternException);
+ }
+ }
+
+ /**
+ * @see org.apache.commons.vfs.FileSelector#includeFile(org.apache.commons.vfs.FileSelectInfo)
+ */
+ public boolean includeFile(FileSelectInfo fileInfo) {
+ String fileName = fileInfo.getFile().getName().getBaseName();
+ return matcher.matches(fileName, pattern);
+ }
+
+ /**
+ * @see org.apache.commons.vfs.FileSelector#traverseDescendents(org.apache.commons.vfs.FileSelectInfo)
+ */
+ public boolean traverseDescendents(FileSelectInfo fileInfo) {
+ return true;
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetException.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetException.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetException.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetException.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+/**
+ * Generic Kalumet exception wrapper.
+ */
+public class KalumetException extends Exception {
+
+ /**
+ * Create exception with the explanation message.
+ *
+ * @param message the explanation message.
+ */
+ public KalumetException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create exception with the cause.
+ *
+ * @param cause the cause.
+ */
+ public KalumetException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Create exception with the explanation message and the cause.
+ *
+ * @param message the explanation message.
+ * @param cause the cause.
+ */
+ public KalumetException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSelector;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.provider.AbstractVfsComponent;
+import org.apache.commons.vfs.provider.FileReplicator;
+import org.apache.commons.vfs.provider.TemporaryFileStore;
+import org.apache.commons.vfs.provider.UriParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.awt.datatransfer.FlavorEvent;
+import java.io.File;
+import java.lang.ref.ReferenceQueue;
+import java.util.ArrayList;
+
+/**
+ * VFS file replicator to avoid huge space usage in the VFS cache.
+ */
+public class KalumetFileReplicator extends AbstractVfsComponent implements FileReplicator, TemporaryFileStore {
+
+ private final static transient Logger LOGGER = LoggerFactory.getLogger(KalumetFileReplicator.class);
+
+ private final ArrayList<WeakFileReference> copies = new ArrayList<WeakFileReference>();
+ private File tmpDir;
+ private ReferenceQueue queue = new ReferenceQueue();
+ private char[] TMP_RESERVED_CHARS = new char[] { '?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';', ':', '<', '>', '|' };
+
+ /**
+ * Constructor to set the location of the temporary directory.
+ *
+ * @param tmpDir the temporary cache directory.
+ */
+ public KalumetFileReplicator(final File tmpDir) {
+ this.tmpDir = tmpDir;
+ }
+
+ /**
+ * Default constructor.
+ */
+ public KalumetFileReplicator() {
+
+ }
+
+ /**
+ * Initialize the VFS component.
+ *
+ * @throws FileSystemException in case of init failure.
+ */
+ public void init() throws FileSystemException {
+ if (tmpDir == null) {
+ tmpDir = new File("kalumet_cache").getAbsoluteFile();
+ }
+ }
+
+ /**
+ * Close the replication class, deleting all temporary files.
+ */
+ public void close() {
+ // delete the temporary files
+ while (copies.size() > 0) {
+ WeakFileReference fileReference = (WeakFileReference) copies.remove(0);
+ try {
+ File file = new File(fileReference.getPath());
+ FileObject fileObject = getContext().toFileObject(file);
+ fileObject.delete(Selectors.SELECT_ALL);
+ } catch (FileSystemException fileSystemException) {
+ LOGGER.error("Can't delete temporary files", fileSystemException);
+ }
+ }
+ // clean the tmp directory, if it's empty
+ if (tmpDir != null && tmpDir.exists() && tmpDir.list().length == 0) {
+ tmpDir.delete();
+ tmpDir = null;
+ }
+ }
+
+ /**
+ * Allocates a new temporary file.
+ *
+ * @param baseName the file base name.
+ * @return the temporary file.
+ * @throws FileSystemException if the allocation failed.
+ */
+ public File allocateFile(final String baseName) throws FileSystemException {
+ WeakFileReference fileReference = (WeakFileReference) queue.poll();
+ while (fileReference != null) {
+ File toDelete = new File(fileReference.getPath());
+ if (toDelete.exists()) {
+ toDelete.delete();
+ }
+ copies.remove(fileReference);
+ fileReference = (WeakFileReference) queue.poll();
+ }
+ // create the filename
+ final String baseNamePath = createFileName(baseName);
+ final File file = createFile(tmpDir, baseNamePath);
+ // keep track to delete later
+ copies.add(new WeakFileReference(file, queue));
+ return file;
+ }
+
+ /**
+ * Create the temporary file name.
+ *
+ * @param baseName the temporary file base name.
+ * @return the temporary file name.
+ */
+ protected String createFileName(final String baseName) {
+ String safeBaseName = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_');
+ return "tmp_" + safeBaseName;
+ }
+
+ /**
+ * Create a temporary file.
+ *
+ * @param parent the parent file.
+ * @param name the file name.
+ * @return the file.
+ * @throws FileSystemException in case of creation failure.
+ */
+ protected File createFile(final File parent, final String name) throws FileSystemException {
+ return new File(parent, UriParser.decode(name));
+ }
+
+ /**
+ * Create a local (in cache) copy of the file, and all its descendants.
+ *
+ * @param src the source file.
+ * @param selector the file selector.
+ * @return the replicate file.
+ * @throws FileSystemException in case of replication failure.
+ */
+ public File replicateFile(final FileObject src, final FileSelector selector) throws FileSystemException {
+ final String baseName = src.getName().getBaseName();
+ final File file = allocateFile(baseName);
+ // copy from the source file
+ final FileObject dest = getContext().toFileObject(file);
+ dest.copyFrom(src, selector);
+ return file;
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/WeakFileReference.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/WeakFileReference.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/WeakFileReference.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/WeakFileReference.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+
+/**
+ * Managed files by reference.
+ */
+public class WeakFileReference extends WeakReference {
+
+ private String absolutePath;
+
+ /**
+ * Default constructor.
+ *
+ * @param file the file to manage reference.
+ * @param queue the references queue.
+ */
+ public WeakFileReference(File file, ReferenceQueue queue) {
+ super(file, queue);
+ this.absolutePath = file.getAbsolutePath();
+ }
+
+ /**
+ * Gets the absolute path of the file.
+ *
+ * @return the absolute path of the file.
+ */
+ public String getPath() {
+ return this.absolutePath;
+ }
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Access.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Access.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Access.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Access.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,120 @@
+/*
+ * 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;
+
+/**
+ * Represents the <code>access</code> tag in the Kalumet XML DOM.
+ */
+public class Access implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -3233389055334111823L;
+
+ private String group;
+ private List properties;
+
+ public Access() {
+ properties = new LinkedList();
+ }
+
+ public String getGroup() {
+ return this.group;
+ }
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+ public List getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Add a new <code>Property</code> in the <code>Access</code>.
+ *
+ * @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 access.");
+ }
+ this.properties.add(property);
+ }
+
+ /**
+ * Get the <code>Property</code> identified by a given name in the <code>Access</code>.
+ *
+ * @param name the <code>Property</code> name.
+ * @return the <code>Property</code> found or null if no <code>Property</code> found.
+ */
+ public Property getProperty(String name) {
+ for (Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); ) {
+ Property property = (Property) propertyIterator.next();
+ if (property.getName().equals(name)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Access clone = new Access();
+ clone.setGroup(this.getGroup());
+ for (Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); ) {
+ Property property = (Property) propertyIterator.next();
+ clone.properties.add((Property) property.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>Access</code> POJO into a DOM element.
+ *
+ * @param document the core DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "access");
+ element.setAttribute("group", this.getGroup());
+ // properties
+ ElementImpl properties = new ElementImpl(document, "properties");
+ for (Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); ) {
+ Property property = (Property) propertyIterator.next();
+ properties.appendChild(property.toDOMElement(document));
+ }
+ element.appendChild(properties);
+ return element;
+ }
+
+}
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Agent.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Agent.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Agent.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Agent.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;
+
+/**
+ * Represents the <code>agent</code> tag in the Kalumet DOM.
+ */
+public class Agent implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -2827134650188545192L;
+
+ private String id;
+ private String hostname;
+ private int port;
+ private String cron;
+ private int maxenvironments;
+ private int maxapplicationserverssactive;
+
+ public Agent() { }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getHostname() {
+ return this.hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public int getPort() {
+ return this.port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getCron() {
+ return cron;
+ }
+
+ public void setCron(String cron) {
+ this.cron = cron;
+ }
+
+ public int getMaxenvironments() {
+ return this.maxenvironments;
+ }
+
+ public void setMaxenvironments(int maxenvironments) {
+ this.maxenvironments = maxenvironments;
+ }
+
+ public int getMaxapplicationserversactive() {
+ return this.maxapplicationserverssactive;
+ }
+
+ public void setMaxapplicationserversactive(int maxenvironmentsactive) {
+ this.maxapplicationserverssactive = maxenvironmentsactive;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Agent clone = new Agent();
+ clone.setId(this.getId());
+ clone.setHostname(this.getHostname());
+ clone.setPort(this.getPort());
+ clone.setCron(this.getCron());
+ clone.setMaxenvironments(this.getMaxenvironments());
+ clone.setMaxapplicationserversactive(this.getMaxapplicationserversactive());
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>Agent</code> POJO into a DOM element.
+ *
+ * @param document the DOM core document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "agent");
+ element.setAttribute("id", this.getId());
+ element.setAttribute("hostname", this.getHostname());
+ element.setAttribute("port", new Integer(this.getPort()).toString());
+ element.setAttribute("cron", this.getCron());
+ element.setAttribute("maxenvironments", new Integer(this.getMaxenvironments()).toString());
+ element.setAttribute("maxenvironmentsactive", new Integer(this.getMaxapplicationserversactive()).toString());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherAgent) {
+ return this.getId().compareTo(((Agent)anotherAgent).getId());
+ }
+
+}