Author: chris.laprun(a)jboss.com
Date: 2009-11-20 18:18:15 -0500 (Fri, 20 Nov 2009)
New Revision: 746
Modified:
portal/branches/wsrp-integration/component/common/pom.xml
portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java
Log:
- Added getBytes method.
Modified: portal/branches/wsrp-integration/component/common/pom.xml
===================================================================
--- portal/branches/wsrp-integration/component/common/pom.xml 2009-11-20 18:01:16 UTC (rev
745)
+++ portal/branches/wsrp-integration/component/common/pom.xml 2009-11-20 23:18:15 UTC (rev
746)
@@ -19,32 +19,38 @@
-->
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component</artifactId>
- <version>3.0.0-Beta03-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>exo.portal.component.common</artifactId>
- <packaging>jar</packaging>
- <name>GateIn Portal Component Common</name>
- <dependencies>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.commons</artifactId>
- <version>${org.exoplatform.kernel.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.core</groupId>
- <artifactId>exo.core.component.database</artifactId>
- <version>${org.exoplatform.core.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component</artifactId>
+ <version>3.0.0-Beta03-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.common</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Common</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.database</artifactId>
+ <version>${org.exoplatform.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-common</artifactId>
+ <version>${org.gatein.common.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
Modified:
portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java
===================================================================
---
portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java 2009-11-20
18:01:16 UTC (rev 745)
+++
portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Safe.java 2009-11-20
23:18:15 UTC (rev 746)
@@ -1,16 +1,16 @@
/**
* Copyright (C) 2009 eXo Platform SAS.
- *
+ *
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
- *
+ *
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@@ -19,8 +19,11 @@
package org.exoplatform.commons.utils;
+import org.gatein.common.io.IOTools;
+
import java.io.Closeable;
import java.io.IOException;
+import java.io.InputStream;
/**
* A class that contains utility method that make the caller not worry much about the
unexpectable expected such as
@@ -37,8 +40,8 @@
}
/**
- * Return true if both objects are null or both are non null and the equals method of
one object returns true when
- * it is invoked with the other object as argument.
+ * Return true if both objects are null or both are non null and the equals method of
one object returns true when it
+ * is invoked with the other object as argument.
*
* @param o1 the first object
* @param o2 the second object
@@ -57,8 +60,8 @@
}
/**
- * Close a closable object. The provided object may be null or thrown an IOException
or a runtime exception during the
- * invocation of the close method without changing the control flow of the method
caller. If the closeable was
+ * Close a closable object. The provided object may be null or thrown an IOException
or a runtime exception during
+ * the invocation of the close method without changing the control flow of the method
caller. If the closeable was
* succesfully closed the method returns true.
*
* @param closeable the closeable
@@ -82,4 +85,29 @@
}
return false;
}
+
+ public static byte[] getBytes(InputStream is)
+ {
+ byte[] bytes;
+
+ if (is == null)
+ {
+ return null;
+ }
+
+ try
+ {
+ bytes = IOTools.getBytes(is);
+ return bytes;
+ }
+ catch (IOException ignore)
+ {
+ // todo: should log
+ return null;
+ }
+ finally
+ {
+ IOTools.safeClose(is);
+ }
+ }
}