You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by dd...@apache.org on 2005/07/29 18:43:41 UTC
svn commit: r226395 [5/14] - in /portals/pluto/branches/pluto-1.1: ./
binding/ binding/src/java/org/apache/pluto/binding/
binding/src/java/org/apache/pluto/binding/impl/digester/
binding/src/java/org/apache/pluto/binding/util/ binding/src/resources/org...
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/NamespaceTag.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/NamespaceTag.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/NamespaceTag.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/NamespaceTag.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.tags;
+
+import java.io.IOException;
+
+import javax.portlet.RenderResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.TagSupport;
+
+/**
+ * This tag produces a unique value for the current portlet.
+ * <p/>
+ * <p/>
+ * Supporting class for the <CODE>namespace</CODE> tag. writes a unique value
+ * for the current portlet <BR>This tag has no attributes
+ */
+public class NamespaceTag extends TagSupport {
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.Tag#doStartTag()
+ */
+ public int doStartTag() throws JspException {
+ RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
+ .getAttribute("javax.portlet.response");
+ String namespace = renderResponse.getNamespace();
+ JspWriter writer = pageContext.getOut();
+ try {
+ writer.print(namespace);
+ writer.flush();
+ } catch (IOException ioe) {
+ throw new JspException(
+ "namespace Tag Exception: cannot write to the output writer.");
+ }
+ return SKIP_BODY;
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/ParamTag.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/ParamTag.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/ParamTag.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/ParamTag.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.tags;
+
+import javax.portlet.PortletURL;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+
+/**
+ * Supporting class for the <CODE>param</CODE> tag. Defines a parameter that
+ * can be added to a <CODE>actionURL</CODE> or a <CODE>renderURL</CODE>
+ * <BR>The following attributes are mandatory:
+ * <UL><LI><CODE>name</CODE>
+ * <LI><CODE>value</CODE></UL>
+ */
+public class ParamTag extends TagSupport {
+
+ private String name;
+ private String value;
+
+ /**
+ * Processes the <CODE>param</CODE> tag.
+ * @return <CODE>SKIP_BODY</CODE>
+ */
+ public int doStartTag() throws JspException {
+ BasicURLTag urlTag = (BasicURLTag) findAncestorWithClass(this,
+ BasicURLTag.class);
+ if (urlTag == null) {
+ throw new JspException(
+ "the 'param' Tag must have actionURL or renderURL as a parent");
+ }
+ PortletURL url = urlTag.getUrl();
+
+ if (getName() != null) {
+ url.setParameter(getName(), getValue());
+ }
+
+ return SKIP_BODY;
+ }
+
+ /**
+ * Returns the name.
+ * @return String
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the value.
+ * @return String
+ */
+ public String getValue() {
+ if (value == null) {
+ value = "";
+ }
+ return value;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the value.
+ * @param value The value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/RenderURLTag.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/RenderURLTag.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/RenderURLTag.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/tags/RenderURLTag.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+/*
+ * Created on Feb 21, 2003
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code Template
+ */
+package org.apache.pluto.tags;
+
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+
+/**
+ * Supporting class for the <CODE>renderURL</CODE> tag. Creates a url that
+ * points to the current Portlet and triggers an render request * with the
+ * supplied parameters. *
+ */
+public class RenderURLTag extends BasicURLTag {
+
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.Tag#doStartTag()
+ */
+ public int doStartTag() throws JspException {
+ if (var != null) {
+ pageContext.removeAttribute(var, PageContext.PAGE_SCOPE);
+ }
+ RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
+ .getAttribute("javax.portlet.response");
+
+ if (renderResponse != null) {
+ setUrl(renderResponse.createRenderURL());
+ if (portletMode != null) {
+ try {
+ url.setPortletMode(
+ (PortletMode) TEI.portletModes.get(
+ portletMode.toUpperCase()));
+ } catch (PortletModeException e) {
+ throw new JspException(e);
+ }
+ }
+ if (windowState != null) {
+ try {
+ url.setWindowState(
+ (WindowState) TEI.definedWindowStates.get(
+ windowState.toUpperCase()));
+ } catch (WindowStateException e) {
+ throw new JspException(e);
+ }
+ }
+ if (secure != null) {
+ try {
+ url.setSecure(getSecureBoolean());
+ } catch (PortletSecurityException e) {
+ throw new JspException(e);
+ }
+ }
+ }
+ return EVAL_PAGE;
+ }
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/ArgumentUtility.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/ArgumentUtility.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/ArgumentUtility.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/ArgumentUtility.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,36 @@
+package org.apache.pluto.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Created by IntelliJ IDEA. User: David Date: Jun 3, 2005 Time: 9:26:17 PM To
+ * change this template use File | Settings | File Templates.
+ */
+public class ArgumentUtility {
+
+ public static final Log LOG = LogFactory.getLog(ArgumentUtility.class);
+
+ public static void validateNotNull(String argumentName, Object argument)
+ throws IllegalArgumentException {
+ if(argument == null) {
+ IllegalArgumentException exception =
+ new IllegalArgumentException("Illegal Argument: "+argumentName+". Argument may not be null.");
+ if(LOG.isInfoEnabled()) {
+ LOG.info("Validation Error for argument: "+argumentName+". Argument may not be null.", exception);
+ }
+ throw exception;
+ }
+ }
+
+ public static void validateNotEmpty(String argumentName, String argument) {
+ if(argument == null || "".equals(argument)) {
+ IllegalArgumentException exception =
+ new IllegalArgumentException("Illegal Argument: "+argumentName+". Argument may not be null or empty.");
+ if(LOG.isInfoEnabled()) {
+ LOG.info("Validation Error for argument: "+argumentName+". Argument may not be null or empty.", exception);
+ }
+ throw exception;
+ }
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/Enumerator.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/Enumerator.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/Enumerator.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/Enumerator.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.util;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+
+/**
+ * Uitlity class to wraps an <code>Enumeration</code> around a Collection, i.e.
+ * <code>Iterator</code> classes.
+ */
+
+public final class Enumerator implements Enumeration {
+
+
+ // Iterator over which the Enumeration takes place
+ private Iterator iterator = null;
+
+
+ /**
+ * Returns an Enumeration over the specified Collection.
+ * @param collection Collection with values that should be enumerated
+ */
+ public Enumerator(Collection collection) {
+ this(collection.iterator());
+ }
+
+
+ /**
+ * Returns an Enumeration over the values of the specified Iterator.
+ * @param iterator Iterator to be wrapped
+ */
+ public Enumerator(Iterator iterator) {
+ super();
+ this.iterator = iterator;
+ }
+
+
+ /**
+ * Returns an Enumeration over the values of the specified Map.
+ * @param map Map with values that should be enumerated
+ */
+ public Enumerator(Map map) {
+ this(map.values().iterator());
+ }
+
+
+ /**
+ * Tests if this enumeration contains more elements.
+ * @return <code>true</code> if this enumeration contains at least one more
+ * element to provide, <code>false</code> otherwise.
+ */
+ public boolean hasMoreElements() {
+ return (iterator.hasNext());
+ }
+
+
+ /**
+ * Returns the next element of this enumeration.
+ * @return the next element of this enumeration
+ * @throws NoSuchElementException if no more elements exist
+ */
+ public Object nextElement() throws NoSuchElementException {
+ return (iterator.next());
+ }
+
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.util;
+
+import org.apache.pluto.om.ObjectID;
+
+/**
+ **/
+public interface NamespaceMapper {
+
+
+ public String encode(ObjectID namespace, String name);
+
+ public String encode(ObjectID ns1, ObjectID ns2, String name);
+
+ public String decode(ObjectID ns, String name);
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/PrintWriterServletOutputStream.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/PrintWriterServletOutputStream.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/PrintWriterServletOutputStream.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/PrintWriterServletOutputStream.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.util;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletOutputStream;
+
+/**
+ * This is a specialized class implementing a ServletOutputStream that works in
+ * conjunction with a PrintWriter to send data to the browser. It is used when a
+ * J2EE server throws an IllegalStateException when you call getOutputStream on
+ * a response which someone has previously called getWriter on.
+ */
+public class PrintWriterServletOutputStream extends ServletOutputStream {
+
+ /**
+ * The PrintWriter that is wrapped on top of the base input stream
+ */
+ PrintWriter mPrintWriter;
+
+ /**
+ * Construct a ServletOutputStream that coordinates output using a base
+ * ServletOutputStream and a PrintWriter that is wrapped on top of that
+ * OutputStream.
+ */
+ public PrintWriterServletOutputStream(PrintWriter pO) {
+ super();
+ mPrintWriter = pO;
+ }
+
+ /**
+ * Writes an array of bytes
+ * @param pBuf the array to be written
+ * @throws IOException if an I/O error occurred
+ */
+ public void write(byte[] pBuf) throws IOException {
+ char[] cbuf = new char[pBuf.length];
+ for (int i = 0; i < cbuf.length; i++) {
+ cbuf[i] = (char) (pBuf[i] & 0xff);
+ }
+ mPrintWriter.write(cbuf, 0, pBuf.length);
+ }
+
+ /**
+ * Writes a single byte to the output stream
+ */
+ public void write(int pVal) throws IOException {
+ mPrintWriter.write(pVal);
+ }
+
+ /**
+ * Writes a subarray of bytes
+ * @param pBuf the array to be written
+ * @param pOffset the offset into the array
+ * @param pLength the number of bytes to write
+ * @throws IOException if an I/O error occurred
+ */
+ public void write(byte[] pBuf, int pOffset, int pLength)
+ throws IOException {
+ char[] cbuf = new char[pLength];
+ for (int i = 0; i < pLength; i++) {
+ cbuf[i] = (char) (pBuf[i + pOffset] & 0xff);
+ }
+ mPrintWriter.write(cbuf, 0, pLength);
+ }
+
+ /**
+ * Flushes the stream, writing any buffered output bytes
+ * @throws IOException if an I/O error occurred
+ */
+ public void flush() throws IOException {
+ mPrintWriter.flush();
+ }
+
+ /**
+ * Closes the stream
+ * @throws IOException if an I/O error occurred
+ */
+ public void close() throws IOException {
+ mPrintWriter.close();
+ }
+
+ /**
+ * Prints a string.
+ * @param pVal the String to be printed
+ * @throws IOException if an I/O error has occurred
+ */
+ public void print(String pVal) throws IOException {
+ mPrintWriter.print(pVal);
+ }
+
+ /**
+ * Prints an string followed by a CRLF.
+ * @param pVal the String to be printed
+ * @throws IOException if an I/O error has occurred
+ */
+ public void println(String pVal) throws IOException {
+ mPrintWriter.println(pVal);
+ }
+
+ /**
+ * Prints a CRLF
+ * @throws IOException if an I/O error has occurred
+ */
+ public void println() throws IOException {
+ mPrintWriter.println();
+ }
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringManager.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringManager.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringManager.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringManager.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,243 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+package org.apache.pluto.util;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * An internationalization / localization helper class which reduces the bother
+ * of handling ResourceBundles and takes care of the common cases of message
+ * formating which otherwise require the creation of Object arrays and such.
+ * <p/>
+ * <p>The StringManager operates on a package basis. One StringManager per
+ * package can be created and accessed via the getManager method call.
+ * <p/>
+ * <p>The StringManager will look for a ResourceBundle named by the package name
+ * given plus the suffix of "LocalStrings". In practice, this means that the
+ * localized information will be contained in a LocalStrings.properties file
+ * located in the package directory of the classpath.
+ * <p/>
+ * <p>Please see the documentation for java.util.ResourceBundle for more
+ * information.
+ * @author James Duncan Davidson [duncan@eng.sun.com]
+ * @author James Todd [gonzo@eng.sun.com]
+ */
+
+public class StringManager {
+ private static final Log LOG = LogFactory.getLog(StringManager.class);
+
+ /**
+ * The ResourceBundle for this StringManager.
+ */
+
+ private ResourceBundle bundle;
+
+ /**
+ * Creates a new StringManager for a given package. This is a private method
+ * and all access to it is arbitrated by the static getManager method call
+ * so that only one StringManager per package will be created.
+ * @param packageName Name of package to create StringManager for.
+ */
+
+ private StringManager(String packageName) {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("String Manager Created for package: "+packageName);
+ }
+ String bundleName = packageName + ".LocalStrings";
+ try {
+ bundle = ResourceBundle.getBundle(bundleName);
+ return;
+ } catch (MissingResourceException ex) {
+ // Try from the current loader ( that's the case for trusted apps )
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl != null) {
+ try {
+ bundle =
+ ResourceBundle.getBundle(bundleName, Locale.getDefault(),
+ cl);
+ return;
+ } catch (MissingResourceException ex2) {
+ }
+ }
+ if (cl == null) {
+ cl = this.getClass().getClassLoader();
+ }
+
+ System.out.println("Can't find resource " + bundleName +
+ " " + cl);
+ if (cl instanceof URLClassLoader) {
+ System.out.println(((URLClassLoader) cl).getURLs());
+ }
+ }
+ }
+
+ /**
+ * Get a string from the underlying resource bundle.
+ * @param key The resource name
+ */
+ public String getString(String key) {
+ return MessageFormat.format(getStringInternal(key), null);
+ }
+
+
+ protected String getStringInternal(String key) {
+ if (key == null) {
+ String msg = "key is null";
+
+ throw new NullPointerException(msg);
+ }
+
+ String str = null;
+
+ if (bundle == null) {
+ return key;
+ }
+ try {
+ str = bundle.getString(key);
+ } catch (MissingResourceException mre) {
+ str = "Cannot find message associated with key '" + key + "'";
+ }
+
+ return str;
+ }
+
+ /**
+ * Get a string from the underlying resource bundle and format it with the
+ * given set of arguments.
+ * @param key The resource name
+ * @param args Formatting directives
+ */
+
+ public String getString(String key, Object[] args) {
+ String iString = null;
+ String value = getStringInternal(key);
+
+ // this check for the runtime exception is some pre 1.1.6
+ // VM's don't do an automatic toString() on the passed in
+ // objects and barf out
+
+ try {
+ // ensure the arguments are not null so pre 1.2 VM's don't barf
+ Object nonNullArgs[] = args;
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] == null) {
+ if (nonNullArgs == args) {
+ nonNullArgs =
+ (Object[]) args.clone();
+ }
+ nonNullArgs[i] = "null";
+ }
+ }
+
+ iString = MessageFormat.format(value, nonNullArgs);
+ } catch (IllegalArgumentException iae) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(value);
+ for (int i = 0; i < args.length; i++) {
+ buf.append(" arg[" + i + "]=" + args[i]);
+ }
+ iString = buf.toString();
+ }
+ return iString;
+ }
+
+ /**
+ * Get a string from the underlying resource bundle and format it with the
+ * given object argument. This argument can of course be a String object.
+ * @param key The resource name
+ * @param arg Formatting directive
+ */
+
+ public String getString(String key, Object arg) {
+ Object[] args = new Object[]{arg};
+ return getString(key, args);
+ }
+
+ /**
+ * Get a string from the underlying resource bundle and format it with the
+ * given object arguments. These arguments can of course be String objects.
+ * @param key The resource name
+ * @param arg1 Formatting directive
+ * @param arg2 Formatting directive
+ */
+
+ public String getString(String key, Object arg1, Object arg2) {
+ Object[] args = new Object[]{arg1, arg2};
+ return getString(key, args);
+ }
+
+ /**
+ * Get a string from the underlying resource bundle and format it with the
+ * given object arguments. These arguments can of course be String objects.
+ * @param key The resource name
+ * @param arg1 Formatting directive
+ * @param arg2 Formatting directive
+ * @param arg3 Formatting directive
+ */
+
+ public String getString(String key, Object arg1, Object arg2,
+ Object arg3) {
+ Object[] args = new Object[]{arg1, arg2, arg3};
+ return getString(key, args);
+ }
+
+ /**
+ * Get a string from the underlying resource bundle and format it with the
+ * given object arguments. These arguments can of course be String objects.
+ * @param key The resource name
+ * @param arg1 Formatting directive
+ * @param arg2 Formatting directive
+ * @param arg3 Formatting directive
+ * @param arg4 Formatting directive
+ */
+
+ public String getString(String key, Object arg1, Object arg2,
+ Object arg3, Object arg4) {
+ Object[] args = new Object[]{arg1, arg2, arg3, arg4};
+ return getString(key, args);
+ }
+ // --------------------------------------------------------------
+ // STATIC SUPPORT METHODS
+ // --------------------------------------------------------------
+
+ private static Hashtable managers = new Hashtable();
+
+ /**
+ * Get the StringManager for a particular package. If a manager for a
+ * package already exists, it will be reused, else a new StringManager will
+ * be created and returned.
+ * @param packageName The package name
+ */
+
+ public synchronized static StringManager getManager(String packageName) {
+ StringManager mgr = (StringManager) managers.get(packageName);
+
+ if (mgr == null) {
+ mgr = new StringManager(packageName);
+ managers.put(packageName, mgr);
+ }
+ return mgr;
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * <CODE>StringUtils</CODE> hosts a couple of utility methods around
+ * strings.
+ */
+public class StringUtils {
+
+
+ /**
+ * Replace all occurrences of a pattern within a string by a replacement
+ * @param source The string that should be searched
+ * @param pattern The pattern that should be replaced
+ * @param replace The replacement that should be inserted instead of the
+ * pattern
+ * @return The updated source string
+ */
+ public static String replace(String source, String pattern, String replace) {
+ if (source == null || source.length() == 0 ||
+ pattern == null || pattern.length() == 0) {
+ return source;
+ }
+
+ int k = source.indexOf(pattern);
+
+ if (k == -1) {
+ return source;
+ }
+
+ StringBuffer out = new StringBuffer();
+ int i = 0, l = pattern.length();
+
+ while (k != -1) {
+ out.append(source.substring(i, k));
+
+ if (replace != null) {
+ out.append(replace);
+ }
+
+ i = k + l;
+ k = source.indexOf(pattern, i);
+ }
+ out.append(source.substring(i));
+ return out.toString();
+ }
+
+ public static String[] copy(String[] source) {
+ if (source == null) {
+ return null;
+ }
+ int length = source.length;
+ String[] result = new String[length];
+ System.arraycopy(source, 0, result, 0, length);
+ return result;
+ }
+
+ public static Map copyParameters(Map parameters) {
+ Map result = new HashMap(parameters);
+ for (Iterator iter = result.entrySet().iterator(); iter.hasNext();) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ if (!(entry.getKey() instanceof String)) {
+ throw new IllegalArgumentException(
+ "Parameter map keys must not be null and of type java.lang.String.");
+ }
+ try {
+ entry.setValue(copy((String[]) entry.getValue()));
+ } catch (ClassCastException ex) {
+ throw new IllegalArgumentException(
+ "Parameter map values must not be null and of type java.lang.String[].");
+ }
+ }
+ return result;
+ }
+
+ public static String stringCharacterEncoding(String mimeType) {
+ int xs = mimeType.indexOf(';');
+ String strippedType;
+ if (xs == -1) {
+ strippedType = mimeType;
+ } else {
+ strippedType = mimeType.substring(0,xs);
+ }
+ return strippedType.trim();
+ }
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+/*
+
+ */
+
+package org.apache.pluto.util.impl;
+
+import org.apache.pluto.om.ObjectID;
+import org.apache.pluto.util.NamespaceMapper;
+
+/**
+ **/
+
+public class NamespaceMapperImpl implements NamespaceMapper {
+ public NamespaceMapperImpl() {
+ }
+
+ // org.apache.pluto.util.NamespaceMapper implementation ---------------------------------------
+ public String encode(ObjectID ns, String name) {
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append("Pluto_");
+ buffer.append(ns);
+ buffer.append('_');
+ buffer.append(name);
+ return buffer.toString();
+ }
+
+ public String encode(ObjectID ns1, ObjectID ns2, String name) {
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append("Pluto_");
+ buffer.append(ns1);
+ buffer.append('_');
+ buffer.append(ns2);
+ buffer.append('_');
+ buffer.append(name);
+ return buffer.toString();
+ }
+
+ public String decode(ObjectID ns, String name) {
+ if (!name.startsWith("Pluto_")) {
+ return null;
+ }
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append("Pluto_");
+ buffer.append(ns);
+ buffer.append('_');
+ if (!name.startsWith(buffer.toString())) {
+ return null;
+ }
+ return name.substring(buffer.length());
+ }
+ // --------------------------------------------------------------------------------------------
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/LocalStrings.properties
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/LocalStrings.properties?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/LocalStrings.properties (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/LocalStrings.properties Fri Jul 29 09:40:51 2005
@@ -0,0 +1,19 @@
+
+pluto.container.init=Unable to initialize portlet container {0}
+
+error.load.portlet.xml=Unable to load portlet.xml for context {0} {1}
+
+error.context.descriptor.load
+
+
+####################################
+## Portlet Invocation ##
+####################################
+
+error.portlet.invoke=Unable to successfully invoke portlet. Error during processing.
+error.portlet.invoke.dispatcher=Unable to locate request dispatcher for context {0} and portlet {1}.
+error.portlet.invoke.unavailable=Unable to invoke portlet. Resource {0} unavilable for {1} seconds.
+
+error.config.context.null=Error creating portlet invoker for portlet {0}. Unable to locate context {1}. Check your portlet configuration and ensure cross context dispatching is enabled.
+
+
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties Fri Jul 29 09:40:51 2005
@@ -0,0 +1,13 @@
+
+## PortletModeException caused by Portal
+javax.portlet.PortletModeException.portlet=Portlet mode '{0}' is not supported by the portal.
+
+## PortletModeException caused by Portlet
+javax.portlet.PortletModeException.portal=Portlet mode '{0}' is not supported by the portlet.
+
+## PortletModeException caused by null mode
+javax.portlet.PortletModeException.null=Portlet mode may not be null.
+
+error.contenttype.null=Content Type Not Set
+
+
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/pluto-configuration.properties
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/pluto-configuration.properties?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/pluto-configuration.properties (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/core/pluto-configuration.properties Fri Jul 29 09:40:51 2005
@@ -0,0 +1 @@
+org.apache.pluto.descriptors.services.PortletAppDescriptorService=org.apache.pluto.descriptors.services.castor.PortletAppDescriptorServiceImpl
\ No newline at end of file
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/environment.properties
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/environment.properties?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/environment.properties (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/resources/properties/org/apache/pluto/environment.properties Fri Jul 29 09:40:51 2005
@@ -0,0 +1,7 @@
+pluto.container.name=Pluto
+pluto.container.version.major=1
+pluto.container.version.minor=1.0-ALPHA
+
+javax.portlet.version.major=1
+javax.portlet.version.minor=0
+
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/resources/tld/portlet.tld
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/resources/tld/portlet.tld?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/resources/tld/portlet.tld (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/resources/tld/portlet.tld Fri Jul 29 09:40:51 2005
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE taglib PUBLIC
+ "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
+ "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
+<!--
+Copyright 2004 The Apache Software Foundation
+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.
+-->
+<taglib>
+ <tlibversion>1.0</tlibversion>
+ <jspversion>1.1</jspversion>
+ <shortname>portlet</shortname>
+ <uri>http://java.sun.com/portlet</uri>
+ <tag>
+ <name>defineObjects</name>
+ <tagclass>org.apache.pluto.tags.DefineObjectsTag</tagclass>
+ <teiclass>org.apache.pluto.tags.DefineObjectsTag$TEI</teiclass>
+ <bodycontent>empty</bodycontent>
+ </tag>
+ <tag>
+ <name>param</name>
+ <tagclass>org.apache.pluto.tags.ParamTag</tagclass>
+ <bodycontent>empty</bodycontent>
+ <attribute>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>value</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+ <tag>
+ <name>actionURL</name>
+ <tagclass>org.apache.pluto.tags.ActionURLTag</tagclass>
+ <teiclass>org.apache.pluto.tags.BasicURLTag$TEI</teiclass>
+ <bodycontent>JSP</bodycontent>
+ <attribute>
+ <name>windowState</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>portletMode</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>secure</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+ <tag>
+ <name>renderURL</name>
+ <tagclass>org.apache.pluto.tags.RenderURLTag</tagclass>
+ <teiclass>org.apache.pluto.tags.BasicURLTag$TEI</teiclass>
+ <bodycontent>JSP</bodycontent>
+ <attribute>
+ <name>windowState</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>portletMode</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>secure</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+ <tag>
+ <name>namespace</name>
+ <tagclass>org.apache.pluto.tags.NamespaceTag</tagclass>
+ <bodycontent>empty</bodycontent>
+ </tag>
+</taglib>
\ No newline at end of file
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/core/impl/EnvironmentTest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/core/impl/EnvironmentTest.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/core/impl/EnvironmentTest.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/core/impl/EnvironmentTest.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.pluto.core.impl;
+
+import java.util.Properties;
+
+import org.apache.pluto.util.PlutoTestCase;
+
+/**
+ * Test Class
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since June 1, 2005
+ */
+public class EnvironmentTest extends PlutoTestCase {
+
+ private Properties props;
+
+ public void setUp() throws Exception {
+ props = new Properties();
+ props.load(Environment.class.getResourceAsStream("/org/apache/pluto/environment.properties"));
+ }
+
+ public void testContainerMajorVersion() {
+ assertEquals(props.getProperty("pluto.container.version.major"), Environment.getPortletContainerMajorVersion());
+ }
+
+ public void testContainerMinorVersion() {
+ assertEquals(props.getProperty("pluto.container.version.minor"), Environment.getPortletContainerMinorVersion());
+ }
+
+ public void testContainerName() {
+ assertEquals(props.getProperty("pluto.container.name"), Environment.getPortletContainerName());
+ }
+
+ public void testSpecVersion() {
+ assertEquals(Integer.parseInt(props.getProperty("javax.portlet.version.major")), Environment.getMajorSpecificationVersion());
+ }
+
+ public void testSpecMinorVersion() {
+ assertEquals(Integer.parseInt(props.getProperty("javax.portlet.version.minor")), Environment.getMinorSpecificationVersion());
+ }
+
+ public void testServerInfo() {
+ assertContains("Server Info does not contain container name.", props.getProperty("pluto.container.name"), Environment.getServerInfo());
+ assertContains("Server Info does not contain container name.", props.getProperty("pluto.container.version.major"), Environment.getServerInfo());
+ assertContains("Server Info does not contain container name.", props.getProperty("pluto.container.version.minor"), Environment.getServerInfo());
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/ArgumentUtilityTest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/ArgumentUtilityTest.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/ArgumentUtilityTest.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/ArgumentUtilityTest.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.pluto.util;
+
+
+
+/**
+ * Test Class
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since June 1, 2005
+ */
+public class ArgumentUtilityTest extends PlutoTestCase {
+
+ public void testValidateNotNullWhenNull()
+ throws Exception {
+ Object[] parameters = new Object[] {"arg", null};
+ assertException(new ArgumentUtility(), "validateNotNull",
+ parameters, IllegalArgumentException.class);
+ }
+
+ public void testValidateNotNullWhenNotNull() {
+ ArgumentUtility.validateNotNull("arg", "notnull");
+ }
+
+ public void testValidateNotNullOrEmptyWhenNull() {
+
+ Object[] parameters = new Object[] {"arg", null};
+ Class[] parameterTypes = new Class[] { String.class, String.class };
+ assertException(new ArgumentUtility(), "validateNotEmpty",
+ parameterTypes,
+ parameters, IllegalArgumentException.class);
+ }
+
+ public void testValidateNotNullOrEmptyWhenEmpty() {
+
+ Object[] parameters = new Object[] {"arg", ""};
+ assertException(new ArgumentUtility(), "validateNotEmpty",
+ parameters, IllegalArgumentException.class);
+ }
+
+ public void testValidateNotNullOrEmptyWhenValid() {
+ ArgumentUtility.validateNotEmpty("arg", "notempty");
+ }
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/PlutoTestCase.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/PlutoTestCase.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/PlutoTestCase.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/PlutoTestCase.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.pluto.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * Test Class
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since June 1, 2005
+ */
+public abstract class PlutoTestCase extends MockObjectTestCase {
+
+ public void setUp() throws Exception {
+ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
+ System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "ERROR");
+ }
+
+ protected void assertException(Object target, String methodName,
+ Object[] parameters, Class exceptionType) {
+ Class[] parameterClasses = new Class[parameters.length];
+ for(int i=0;i<parameters.length;i++) {
+ parameterClasses[i] = parameters[i]==null?Object.class:parameters[i].getClass();
+ }
+ assertException(target, methodName, parameterClasses, parameters, exceptionType);
+ }
+
+ protected void assertException(Object target, String methodName,
+ Class[] parameterClasses,
+ Object[] parameters, Class exceptionType) {
+ try {
+ Class targetClass = target.getClass();
+ Method method = targetClass.getMethod(methodName, parameterClasses);
+ method.invoke(target, parameters);
+ }
+ catch(InvocationTargetException ite) {
+ Throwable t = ite.getTargetException();
+ if(!t.getClass().equals(exceptionType)) {
+ fail("Incorrect Exception thrown. Expected: "+exceptionType.getName()+", recieved "+t.getClass().getName());
+ }
+ }
+ catch(Throwable t) {
+ fail("Invalid Test. Reflection invocation and setup failed.");
+ }
+ }
+
+ protected void assertContains(String message, String expectedSubstring,
+ String testString) {
+ if(!testString.contains(expectedSubstring)) {
+ fail(message);
+ }
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.pluto.util;
+
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * Test Class
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since June 1, 2005
+ */
+public class StringUtilsTest extends PlutoTestCase {
+
+ public void testReplaceAtBegin() {
+ assertEquals("ReplacedValue", StringUtils.replace("___lacedValue", "___", "Rep"));
+ }
+
+ public void testReplaceAtEnd() {
+ assertEquals("ReplacedValue", StringUtils.replace("ReplacedVa***", "***", "lue"));
+ }
+
+ public void testReplaceInMiddle() {
+ assertEquals("ReplacedValue", StringUtils.replace("Rep(###)Value", "(###)", "laced"));
+ }
+
+ public void testReplaceMultiples() {
+ assertEquals("ReplacedValueReplacedValue", StringUtils.replace("Rep(###)ValueRep(###)Value", "(###)", "laced"));
+ }
+
+ public void testCopy() {
+ String[] original = new String[] {"one", "two", "three", "four", "five"};
+ String[] results = StringUtils.copy(original);
+ for(int i=0;i<original.length;i++) {
+ assertEquals(original[i], results[i]);
+ }
+ }
+
+ public void testCopyMap() {
+ Map original = new java.util.HashMap();
+ original.put("one", new String[] { "two"});
+ original.put("three", new String[] { "four"});
+ original.put("five", new String[] { "six"});
+ original.put("seven", new String[] { String.valueOf(8), String.valueOf(9) } );
+
+ Map results = StringUtils.copyParameters(original);
+ assertEquals("Map sizes are inconsistent", original.size(), results.size());
+ Iterator it = original.keySet().iterator();
+ while(it.hasNext()) {
+ Object key = it.next();
+ String[] originalValue = (String[])original.get(key);
+ String[] newValue = (String[])results.get(key);
+
+ assertNotNull(originalValue);
+ assertNotNull(newValue);
+ assertEquals(originalValue.length, newValue.length);
+ for(int i=0;i<i++;i++) {
+ assertEquals(originalValue[i], newValue[i]);
+ }
+ }
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,61 @@
+package org.apache.pluto.util.impl;
+
+import org.apache.pluto.util.PlutoTestCase;
+import org.apache.pluto.util.NamespaceMapper;
+import org.apache.pluto.om.ObjectID;
+import junit.framework.Assert;
+
+/**
+ * Test Class
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since June 1, 2005
+ */
+public class NamespaceMapperImplTest extends PlutoTestCase {
+
+ private NamespaceMapper mapper = new NamespaceMapperImpl();
+ private ObjectID id1;
+ private ObjectID id2;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ id1 = new InternalObjectID();
+ id2 = new InternalObjectID();
+ }
+
+ public void testEncodeUniquenessWithSameName() {
+ String mappedA = mapper.encode(id1, "testNumber1");
+ String mappedB = mapper.encode(id2, "testNumber1");
+ assertFalse(mappedA.equals(mappedB));
+ }
+
+ public void testEncodeUniquenessWithSameObjectID() {
+ String mappedA = mapper.encode(id1, "testNumber1");
+ String mappedB = mapper.encode(id1, "testNumber2");
+ assertFalse(mappedA.equals(mappedB));
+ }
+
+ public void testDecode() {
+ String original = "original";
+ String mappedA = mapper.encode(id1, original);
+ assertEquals(original, mapper.decode(id1, mappedA));
+ }
+
+ public void testDecodeInvalidId() {
+ assertNull(mapper.decode(id1, mapper.encode(id2, "test")));
+ }
+
+ private static int objectIDCounter = 1;
+ private class InternalObjectID implements ObjectID {
+ private int id;
+
+ public InternalObjectID() {
+ id = objectIDCounter++;
+ }
+
+ public String toString() {
+ return "uniqueId"+id;
+ }
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/README
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/README?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/README (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/README Fri Jul 29 09:40:51 2005
@@ -0,0 +1,28 @@
+The purpose of the Pluto 1.1 deploy tool is to provide
+the following facilities for portlet development:
+
+1) Ant task with which wars may be created which
+ contain all the necessary resources needed to
+ deploy the webapp as a portlet application
+ within pluto.
+
+ usage: tbd
+
+
+2) [deprecated] These will be replaced with M2 goals
+
+ Maven goal(s) with which wars may be created
+ which contain all of the necessary resources
+ needed to deploy the webapp as a portlet
+ application within pluto.
+
+ usage: maven pluto:assemble -- assembles web application (updates web.xml)
+ maven pluto:deploy -- deploys to configured app server
+
+3) Command line utility with which wars may be
+ updated to contain all of the resources
+ necessary to deploy the webapp as a portlet
+ application within pluto.
+
+ usage: assemble [OPTIONS] warfile|exploded
+ deploy [OPTIONS] warfile|exploded
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/pom.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/pom.xml?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/pom.xml (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/pom.xml Fri Jul 29 09:40:51 2005
@@ -0,0 +1,80 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto-deploy</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1-SNAPSHOT</version>
+ <name>Pluto Deployer</name>
+ <url>http://portals.apache.org/pluto</url>
+ <parent>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto-descriptor-api</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto-descriptor-impl</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-jelly</groupId>
+ <artifactId>commons-jelly</artifactId>
+ <version>1.0-beta-4</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>src/assemble/bin.xml</descriptor>
+ <finalName>pluto-deploy-1.0-SNAPSHOT</finalName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/assemble/bin.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/assemble/bin.xml?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/assemble/bin.xml (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/assemble/bin.xml Fri Jul 29 09:40:51 2005
@@ -0,0 +1,38 @@
+<assembly>
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>tar.bz2</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/bin</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>*.bat</include>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ </dependencySet>
+ </dependencySets>
+</assembly>
+
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/bin/assemble.bat
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/bin/assemble.bat?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/bin/assemble.bat (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/bin/assemble.bat Fri Jul 29 09:40:51 2005
@@ -0,0 +1,27 @@
+@echo off
+
+rem
+rem Copyright 2004 The Apache Software Foundation.
+rem
+rem Licensed under the Apache License, Version 2.0 (the "License");
+rem you may not use this file except in compliance with the License.
+rem You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+set JAVA_CMD=java
+set CLASSPATH=../lib/pluto-deploy-1.1.jar;
+set CLASSPATH=%CLASSPATH%../lib/pluto-binding-1.1.jar;
+set CLASSPATH=%CLASSPATH%../lib/commons-cli-1.0.jar;
+set CLASSPATH=%CLASSPATH%../lib/commons-digester-1.6.jar;
+set CLASSPATH=%CLASSPATH%../lib/commons-beanutils-1.7.0.jar;
+set CLASSPATH=%CLASSPATH%../lib/commons-logging-1.0.4.jar;
+
+java -classpath %CLASSPATH% org.apache.pluto.deploy.cli.AssemblerCLI %1
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Assembler.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Assembler.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Assembler.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Assembler.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy;
+
+import java.io.IOException;
+
+/**
+ * Used to assemble a web application into a portlet application.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 15, 2004
+ */
+public interface Assembler {
+
+ public static final String PORTLET_XML = "WEB-INF/portlet.xml";
+
+ public static final String SERVLET_XML = "WEB-INF/web.xml";
+
+ public static final String DISPATCH_SERVLET_CLASS =
+ "org.apache.pluto.core.PortletServlet";
+
+ /**
+ * Assemble a web applicaiton into a portlet
+ * web application which is deployable into
+ * the pluto-1.1 portlet container. The
+ * specified web application will be overwritten
+ * with the new application.
+ *
+ */
+ public void assemble() throws IOException;
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/AssemblerFactory.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/AssemblerFactory.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/AssemblerFactory.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/AssemblerFactory.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy;
+
+import org.apache.pluto.deploy.impl.ArchivedFileAssembler;
+import org.apache.pluto.deploy.impl.ExplodedFileAssembler;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.jar.JarFile;
+
+/**
+ * <B>TODO</B>: Document
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Nov 8, 2004
+ */
+public class AssemblerFactory {
+
+ private static AssemblerFactory factory;
+
+ private AssemblerFactory() {
+
+ }
+
+ public static AssemblerFactory getFactory() {
+ if(factory == null) {
+ factory = new AssemblerFactory();
+ }
+ return factory;
+ }
+
+ public Assembler createAssembler(File webapp, File destination) {
+ if(webapp.isDirectory()) {
+ return new ExplodedFileAssembler(webapp, destination);
+ }
+ else {
+ try {
+ JarFile war = new JarFile(webapp);
+ return new ArchivedFileAssembler(war, destination);
+ }
+ catch(IOException io) {
+ return null;
+ }
+ }
+
+ }
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Deployer.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Deployer.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Deployer.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/Deployer.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Interface defining the methods necessary to deploy a portlet
+ * application to a servlet container.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 15, 2004
+ */
+public interface Deployer {
+
+ /**
+ * Deploy the specified web application
+ * @param config
+ * @param webapp
+ * @throws IOException
+ */
+ public void deploy(DeploymentConfig config, InputStream webapp)
+ throws IOException, DeploymentException;
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeployerFactory.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeployerFactory.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeployerFactory.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeployerFactory.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy;
+
+/**
+ * <B>TODO</B>: Document
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 28, 2004
+ */
+public class DeployerFactory {
+
+ private static DeployerFactory factory;
+
+ public static DeployerFactory getFactory() {
+ if(factory == null) {
+ factory = new DeployerFactory();
+ }
+ return factory;
+ }
+
+ public Deployer createFactory() {
+ String className = System.getProperty(
+ "org.apache.pluto.deploy.Deployer",
+ "org.apache.pluto.deploy.impl.FileSystemDeployer"
+ );
+
+ try {
+ Class cl = Class.forName(className);
+ return (Deployer)cl.newInstance();
+ }
+ catch(Throwable t) {
+ t.printStackTrace();
+ return null;
+ }
+ }
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentConfig.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentConfig.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentConfig.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentConfig.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy;
+
+/**
+ * Encapsulation of deployment configuration info.
+ * Implementations must provide a way to retrieved
+ * context specific deployment properties.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 15, 2004
+ */
+public abstract class DeploymentConfig {
+
+ /** The deployment name. */
+ private String deploymentName;
+
+ /**
+ * Default Constructor.
+ * @param deploymentName the name of the deployment.
+ */
+ public DeploymentConfig(String deploymentName) {
+ this.deploymentName = deploymentName;
+ }
+
+ /**
+ * Standard Getter.
+ * @return the name of the deployment.
+ */
+ public String getDeploymentName() {
+ return deploymentName;
+ }
+
+ /**
+ * Standard Setter
+ * @param deploymentName the name of the deployment.
+ */
+ public void setDeploymentName(String deploymentName) {
+ this.deploymentName = deploymentName;
+ }
+
+ /**
+ * Retrieve the named deployment property.
+ * @param key
+ * @return
+ */
+ public abstract String getDeploymentProperty(String key);
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentException.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentException.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentException.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/DeploymentException.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy;
+
+/**
+ * Exception thrown if deployment fails due to a configuration
+ * or internal error.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 28, 2004
+ */
+public class DeploymentException extends Exception {
+
+ public DeploymentException(String message) {
+ super(message);
+ }
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/cli/AssemblerCLI.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/cli/AssemblerCLI.java?rev=226395&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/cli/AssemblerCLI.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-deploy/src/main/java/org/apache/pluto/deploy/cli/AssemblerCLI.java Fri Jul 29 09:40:51 2005
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.pluto.deploy.cli;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.pluto.deploy.Assembler;
+import org.apache.pluto.deploy.AssemblerFactory;
+
+/**
+ * Command Line Interface to the Pluto Assembler.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 15, 2004
+ */
+public class AssemblerCLI {
+
+ private Options options;
+ private String[] args;
+
+ public AssemblerCLI(String[] args) {
+ this.args = args;
+ options = new Options();
+ Option destination =
+ new Option("d" , "destination", true,
+ "specify where the resulting webapp should be written ");
+ destination.setArgName("file");
+
+ Option debug =
+ new Option("debug", false, "print debug information.");
+ options.addOption(destination);
+ options.addOption(debug);
+ }
+
+ public void run() throws ParseException, IOException {
+ CommandLineParser parser = new PosixParser();
+ CommandLine line = parser.parse(options, args);
+
+ String[] args = line.getArgs();
+ if(args.length != 1) {
+ abort();
+ return;
+ }
+
+ String dest = line.getOptionValue("file");
+ if(dest == null) {
+ dest = args[0];
+ }
+
+ File source = new File(args[0]);
+ File result = new File(dest);
+ result.getParentFile().mkdirs();
+
+ if(!source.exists()) {
+ System.out.println("File does not exist: "+source.getCanonicalPath());
+ }
+
+
+ System.out.println("-----------------------------------------------");
+ System.out.println("Assembling: "+source.getCanonicalPath());
+ System.out.println(" to: "+result.getCanonicalPath());
+
+ Assembler assembler = AssemblerFactory.getFactory()
+ .createAssembler(new File(args[0]), new File(dest));
+ assembler.assemble();
+
+ System.out.println("Complete!");
+ }
+
+ public void abort() {
+ HelpFormatter help = new HelpFormatter();
+ help.setArgName("webapp");
+ help.setWidth(60);
+ help.printHelp("assemble", options);
+ }
+
+ public static void main(String[] args)
+ throws ParseException, IOException{
+ new AssemblerCLI(args).run();
+ }
+}
+