From: Chad B. <cwb...@us...> - 2008-04-11 22:57:12
|
User: cwbrandon Date: 08/04/11 15:57:13 Modified: andromda-jsf2/components pom.xml Log: typo Revision Changes Path 1.4 +1 -1 cartridges/andromda-jsf2/components/pom.xml Index: pom.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/components/pom.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- pom.xml 11 Apr 2008 22:56:49 -0000 1.3 +++ pom.xml 11 Apr 2008 22:57:12 -0000 1.4 @@ -12,7 +12,7 @@ <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>AndroMDA JSF2 Cartridge Components</name> - <description>Constains custom JSF2 components used by the JSF2 cartridge.</description> + <description>Contains custom JSF2 components used by the JSF2 cartridge.</description> <dependencies> <dependency> <groupId>org.apache.myfaces.core</groupId> |
From: Chad B. <cwb...@us...> - 2008-04-11 22:56:42
|
User: cwbrandon Date: 08/04/11 15:56:49 Added: andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support HttpServletRequestWrapper.java ExtensionsResponseWrapper.java MockHttpServletRequest.java ServletOutputStreamWrapper.java MultipartRequest.java ServletContextWrapper.java HttpServletResponseWrapper.java HttpSessionWrapper.java MultipartPortletRequestWrapper.java andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk AddResource.java ExtensionsPortletFilter.java andromda-jsf2/components pom.xml Log: add jsf2 components (that has some tomahawk portlet specific support at this point). Revision Changes Path 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/HttpServletRequestWrapper.java Index: HttpServletRequestWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.BufferedReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.Principal; import java.util.Enumeration; import java.util.Locale; import java.util.Map; import javax.portlet.PortalContext; import javax.portlet.PortletContext; import javax.portlet.PortletMode; import javax.portlet.PortletPreferences; import javax.portlet.PortletRequest; import javax.portlet.PortletSession; import javax.portlet.WindowState; import javax.servlet.RequestDispatcher; import javax.servlet.ServletInputStream; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** * This class is a dummy HttpServletRequest. * * @author <a href="mailto:shi...@ya...">Shinsuke Sugaya</a> * @author Chad Brandon */ public class HttpServletRequestWrapper implements HttpServletRequest { private PortletRequest portletRequest; private PortletContext portletContext; public HttpServletRequestWrapper( PortletRequest portletRequest, PortletContext portletContext) { this.portletRequest = portletRequest; this.portletContext = portletContext; } public String getAuthType() { return portletRequest.getAuthType(); } public String getContextPath() { return portletRequest.getContextPath(); } public Cookie[] getCookies() { return null; } public long getDateHeader(String dateHeader) { return 0; } public String getHeader(String header) { return null; } public Enumeration getHeaderNames() { return null; } public Enumeration getHeaders(String arg0) { return null; } public int getIntHeader(String arg0) { return 0; } public String getMethod() { return null; } public String getPathInfo() { return null; } public String getPathTranslated() { return null; } public String getQueryString() { return null; } public String getRemoteUser() { return portletRequest.getRemoteUser(); } public String getRequestedSessionId() { return portletRequest.getRequestedSessionId(); } public String getRequestURI() { return null; } public StringBuffer getRequestURL() { return null; } public String getServletPath() { return null; } public HttpSession getSession() { return new HttpSessionWrapper(portletRequest.getPortletSession(), this.portletContext); } public HttpSession getSession(boolean create) { return new HttpSessionWrapper(portletRequest.getPortletSession(create), this.portletContext); } public Principal getUserPrincipal() { return portletRequest.getUserPrincipal(); } public boolean isRequestedSessionIdFromCookie() { return false; } public boolean isRequestedSessionIdFromUrl() { return false; } public boolean isRequestedSessionIdFromURL() { return false; } public boolean isRequestedSessionIdValid() { return portletRequest.isRequestedSessionIdValid(); } public boolean isUserInRole(String arg0) { return portletRequest.isUserInRole(arg0); } public Object getAttribute(String arg0) { return portletRequest.getAttribute(arg0); } public Enumeration getAttributeNames() { return portletRequest.getAttributeNames(); } public String getCharacterEncoding() { return null; } public int getContentLength() { return 0; } public String getContentType() { return null; } public ServletInputStream getInputStream() throws IOException { return null; } public Locale getLocale() { return portletRequest.getLocale(); } public Enumeration getLocales() { return portletRequest.getLocales(); } public String getParameter(String arg0) { return portletRequest.getParameter(arg0); } public Map getParameterMap() { return portletRequest.getParameterMap(); } public Enumeration getParameterNames() { return portletRequest.getParameterNames(); } public String[] getParameterValues(String arg0) { return portletRequest.getParameterValues(arg0); } public String getProtocol() { return null; } public BufferedReader getReader() throws IOException { return null; } public String getRealPath(String arg0) { return null; } public String getRemoteAddr() { return null; } public String getRemoteHost() { return null; } public RequestDispatcher getRequestDispatcher(String arg0) { return null; } public String getScheme() { return portletRequest.getScheme(); } public String getServerName() { return portletRequest.getServerName(); } public int getServerPort() { return portletRequest.getServerPort(); } public boolean isSecure() { return portletRequest.isSecure(); } public void removeAttribute(String arg0) { portletRequest.removeAttribute(arg0); } public void setAttribute(String arg0, Object arg1) { portletRequest.setAttribute(arg0, arg1); } public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException { } public PortalContext getPortalContext() { return portletRequest.getPortalContext(); } public PortletMode getPortletMode() { return portletRequest.getPortletMode(); } public PortletSession getPortletSession() { return portletRequest.getPortletSession(); } public PortletSession getPortletSession(boolean create) { return portletRequest.getPortletSession(create); } public PortletPreferences getPreferences() { return portletRequest.getPreferences(); } public Enumeration getProperties(String arg0) { return portletRequest.getProperties(arg0); } public String getProperty(String arg0) { return portletRequest.getProperty(arg0); } public Enumeration getPropertyNames() { return portletRequest.getPropertyNames(); } public String getResponseContentType() { return portletRequest.getResponseContentType(); } public Enumeration getResponseContentTypes() { return portletRequest.getResponseContentTypes(); } public WindowState getWindowState() { return portletRequest.getWindowState(); } public boolean isPortletModeAllowed(PortletMode portletMode) { return portletRequest.isPortletModeAllowed(portletMode); } public boolean isWindowStateAllowed(WindowState windowState) { return portletRequest.isWindowStateAllowed(windowState); } public int getRemotePort() { return 0; } public String getLocalName() { return null; } public String getLocalAddr() { return null; } public int getLocalPort() { return 0; } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/ExtensionsResponseWrapper.java Index: ExtensionsResponseWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.Locale; import javax.portlet.PortletURL; import javax.portlet.RenderResponse; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; import org.xml.sax.InputSource; /** * @author Sylvain Vieujot (latest modification by $Author: cwbrandon $) * @author Chad Brandon */ public class ExtensionsResponseWrapper extends HttpServletResponseWrapper implements RenderResponse { private ByteArrayOutputStream stream = null; private PrintWriter printWriter = null; private String contentType; private RenderResponse response; public ExtensionsResponseWrapper( HttpServletResponse servletResponse, RenderResponse response) { super(servletResponse); this.response = response; stream = new ByteArrayOutputStream(); } public byte[] getBytes() { return stream.toByteArray(); } public String toString() { try { return this.stream.toString(getCharacterEncoding()); } catch (UnsupportedEncodingException e) { // an attempt to set an invalid character encoding would have caused // this exception before throw new RuntimeException("Response accepted invalid character encoding " + getCharacterEncoding()); } } /** * This method is used by Tomcat. * * @throws IOException */ public PrintWriter getWriter() { if (printWriter == null) { OutputStreamWriter streamWriter = new OutputStreamWriter(this.stream, Charset.forName(getCharacterEncoding())); printWriter = new PrintWriter(streamWriter, true); } return printWriter; } /** * This method is used by Jetty. * * @throws IOException */ public ServletOutputStream getOutputStream() throws IOException { return new MyServletOutputStream(this.stream); } public InputSource getInputSource() { ByteArrayInputStream bais = new ByteArrayInputStream(stream.toByteArray()); return new InputSource(bais); } /** * Prevent content-length being set as the page might be modified. */ public void setContentLength(int contentLength) { } public void setContentType(String contentType) { super.setContentType(contentType); this.contentType = contentType; } public String getContentType() { return contentType; } public void flushBuffer() throws IOException { this.stream.flush(); } public void finishResponse() { try { if (printWriter != null) { printWriter.close(); } else { if (this.stream != null) { this.stream.close(); } } } catch (IOException e) { } } /** * Used in the <code>getOutputStream()</code> method. */ private class MyServletOutputStream extends ServletOutputStream { private OutputStream outputStream; public MyServletOutputStream( OutputStream outputStream) { this.outputStream = outputStream; } public void write(int b) throws IOException { outputStream.write(b); } public void write(byte[] bytes) throws IOException { outputStream.write(bytes); } public void write(byte[] bytes, int off, int len) throws IOException { outputStream.write(bytes, off, len); } } public PortletURL createActionURL() { return this.response.createActionURL(); } public PortletURL createRenderURL() { return this.response.createRenderURL(); } public int getBufferSize() { return this.response.getBufferSize(); } public String getCharacterEncoding() { return this.response.getCharacterEncoding(); } public Locale getLocale() { return this.response.getLocale(); } public String getNamespace() { return this.response.getNamespace(); } public OutputStream getPortletOutputStream() throws IOException { return this.stream; } public boolean isCommitted() { return this.response.isCommitted(); } public void reset() { this.response.reset(); } public void resetBuffer() { this.response.resetBuffer(); } public void setBufferSize(int bufferSize) { this.response.setBufferSize(bufferSize); } public void setTitle(String title) { this.response.setTitle(title); } public void addProperty(String arg0, String arg1) { this.response.addProperty(arg0, arg1); } public String encodeURL(String arg0) { return this.response.encodeURL(arg0); } public void setProperty(String arg0, String arg1) { this.response.setProperty(arg0, arg1); } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/MockHttpServletRequest.java Index: MockHttpServletRequest.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.BufferedReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.Principal; import java.util.Enumeration; import java.util.Locale; import java.util.Map; import javax.servlet.RequestDispatcher; import javax.servlet.ServletInputStream; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; public class MockHttpServletRequest implements HttpServletRequest { public String getAuthType() { return null; } public String getContextPath() { return null; } public Cookie[] getCookies() { return null; } public long getDateHeader(String arg0) { return 0; } public String getHeader(String arg0) { return null; } public Enumeration getHeaderNames() { return null; } public Enumeration getHeaders(String arg0) { return null; } public int getIntHeader(String arg0) { return 0; } public String getMethod() { return null; } public String getPathInfo() { return null; } public String getPathTranslated() { return null; } public String getQueryString() { return null; } public String getRemoteUser() { return null; } public String getRequestURI() { return null; } public StringBuffer getRequestURL() { return null; } public String getRequestedSessionId() { return null; } public String getServletPath() { return null; } public HttpSession getSession() { return null; } public HttpSession getSession(boolean arg0) { return null; } public Principal getUserPrincipal() { return null; } public boolean isRequestedSessionIdFromCookie() { return false; } public boolean isRequestedSessionIdFromURL() { return false; } public boolean isRequestedSessionIdFromUrl() { return false; } public boolean isRequestedSessionIdValid() { return false; } public boolean isUserInRole(String arg0) { return false; } public Object getAttribute(String arg0) { return null; } public Enumeration getAttributeNames() { return null; } public String getCharacterEncoding() { return null; } public int getContentLength() { return 0; } public String getContentType() { return null; } public ServletInputStream getInputStream() throws IOException { return null; } public String getLocalAddr() { return null; } public String getLocalName() { return null; } public int getLocalPort() { return 0; } public Locale getLocale() { return null; } public Enumeration getLocales() { return null; } public String getParameter(String arg0) { return null; } public Map getParameterMap() { return null; } public Enumeration getParameterNames() { return null; } public String[] getParameterValues(String arg0) { return null; } public String getProtocol() { return null; } public BufferedReader getReader() throws IOException { return null; } public String getRealPath(String arg0) { return null; } public String getRemoteAddr() { return null; } public String getRemoteHost() { return null; } public int getRemotePort() { return 0; } public RequestDispatcher getRequestDispatcher(String arg0) { return null; } public String getScheme() { return null; } public String getServerName() { return null; } public int getServerPort() { return 0; } public boolean isSecure() { return false; } public void removeAttribute(String arg0) { } public void setAttribute(String arg0, Object arg1) { } public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException { } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/ServletOutputStreamWrapper.java Index: ServletOutputStreamWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.CharConversionException; import java.io.IOException; import java.io.OutputStream; import java.text.MessageFormat; import javax.servlet.ServletOutputStream; /** * This class is a dummy ServletOutputStream. * * @author <a href="mailto:shi...@ya...">Shinsuke Sugaya</a> * */ public class ServletOutputStreamWrapper extends ServletOutputStream { private OutputStream outputStream; public ServletOutputStreamWrapper(OutputStream outputStream) { this.outputStream = outputStream; } /** * Writes a <code>String</code> to the client, without a carriage * return-line feed (CRLF) character at the end. * * * @param s * the <code>String</code> to send to the client * * @exception IOException * if an input or output exception occurred * */ public void print(String s) throws IOException { if (s == null) s = "null"; int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); // // XXX NOTE: This is clearly incorrect for many strings, // but is the only consistent approach within the current // servlet framework. It must suffice until servlet output // streams properly encode their output. // if ((c & 0xff00) != 0) { // high order byte must be zero String errMsg = "Not an ISO 8859-1 character: {0}"; Object[] errArgs = new Object[1]; errArgs[0] = new Character(c); errMsg = MessageFormat.format(errMsg, errArgs); throw new CharConversionException(errMsg); } write(c); } } /** * Writes a <code>boolean</code> value to the client, with no carriage * return-line feed (CRLF) character at the end. * * @param b * the <code>boolean</code> value to send to the client * * @exception IOException * if an input or output exception occurred * */ public void print(boolean b) throws IOException { String msg; if (b) { msg = "true"; } else { msg = "false"; } print(msg); } /** * Writes a character to the client, with no carriage return-line feed * (CRLF) at the end. * * @param c * the character to send to the client * * @exception IOException * if an input or output exception occurred * */ public void print(char c) throws IOException { print(String.valueOf(c)); } /** * * Writes an int to the client, with no carriage return-line feed (CRLF) at * the end. * * @param i * the int to send to the client * * @exception IOException * if an input or output exception occurred * */ public void print(int i) throws IOException { print(String.valueOf(i)); } /** * * Writes a <code>long</code> value to the client, with no carriage * return-line feed (CRLF) at the end. * * @param l * the <code>long</code> value to send to the client * * @exception IOException * if an input or output exception occurred * */ public void print(long l) throws IOException { print(String.valueOf(l)); } /** * * Writes a <code>float</code> value to the client, with no carriage * return-line feed (CRLF) at the end. * * @param f * the <code>float</code> value to send to the client * * @exception IOException * if an input or output exception occurred * * */ public void print(float f) throws IOException { print(String.valueOf(f)); } /** * * Writes a <code>double</code> value to the client, with no carriage * return-line feed (CRLF) at the end. * * @param d * the <code>double</code> value to send to the client * * @exception IOException * if an input or output exception occurred * */ public void print(double d) throws IOException { print(String.valueOf(d)); } /** * Writes a carriage return-line feed (CRLF) to the client. * * * * @exception IOException * if an input or output exception occurred * */ public void println() throws IOException { print("\r\n"); } /** * Writes a <code>String</code> to the client, followed by a carriage * return-line feed (CRLF). * * * @param s * the <code>String</code> to write to the client * * @exception IOException * if an input or output exception occurred * */ public void println(String s) throws IOException { print(s); println(); } /** * * Writes a <code>boolean</code> value to the client, followed by a * carriage return-line feed (CRLF). * * * @param b * the <code>boolean</code> value to write to the client * * @exception IOException * if an input or output exception occurred * */ public void println(boolean b) throws IOException { print(b); println(); } /** * * Writes a character to the client, followed by a carriage return-line feed * (CRLF). * * @param c * the character to write to the client * * @exception IOException * if an input or output exception occurred * */ public void println(char c) throws IOException { print(c); println(); } /** * * Writes an int to the client, followed by a carriage return-line feed * (CRLF) character. * * * @param i * the int to write to the client * * @exception IOException * if an input or output exception occurred * */ public void println(int i) throws IOException { print(i); println(); } /** * * Writes a <code>long</code> value to the client, followed by a carriage * return-line feed (CRLF). * * * @param l * the <code>long</code> value to write to the client * * @exception IOException * if an input or output exception occurred * */ public void println(long l) throws IOException { print(l); println(); } /** * * Writes a <code>float</code> value to the client, followed by a carriage * return-line feed (CRLF). * * @param f * the <code>float</code> value to write to the client * * * @exception IOException * if an input or output exception occurred * */ public void println(float f) throws IOException { print(f); println(); } /** * * Writes a <code>double</code> value to the client, followed by a * carriage return-line feed (CRLF). * * * @param d * the <code>double</code> value to write to the client * * @exception IOException * if an input or output exception occurred * */ public void println(double d) throws IOException { print(d); println(); } /* * (non-Javadoc) * * @see java.io.OutputStream#write(int) */ public void write(int b) throws IOException { outputStream.write(b); } /* * (non-Javadoc) * * @see java.io.OutputStream#close() */ public void close() throws IOException { outputStream.close(); } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { return outputStream.equals(obj); } /* * (non-Javadoc) * * @see java.io.OutputStream#flush() */ public void flush() throws IOException { outputStream.flush(); } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ public int hashCode() { return outputStream.hashCode(); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ public String toString() { return outputStream.toString(); } /* * (non-Javadoc) * * @see java.io.OutputStream#write(byte[], int, int) */ public void write(byte[] b, int off, int len) throws IOException { outputStream.write(b, off, len); } /* * (non-Javadoc) * * @see java.io.OutputStream#write(byte[]) */ public void write(byte[] b) throws IOException { outputStream.write(b); } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/MultipartRequest.java Index: MultipartRequest.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.util.Map; import org.apache.commons.fileupload.FileItem; /** * This interface handles the multpart request for inputFileUpload components. * * @author <a href="mailto:shi...@ya...">Shinsuke Sugaya</a> */ public interface MultipartRequest { // Hook for the t:inputFileUpload tag. public abstract FileItem getFileItem(String fieldName); /** * Not used internaly by MyFaces, but provides a way to handle the uploaded * files out of MyFaces. */ public abstract Map getFileItems(); } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/ServletContextWrapper.java Index: ServletContextWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.Enumeration; import java.util.Set; import javax.portlet.PortletContext; import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; import javax.servlet.ServletContext; import javax.servlet.ServletException; public class ServletContextWrapper implements ServletContext { private PortletContext portletContext; public ServletContextWrapper(PortletContext portletContext) { this.portletContext = portletContext; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getAttribute(java.lang.String) */ public Object getAttribute(String arg0) { return portletContext.getAttribute(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getAttributeNames() */ public Enumeration getAttributeNames() { return portletContext.getAttributeNames(); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getContext(java.lang.String) */ public ServletContext getContext(String arg0) { // TODO Portlet API does not have this method return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getInitParameter(java.lang.String) */ public String getInitParameter(String arg0) { return portletContext.getInitParameter(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getInitParameterNames() */ public Enumeration getInitParameterNames() { return portletContext.getInitParameterNames(); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getMajorVersion() */ public int getMajorVersion() { return portletContext.getMajorVersion(); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getMimeType(java.lang.String) */ public String getMimeType(String arg0) { return portletContext.getMimeType(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getMinorVersion() */ public int getMinorVersion() { return portletContext.getMinorVersion(); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String) */ public RequestDispatcher getNamedDispatcher(String arg0) { // TODO Portlet API does not have this method return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getRealPath(java.lang.String) */ public String getRealPath(String arg0) { return portletContext.getRealPath(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String) */ public RequestDispatcher getRequestDispatcher(String arg0) { // TODO Portlet API does not have this method return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getResource(java.lang.String) */ public URL getResource(String arg0) throws MalformedURLException { return portletContext.getResource(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String) */ public InputStream getResourceAsStream(String arg0) { return portletContext.getResourceAsStream(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String) */ public Set getResourcePaths(String arg0) { return portletContext.getResourcePaths(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getServerInfo() */ public String getServerInfo() { return portletContext.getServerInfo(); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getServlet(java.lang.String) */ public Servlet getServlet(String arg0) throws ServletException { // TODO Portlet API does not have this method return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getServletContextName() */ public String getServletContextName() { return portletContext.getPortletContextName(); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getServletNames() */ public Enumeration getServletNames() { // TODO Portlet API does not have this method return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#getServlets() */ public Enumeration getServlets() { // TODO Portlet API does not have this method return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#log(java.lang.Exception, * java.lang.String) */ public void log(Exception arg0, String arg1) { portletContext.log(arg1, new Exception(arg0)); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#log(java.lang.String, * java.lang.Throwable) */ public void log(String arg0, Throwable arg1) { portletContext.log(arg0, arg1); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#log(java.lang.String) */ public void log(String arg0) { portletContext.log(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#removeAttribute(java.lang.String) */ public void removeAttribute(String arg0) { portletContext.removeAttribute(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletContext#setAttribute(java.lang.String, * java.lang.Object) */ public void setAttribute(String arg0, Object arg1) { portletContext.setAttribute(arg0, arg1); } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/HttpServletResponseWrapper.java Index: HttpServletResponseWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Locale; import javax.portlet.PortletURL; import javax.portlet.RenderResponse; import javax.servlet.ServletOutputStream; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; /** * This class is a dummy HttpServletResponse. * * @author <a href="mailto:shi...@ya...">Shinsuke Sugaya</a> */ public class HttpServletResponseWrapper implements HttpServletResponse, RenderResponse { private RenderResponse renderResponse; public HttpServletResponseWrapper( RenderResponse renderResponse) { this.renderResponse = renderResponse; } /* * (non-Javadoc) * * @see javax.servlet.ServletResponseWrapper#getWriter() */ public PrintWriter getWriter() throws IOException { return this.renderResponse.getWriter(); } /** * Returns writer to which MyFaces' AddResource stores elements. * * @return writer which has elements, such as <script> and * <link> public StringWriter getStringWriter() { return * (StringWriter) writer; } */ /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#flushBuffer() */ public void flushBuffer() throws IOException { if (renderResponse != null) { renderResponse.flushBuffer(); } } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#getBufferSize() */ public int getBufferSize() { if (renderResponse != null) { return renderResponse.getBufferSize(); } return 0; } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#getCharacterEncoding() */ public String getCharacterEncoding() { if (renderResponse != null) { return renderResponse.getCharacterEncoding(); } return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#getLocale() */ public Locale getLocale() { if (renderResponse != null) { return renderResponse.getLocale(); } return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#getOutputStream() */ public ServletOutputStream getOutputStream() throws IOException { if (renderResponse != null) { return new ServletOutputStreamWrapper(renderResponse.getPortletOutputStream()); } return null; } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#isCommitted() */ public boolean isCommitted() { if (renderResponse != null) { return renderResponse.isCommitted(); } return false; } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#reset() */ public void reset() { if (renderResponse != null) { renderResponse.reset(); } } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#resetBuffer() */ public void resetBuffer() { if (renderResponse != null) { renderResponse.resetBuffer(); } } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#setBufferSize(int) */ public void setBufferSize(int arg0) { renderResponse.setBufferSize(arg0); } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#setContentLength(int) */ public void setContentLength(int arg0) { } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#setContentType(java.lang.String) */ public void setContentType(String arg0) { if (renderResponse != null) { renderResponse.setContentType(arg0); } } /* * (non-Javadoc) * * @see javax.servlet.ServletResponse#setLocale(java.util.Locale) */ public void setLocale(Locale arg0) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie) */ public void addCookie(Cookie arg0) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String, * long) */ public void addDateHeader(String arg0, long arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, * java.lang.String) */ public void addHeader(String arg0, String arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String, * int) */ public void addIntHeader(String arg0, int arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String) */ public boolean containsHeader(String arg0) { return false; } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#encodeRedirectUrl(java.lang.String) */ public String encodeRedirectUrl(String arg0) { return null; } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String) */ public String encodeRedirectURL(String arg0) { return null; } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#encodeUrl(java.lang.String) */ public String encodeUrl(String arg0) { if (renderResponse != null) { return renderResponse.encodeURL(arg0); } return null; } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) */ public String encodeURL(String arg0) { return renderResponse.encodeURL(arg0); } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#sendError(int, * java.lang.String) */ public void sendError(int arg0, String arg1) throws IOException { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#sendError(int) */ public void sendError(int arg0) throws IOException { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String) */ public void sendRedirect(String arg0) throws IOException { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String, * long) */ public void setDateHeader(String arg0, long arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, * java.lang.String) */ public void setHeader(String arg0, String arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String, * int) */ public void setIntHeader(String arg0, int arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#setStatus(int, * java.lang.String) */ public void setStatus(int arg0, String arg1) { } /* * (non-Javadoc) * * @see javax.servlet.http.HttpServletResponse#setStatus(int) */ public void setStatus(int arg0) { } /* * (non-Javadoc) * * @see javax.portlet.PortletResponse#addProperty(java.lang.String, * java.lang.String) */ public void addProperty(String arg0, String arg1) { renderResponse.addProperty(arg0, arg1); } /* * (non-Javadoc) * * @see javax.portlet.PortletResponse#setProperty(java.lang.String, * java.lang.String) */ public void setProperty(String arg0, String arg1) { renderResponse.setProperty(arg0, arg1); } public String getContentType() { if (renderResponse != null) { return renderResponse.getContentType(); } return null; } public void setCharacterEncoding(String arg0) { } /* * (non-Javadoc) * * @see javax.portlet.RenderResponse#createActionURL() */ public PortletURL createActionURL() { return this.renderResponse.createActionURL(); } /* * (non-Javadoc) * * @see javax.portlet.RenderResponse#createRenderURL() */ public PortletURL createRenderURL() { return this.createRenderURL(); } /* * (non-Javadoc) * * @see javax.portlet.RenderResponse#getNamespace() */ public String getNamespace() { return this.getNamespace(); } /* * (non-Javadoc) * * @see javax.portlet.RenderResponse#getPortletOutputStream() */ public OutputStream getPortletOutputStream() throws IOException { return this.getPortletOutputStream(); } /* * (non-Javadoc) * * @see javax.portlet.RenderResponse#setTitle(java.lang.String) */ public void setTitle(String title) { this.renderResponse.setTitle(title); } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/HttpSessionWrapper.java Index: HttpSessionWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.util.ArrayList; import java.util.Enumeration; import javax.portlet.PortletContext; import javax.portlet.PortletSession; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionContext; /** * This class is a dummy HttpSessionWrapper. * * @author <a href="mailto:shi...@ya...">Shinsuke Sugaya</a> */ public class HttpSessionWrapper implements HttpSession { private PortletSession portletSession; private PortletContext portletContext; public HttpSessionWrapper( PortletSession portletSession, PortletContext portletContext) { this.portletSession = portletSession; this.portletContext = portletContext; } public long getCreationTime() { return portletSession.getCreationTime(); } public String getId() { return portletSession.getId(); } public long getLastAccessedTime() { return portletSession.getLastAccessedTime(); } public ServletContext getServletContext() { return new ServletContextWrapper(portletContext); } public void setMaxInactiveInterval(int arg0) { portletSession.setMaxInactiveInterval(arg0); } public int getMaxInactiveInterval() { return portletSession.getMaxInactiveInterval(); } public HttpSessionContext getSessionContext() { // TODO Portlet API does not have this method return null; } public Object getAttribute(String arg0) { return portletSession.getAttribute(arg0); } public Object getValue(String arg0) { return portletSession.getAttribute(arg0); } public Enumeration getAttributeNames() { return portletSession.getAttributeNames(); } public String[] getValueNames() { ArrayList objs = new ArrayList(); for (Enumeration e = portletSession.getAttributeNames(); e.hasMoreElements();) { String key = (String)e.nextElement(); objs.add(key); } String[] values = new String[objs.size()]; for (int i = 0; i < objs.size(); i++) { values[i] = (String)objs.get(i); } return values; } public void setAttribute(String arg0, Object arg1) { portletSession.setAttribute(arg0, arg1); } public void putValue(String arg0, Object arg1) { portletSession.setAttribute(arg0, arg1); } public void removeAttribute(String arg0) { portletSession.removeAttribute(arg0); } public void removeValue(String arg0) { portletSession.removeAttribute(arg0); } public void invalidate() { portletSession.invalidate(); } public boolean isNew() { return portletSession.isNew(); } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/portlet/myfaces/tomahawk/support/MultipartPortletRequestWrapper.java Index: MultipartPortletRequestWrapper.java =================================================================== package org.andromda.cartridges.jsf2.portlet.myfaces.tomahawk.support; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.security.Principal; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import javax.portlet.ActionRequest; import javax.portlet.PortalContext; import javax.portlet.PortletMode; import javax.portlet.PortletPreferences; import javax.portlet.PortletSession; import javax.portlet.WindowState; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadBase; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.portlet.PortletFileUpload; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.myfaces.webapp.filter.MultipartRequestWrapper; /** * This class handles multipart/form-date request for Portlet. It will be called * if the request is multipart/form-data. * * @author <a href="mailto:shi...@ya...">Shinsuke Sugaya</a> * @author Sylvain Vieujot */ public class MultipartPortletRequestWrapper implements ActionRequest, MultipartRequest { private static Log log = LogFactory.getLog(MultipartPortletRequestWrapper.class); private ActionRequest request = null; private Map parametersMap = null; private PortletFileUpload fileUpload = null; private Map fileItems = null; private int maxSize; private int thresholdSize; private String repositoryPath; public MultipartPortletRequestWrapper( ActionRequest request, int maxSize, int thresholdSize, String repositoryPath) { this.request = request; this.maxSize = maxSize; this.thresholdSize = thresholdSize; this.repositoryPath = repositoryPath; } private void parseRequest() { DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); diskFileItemFactory.setSizeThreshold(thresholdSize); if (repositoryPath != null && repositoryPath.trim().length() > 0) diskFileItemFactory.setRepository(new File(repositoryPath)); fileUpload = new PortletFileUpload(); fileUpload.setFileItemFactory(diskFileItemFactory); fileUpload.setSizeMax(maxSize); String charset = request.getCharacterEncoding(); fileUpload.setHeaderEncoding(charset); List requestParameters = null; try { requestParameters = fileUpload.parseRequest(request); } catch (FileUploadBase.SizeLimitExceededException e) { // TODO: find a way to notify the user about the fact that the // uploaded file exceeded size limit if (log.isInfoEnabled()) log.info("user tried to upload a file that exceeded file-size limitations.", e); requestParameters = Collections.EMPTY_LIST; } catch (FileUploadException fue) { log.error("Exception while uploading file.", fue); requestParameters = Collections.EMPTY_LIST; } parametersMap = new HashMap(requestParameters.size()); fileItems = new HashMap(); for (Iterator iter = requestParameters.iterator(); iter.hasNext();) { FileItem fileItem = (FileItem)iter.next(); if (fileItem.isFormField()) { String name = fileItem.getFieldName(); // The following code avoids commons-fileupload charset problem. // After fixing commons-fileupload, this code should be // // String value = fileItem.getString(); // String value = null; if (charset == null) { value = fileItem.getString(); } else { try { value = new String(fileItem.get(), charset); } catch (UnsupportedEncodingException e) { value = fileItem.getString(); } } addTextParameter(name, value); } else { // fileItem is a File if (fileItem.getName() != null) { fileItems.put(fileItem.getFieldName(), fileItem); } } } // Add the query string paramters for (Iterator it = request.getParameterMap().entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry)it.next(); String[] valuesArray = (String[])entry.getValue(); for (int i = 0; i < valuesArray.length; i++) { addTextParameter((String)entry.getKey(), valuesArray[i]); } } } private void addTextParameter(String name, String value) { if (!parametersMap.containsKey(name)) { String[] valuesArray = { value }; parametersMap.put(name, valuesArray); } else { String[] storedValues = (String[])parametersMap.get(name); int lengthSrc = storedValues.length; String[] valuesArray = new String[lengthSrc + 1]; System.arraycopy(storedValues, 0, valuesArray, 0, lengthSrc); valuesArray[lengthSrc] = value; parametersMap.put(name, valuesArray); } } public Enumeration getParameterNames() { if (parametersMap == null) parseRequest(); return Collections.enumeration(parametersMap.keySet()); } public String getParameter(String name) { if (parametersMap == null) parseRequest(); String[] values ... [truncated message content] |
From: Chad B. <cwb...@us...> - 2008-07-24 18:07:37
|
User: cwbrandon Date: 08/07/24 11:07:44 Modified: andromda-jsf2/components pom.xml Added: andromda-jsf2/components/src/main/resources/META-INF faces-config.xml andromda.taglib.xml andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/renderkit TransactionTokenRenderer.java andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/component TransactionToken.java Log: Add TransactionToken component that we an use for preventing multi submits of the same action either or refreshes or when a button is clicked twice Revision Changes Path 1.3 +7 -77 cartridges/andromda-jsf2/components/src/main/resources/META-INF/faces-config.xml 1.1 cartridges/andromda-jsf2/components/src/main/resources/META-INF/andromda.taglib.xml Index: andromda.taglib.xml =================================================================== <?xml version="1.0"?> <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"> <facelet-taglib> <namespace>http://www.andromda.org/cartridges/jsf2</namespace> <tag> <tag-name>transactionToken</tag-name> <component> <component-type>org.andromda.cartridges.jsf2.component.TransactionToken</component-type> <renderer-type>org.andromda.cartridges.jsf2.TransactionToken</renderer-type> </component> </tag> </facelet-taglib> 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/renderkit/TransactionTokenRenderer.java Index: TransactionTokenRenderer.java =================================================================== package org.andromda.cartridges.jsf2.renderkit; import java.io.IOException; import java.util.UUID; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.render.Renderer; import org.andromda.cartridges.jsf2.component.TransactionToken; /** * The transaction token renderer (just adds the transaction token value * as an attribute of the parent component so we can skip multi-submits of the same action). * * @author Chad Brandon */ public class TransactionTokenRenderer extends Renderer { /** * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent) */ @SuppressWarnings("unchecked") public void encodeBegin( FacesContext context, UIComponent component) throws IOException { if (component.getParent() != null) { component.getParent().getAttributes().put(TransactionToken.TRANSACTION_TOKEN, UUID.randomUUID().toString()); } } } 1.1 cartridges/andromda-jsf2/components/src/main/java/org/andromda/cartridges/jsf2/component/TransactionToken.java Index: TransactionToken.java =================================================================== package org.andromda.cartridges.jsf2.component; import javax.faces.component.UIComponentBase; /** * The transaction token component, basically just registers its renderer. * * @author Chad Brandon */ public class TransactionToken extends UIComponentBase { public static final String TRANSACTION_TOKEN = "AndroMDA_Transaction_Token"; private static final String RENDERER_TYPE = "org.andromda.cartridges.jsf2.TransactionToken"; public TransactionToken() { super(); this.setRendererType(RENDERER_TYPE); } /** * @see javax.faces.component.UIComponent#getFamily() */ public String getFamily() { return RENDERER_TYPE; } } 1.5 +6 -0 cartridges/andromda-jsf2/components/pom.xml Index: pom.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/components/pom.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- pom.xml 11 Apr 2008 22:57:12 -0000 1.4 +++ pom.xml 24 Jul 2008 18:07:44 -0000 1.5 @@ -25,6 +25,12 @@ <artifactId>tomahawk</artifactId> <version>1.1.7-SNAPSHOT</version> <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>commons-lang</groupId> |
From: Walter M. <wal...@us...> - 2008-09-18 12:56:43
|
User: walterim Date: 08/09/18 05:56:53 Modified: andromda-jsf2/src/main/resources/META-INF/andromda cartridge.xml andromda-jsf2/src/main/resources/templates/jsf2/configuration web.xml.vsl andromda-jsf2/components pom.xml Removed: andromda-jsf2/src/main/resources/resources/lib/myfaces tomahawk-1.1.7-SNAPSHOT.jar Log: Using Tomahawk 1.1.7 final Revision Changes Path 1.34 +0 -7 cartridges/andromda-jsf2/src/main/resources/META-INF/andromda/cartridge.xml Index: cartridge.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/META-INF/andromda/cartridge.xml,v retrieving revision 1.33 retrieving revision 1.34 diff -u -w -r1.33 -r1.34 --- cartridge.xml 24 Jul 2008 14:38:50 -0000 1.33 +++ cartridge.xml 18 Sep 2008 12:56:51 -0000 1.34 @@ -177,13 +177,6 @@ lastModifiedCheck="true" outputCondition="portlet"/> - <resource - path="resources/lib/myfaces/*.*" - outputPattern="WEB-INF/lib/{0}" - outlet="libraries" - overwrite="true" - lastModifiedCheck="true"/> - <!-- process templates on model elements --> <template path="templates/jsf2/configuration/web.xml.vsl" 1.19 +10 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/web.xml.vsl Index: web.xml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/web.xml.vsl,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- web.xml.vsl 4 Jul 2008 12:17:51 -0000 1.18 +++ web.xml.vsl 18 Sep 2008 12:56:53 -0000 1.19 @@ -158,6 +158,16 @@ <param-value>true</param-value> </context-param> + <context-param> + <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name> + <param-value>false</param-value> + </context-param> + + <context-param> + <param-name>org.apache.myfaces.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER</param-name> + <param-value>true</param-value> + </context-param> + #if ($liferayPortlet) <context-param> <param-name>portlet_properties</param-name> 1.6 +1 -2 cartridges/andromda-jsf2/components/pom.xml Index: pom.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/components/pom.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- pom.xml 24 Jul 2008 18:07:44 -0000 1.5 +++ pom.xml 18 Sep 2008 12:56:53 -0000 1.6 @@ -23,8 +23,7 @@ <dependency> <groupId>org.apache.myfaces.tomahawk</groupId> <artifactId>tomahawk</artifactId> - <version>1.1.7-SNAPSHOT</version> - <scope>provided</scope> + <version>1.1.7</version> <exclusions> <exclusion> <groupId>commons-collections</groupId> |