[Bedework-commit] bwcalfacade r49 - in releases/bedework-3.8: .
src/org/bedework/calfacade src/org/bedework/calfacade/svc
src/org/bedework/calfacade/util
svnadmin at bedework.org
svnadmin at bedework.org
Sat Apr 21 23:00:08 EDT 2012
Author: douglm
Date: 2012-04-21 23:00:04 -0400 (Sat, 21 Apr 2012)
New Revision: 49
Modified:
releases/bedework-3.8/.classpath
releases/bedework-3.8/build.xml
releases/bedework-3.8/src/org/bedework/calfacade/BwResource.java
releases/bedework-3.8/src/org/bedework/calfacade/BwResourceContent.java
releases/bedework-3.8/src/org/bedework/calfacade/svc/BwView.java
releases/bedework-3.8/src/org/bedework/calfacade/util/ChangeTableEntry.java
Log:
Dump and restore resources - dumped as Base64 encoded values in the file.
Modified: releases/bedework-3.8/.classpath
===================================================================
--- releases/bedework-3.8/.classpath 2012-04-22 03:00:01 UTC (rev 48)
+++ releases/bedework-3.8/.classpath 2012-04-22 03:00:04 UTC (rev 49)
@@ -16,5 +16,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/caldav-3.8"/>
<classpathentry combineaccessrules="false" kind="src" path="/davutil-3.8"/>
<classpathentry kind="lib" path="lib/hibernate-3.6.9.Final.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.5.jar"/>
<classpathentry kind="output" path="bin/bwcalfacade/bwcalfacade-3.8"/>
</classpath>
Modified: releases/bedework-3.8/build.xml
===================================================================
--- releases/bedework-3.8/build.xml 2012-04-22 03:00:01 UTC (rev 48)
+++ releases/bedework-3.8/build.xml 2012-04-22 03:00:04 UTC (rev 49)
@@ -40,6 +40,7 @@
</target>
<target name="build-init" depends="init">
+ <getJar name="commons-codec" version="1.5" />
<getJar name="hibernate" version="3.6.9.Final" />
<getJar name="ical4j" version="head-20100601" />
<getJar name="ical4j-vcard" version="0.9.3-SNAPSHOT" />
Modified: releases/bedework-3.8/src/org/bedework/calfacade/BwResource.java
===================================================================
--- releases/bedework-3.8/src/org/bedework/calfacade/BwResource.java 2012-04-22 03:00:01 UTC (rev 48)
+++ releases/bedework-3.8/src/org/bedework/calfacade/BwResource.java 2012-04-22 03:00:04 UTC (rev 49)
@@ -6,9 +6,9 @@
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
@@ -18,6 +18,8 @@
*/
package org.bedework.calfacade;
+import org.bedework.calfacade.annotations.Dump;
+import org.bedework.calfacade.annotations.NoDump;
import org.bedework.calfacade.base.BwShareableContainedDbentity;
import edu.rpi.sss.util.DateTimeUtil;
@@ -34,6 +36,7 @@
*
* @author Mike Douglass douglm - rpi.edu
*/
+ at Dump(elementName="resource", keyFields={"name"})
public class BwResource extends BwShareableContainedDbentity<BwResource> {
private String name;
@@ -213,6 +216,7 @@
*
* @param val lastmod
*/
+ @NoDump
public void setPrevLastmod(final String val) {
prevLastmod = val;
}
@@ -237,6 +241,7 @@
*
* @return the event's seq
*/
+ @NoDump
public int getPrevSeq() {
return prevSeq;
}
@@ -253,6 +258,7 @@
*
* @return BwResourceContent content
*/
+ @Dump(compound = true)
public BwResourceContent getContent() {
return content;
}
Modified: releases/bedework-3.8/src/org/bedework/calfacade/BwResourceContent.java
===================================================================
--- releases/bedework-3.8/src/org/bedework/calfacade/BwResourceContent.java 2012-04-22 03:00:01 UTC (rev 48)
+++ releases/bedework-3.8/src/org/bedework/calfacade/BwResourceContent.java 2012-04-22 03:00:04 UTC (rev 49)
@@ -18,12 +18,18 @@
*/
package org.bedework.calfacade;
+import org.bedework.calfacade.annotations.Dump;
+import org.bedework.calfacade.annotations.NoDump;
import org.bedework.calfacade.base.BwDbentity;
import org.bedework.calfacade.exc.CalFacadeException;
import org.bedework.calfacade.util.CalFacadeUtil;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Base64OutputStream;
import org.hibernate.Hibernate;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.sql.Blob;
/** Represent the content for a resource stored within the system, e.g an attachment or an
@@ -32,6 +38,7 @@
*
* @author Mike Douglass douglm - rpi.edu
*/
+ at Dump(elementName="resourceContent", keyFields={"colPath", "name", "encodedContent"})
public class BwResourceContent extends BwDbentity<BwResourceContent> {
/* The collection this belongs to
*/
@@ -95,6 +102,7 @@
*
* @return Blob
*/
+ @NoDump
public Blob getValue() {
return value;
}
@@ -107,6 +115,7 @@
* @param val
* @throws CalFacadeException
*/
+ @NoDump
public void setContent(final byte[] val) throws CalFacadeException {
try {
setValue(Hibernate.createBlob(val));
@@ -115,6 +124,43 @@
}
}
+ /** Used during dump and restore
+ * @param val base64 encoded value
+ * @throws CalFacadeException
+ */
+ public void setEncodedContent(final String val) throws CalFacadeException {
+ try {
+ setContent(Base64.decodeBase64(val.getBytes()));
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /**
+ * @return base64 encoded value
+ * @throws CalFacadeException
+ */
+ public String getEncodedContent() throws CalFacadeException {
+ try {
+ int len = -1;
+ int chunkSize = 1024;
+
+ byte buffer[] = new byte[chunkSize];
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Base64OutputStream b64out = new Base64OutputStream(baos);
+ InputStream str = getValue().getBinaryStream();
+
+ while((len = str.read(buffer)) != -1) {
+ b64out.write(buffer, 0, len);
+ }
+
+ return new String(baos.toByteArray());
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
/** Copy this objects values into the parameter
*
* @param val
Modified: releases/bedework-3.8/src/org/bedework/calfacade/svc/BwView.java
===================================================================
--- releases/bedework-3.8/src/org/bedework/calfacade/svc/BwView.java 2012-04-22 03:00:01 UTC (rev 48)
+++ releases/bedework-3.8/src/org/bedework/calfacade/svc/BwView.java 2012-04-22 03:00:04 UTC (rev 49)
@@ -123,7 +123,6 @@
*
* @param val
*/
- @NoDump
public void setConjunction(final boolean val) {
conjunction = val;
}
@@ -131,6 +130,7 @@
/**
* @return true if we AND the expressions for each path
*/
+ @NoDump
public boolean getConjunction() {
return conjunction;
}
Modified: releases/bedework-3.8/src/org/bedework/calfacade/util/ChangeTableEntry.java
===================================================================
--- releases/bedework-3.8/src/org/bedework/calfacade/util/ChangeTableEntry.java 2012-04-22 03:00:01 UTC (rev 48)
+++ releases/bedework-3.8/src/org/bedework/calfacade/util/ChangeTableEntry.java 2012-04-22 03:00:04 UTC (rev 49)
@@ -191,6 +191,7 @@
/** Return a new entry based on this entry.
*
+ * @param chg - the change table
* @return ChangeTableEntry
*/
public ChangeTableEntry newEntry(final ChangeTable chg) {
@@ -205,6 +206,7 @@
/** Return a new entry given the property name.
*
+ * @param chg - the change table
* @param name
* @return ChangeTableEntry
*/
More information about the Bedework-commit
mailing list