[Bedework-commit] dumprestore r465 - in
trunk/src/org/bedework/dumprestore: . dump dump/dumpling
restore restore/rules
svnadmin at bedework.org
svnadmin at bedework.org
Sat Apr 21 22:59:49 EDT 2012
Author: douglm
Date: 2012-04-21 22:59:41 -0400 (Sat, 21 Apr 2012)
New Revision: 465
Added:
trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentFieldRule.java
trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentRule.java
trunk/src/org/bedework/dumprestore/restore/rules/ResourceFieldRule.java
trunk/src/org/bedework/dumprestore/restore/rules/ResourceRule.java
Modified:
trunk/src/org/bedework/dumprestore/Counters.java
trunk/src/org/bedework/dumprestore/Defs.java
trunk/src/org/bedework/dumprestore/dump/DumpIntf.java
trunk/src/org/bedework/dumprestore/dump/HibDump.java
trunk/src/org/bedework/dumprestore/dump/dumpling/DumpAll.java
trunk/src/org/bedework/dumprestore/dump/dumpling/Dumpling.java
trunk/src/org/bedework/dumprestore/restore/HibRestore.java
trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java
trunk/src/org/bedework/dumprestore/restore/rules/EntityRule.java
trunk/src/org/bedework/dumprestore/restore/rules/RestoreRuleSet.java
Log:
Dump and restore resources - dumped as Base64 encoded values in the file.
Modified: trunk/src/org/bedework/dumprestore/Counters.java
===================================================================
--- trunk/src/org/bedework/dumprestore/Counters.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/Counters.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -79,10 +79,13 @@
public final int calSuites = 15;
/** */
- public final int externalSubscriptions = 16;
+ public final int resources = 16;
+ /** */
+ public final int externalSubscriptions = 17;
+
/** */
- public int[] counts = new int[17];
+ public int[] counts = new int[18];
/** */
public String[] countNames = {
@@ -102,6 +105,7 @@
"userPrefs",
"filters",
"calendar suites",
+ "resources",
"external subscriptions",
};
Modified: trunk/src/org/bedework/dumprestore/Defs.java
===================================================================
--- trunk/src/org/bedework/dumprestore/Defs.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/Defs.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -101,6 +101,8 @@
/** */
public static final String sectionUserPrefs = "user-preferences";
/** */
+ public static final String sectionResources = "resources";
+ /** */
public static final String sectionDbLastmods = "dblastmods";
/** */
public static final String sectionCalSuites = "cal-suites";
@@ -166,6 +168,12 @@
public static final String objectRelatedTo = "relatedTo";
/** */
+ public static final String objectResource = "resource";
+
+ /** */
+ public static final String objectContent = "content";
+
+ /** */
public static final String objectDateTime = "date-time";
/** */
Modified: trunk/src/org/bedework/dumprestore/dump/DumpIntf.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/DumpIntf.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/dump/DumpIntf.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -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
@@ -25,6 +25,7 @@
import org.bedework.calfacade.BwEventAnnotation;
import org.bedework.calfacade.BwFilterDef;
import org.bedework.calfacade.BwLocation;
+import org.bedework.calfacade.BwResource;
import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import org.bedework.calfacade.svc.BwAdminGroup;
@@ -67,11 +68,6 @@
* <li>BwCalSuite</li>
*
* <li>BwFilter</li>
- * <li>BwRecurrenceInstance</li>
- * <li>BwSynchData</li>
- * <li>BwSynchInfo</li>
- * <li>BwSynchState</li>
- * <li>BwTodo</li>
* <li>BwUserInfo</li>
* </ul>
*
@@ -197,6 +193,20 @@
*/
public Iterator<BwUser> getUsers() throws Throwable;
+ /** Will return an Iterator returning User resources.
+ *
+ * @return Iterator over entities
+ * @throws Throwable
+ */
+ public Iterator<BwResource> getResources() throws Throwable;
+
+ /** Will return the resource content for the given resource.
+ *
+ * @param res on return resource content object will be implanted
+ * @throws Throwable
+ */
+ public void getResourceContent(BwResource res) throws Throwable;
+
/** Will return an Iterator returning view objects.
*
* @return Iterator over entities
Modified: trunk/src/org/bedework/dumprestore/dump/HibDump.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/HibDump.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/dump/HibDump.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -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
@@ -27,6 +27,8 @@
import org.bedework.calfacade.BwFilterDef;
import org.bedework.calfacade.BwGroup;
import org.bedework.calfacade.BwLocation;
+import org.bedework.calfacade.BwResource;
+import org.bedework.calfacade.BwResourceContent;
import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import org.bedework.calfacade.exc.CalFacadeException;
@@ -76,16 +78,19 @@
}
}
+ @Override
public void open() throws Throwable {
openSess();
beginTransaction();
}
+ @Override
public void close() throws Throwable {
endTransaction();
closeSess();
}
+ @Override
public Iterator getAdminGroups() throws Throwable {
sess.createQuery("from " + BwAdminGroup.class.getName());
@@ -98,10 +103,12 @@
return c.iterator();
}
+ @Override
public Iterator getAuthUsers() throws Throwable {
return getObjects("org.bedework.calfacade.svc.BwAuthUser");
}
+ @Override
public Iterator getCalendars() throws Throwable {
getIntSyspars();
@@ -113,6 +120,7 @@
return sess.getList().iterator();
}
+ @Override
public Collection<BwCalendar> getChildren(final BwCalendar val) throws Throwable {
sess.createQuery("from org.bedework.calfacade.BwCalendar c where " +
"c.colPath=:path");
@@ -121,14 +129,17 @@
return sess.getList();
}
+ @Override
public Iterator getCalSuites() throws Throwable {
return getObjects(BwCalSuite.class.getName());
}
+ @Override
public Iterator getCategories() throws Throwable {
return getObjects(BwCategory.class.getName());
}
+ @Override
public Iterator<BwEvent> getEvents() throws Throwable {
Collection<BwEvent> evs = getObjectCollection(BwEventObj.class.getName());
@@ -141,6 +152,7 @@
return evs.iterator();
}
+ @Override
public Iterator<BwEventAnnotation> getEventAnnotations() throws Throwable {
StringBuilder sb = new StringBuilder();
@@ -155,30 +167,62 @@
return anns.iterator();
}
+ @Override
public Iterator getFilters() throws Throwable {
return getObjects(BwFilterDef.class.getName());
}
+ @Override
public Iterator getLocations() throws Throwable {
return getObjects(BwLocation.class.getName());
}
+ @Override
public Iterator getPreferences() throws Throwable {
return getObjects(BwPreferences.class.getName());
}
+ @Override
public Iterator getContacts() throws Throwable {
return getObjects(BwContact.class.getName());
}
+ @Override
public Iterator getSyspars() throws Throwable {
return getObjects(BwSystem.class.getName());
}
+ @Override
public Iterator getUsers() throws Throwable {
return getObjects(BwUser.class.getName());
}
+ @Override
+ public Iterator<BwResource> getResources() throws Throwable {
+ return getObjects(BwResource.class.getName());
+ }
+
+ @Override
+ public void getResourceContent(final BwResource res) throws Throwable {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("from ");
+ sb.append(BwResourceContent.class.getName());
+ sb.append(" as rc where rc.colPath=:path and rc.name=:name");
+
+ sess.createQuery(sb.toString());
+ sess.setString("path", res.getColPath());
+ sess.setString("name", res.getName());
+
+ BwResourceContent rc = (BwResourceContent)sess.getUnique();
+ if (rc == null) {
+ throw new CalFacadeException(CalFacadeException.missingResourceContent);
+ }
+
+ res.setContent(rc);
+ }
+
+ @Override
public Iterator getViews() throws Throwable {
return getObjects(BwView.class.getName());
}
Modified: trunk/src/org/bedework/dumprestore/dump/dumpling/DumpAll.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/dumpling/DumpAll.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/dump/dumpling/DumpAll.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -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
@@ -25,6 +25,7 @@
import org.bedework.calfacade.BwEventAnnotation;
import org.bedework.calfacade.BwFilterDef;
import org.bedework.calfacade.BwLocation;
+import org.bedework.calfacade.BwResource;
import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import org.bedework.calfacade.BwVersion;
@@ -154,6 +155,12 @@
close();
open();
+ new Dumpling<BwResource>(globals,
+ new QName(sectionResources),
+ globals.resources).dumpSection(globals.di.getResources());
+ close();
+
+ open();
new Dumpling<BwCalSuite>(globals,
new QName(sectionCalSuites),
globals.calSuites).dumpSection(globals.di.getCalSuites());
Modified: trunk/src/org/bedework/dumprestore/dump/dumpling/Dumpling.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/dumpling/Dumpling.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/dump/dumpling/Dumpling.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -20,6 +20,7 @@
import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.BwEvent;
+import org.bedework.calfacade.BwResource;
import org.bedework.calfacade.base.DumpEntity;
import org.bedework.calfacade.base.DumpEntity.DumpType;
import org.bedework.calfacade.exc.CalFacadeException;
@@ -56,7 +57,9 @@
* @param sectionTag
* @param countIndex
*/
- public Dumpling(final DumpGlobals globals, final QName sectionTag, final int countIndex) {
+ public Dumpling(final DumpGlobals globals,
+ final QName sectionTag,
+ final int countIndex) {
this.globals = globals;
this.sectionTag = sectionTag;
this.countIndex = countIndex;
@@ -85,8 +88,17 @@
while (it.hasNext()) {
DumpEntity d = unwrap(it.next());
+ if (d instanceof BwResource) {
+ globals.di.getResourceContent((BwResource)d);
+ }
+
d.dump(globals.xml, DumpType.def);
+ if (d instanceof BwResource) {
+ // Let GC take it away
+ ((BwResource)d).setContent(null);
+ }
+
globals.counts[countIndex]++;
if ((globals.counts[countIndex] % 100) == 0) {
Modified: trunk/src/org/bedework/dumprestore/restore/HibRestore.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/HibRestore.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/restore/HibRestore.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -40,6 +40,8 @@
import org.bedework.calfacade.BwFilterDef;
import org.bedework.calfacade.BwLocation;
import org.bedework.calfacade.BwPrincipal;
+import org.bedework.calfacade.BwResource;
+import org.bedework.calfacade.BwResourceContent;
import org.bedework.calfacade.BwStats;
import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
@@ -556,6 +558,21 @@
}
@Override
+ public void restoreResource(final BwResource o) throws Throwable {
+ openHibSess();
+
+ o.setId(CalFacadeDefs.unsavedItemKey);
+ save(o);
+
+ BwResourceContent rc = o.getContent();
+
+ rc.setId(CalFacadeDefs.unsavedItemKey);
+ save(rc);
+
+ closeHibSess();
+ }
+
+ @Override
public void restoreUserPrefs(final BwPreferences o) throws Throwable {
if (!globals.onlyUsersMap.check(o)) {
return;
Modified: trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -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
@@ -27,6 +27,7 @@
import org.bedework.calfacade.BwFilterDef;
import org.bedework.calfacade.BwLocation;
import org.bedework.calfacade.BwPrincipal;
+import org.bedework.calfacade.BwResource;
import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import org.bedework.calfacade.exc.CalFacadeException;
@@ -224,6 +225,13 @@
*/
public void restoreFilter(BwFilterDef o) throws Throwable;
+ /** Restore resource
+ *
+ * @param o Object to restore with id set
+ * @throws Throwable
+ */
+ public void restoreResource(BwResource o) throws Throwable;
+
/** Restore user prefs
*
* @param o Object to restore with id set
Modified: trunk/src/org/bedework/dumprestore/restore/rules/EntityRule.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/EntityRule.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/restore/rules/EntityRule.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -32,6 +32,8 @@
import org.bedework.calfacade.BwLocation;
import org.bedework.calfacade.BwRelatedTo;
import org.bedework.calfacade.BwRequestStatus;
+import org.bedework.calfacade.BwResource;
+import org.bedework.calfacade.BwResourceContent;
import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import org.bedework.calfacade.base.BwShareableDbentity;
@@ -83,6 +85,8 @@
classes.put("request-status", BwRequestStatus.class.getName());
classes.put(objectGeo, BwGeo.class.getName());
classes.put(objectRelatedTo, BwRelatedTo.class.getName());
+ classes.put(objectResource, BwResource.class.getName());
+ classes.put(objectContent, BwResourceContent.class.getName());
/* The name is the kind key for EventRule. */
classes.put(objectEvent, BwEventObj.class.getName());
Added: trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentFieldRule.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentFieldRule.java (rev 0)
+++ trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentFieldRule.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -0,0 +1,55 @@
+/* ********************************************************************
+ Licensed to Jasig under one or more contributor license
+ agreements. See the NOTICE file distributed with this work
+ for additional information regarding copyright ownership.
+ Jasig licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a
+ copy of the License at:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+package org.bedework.dumprestore.restore.rules;
+
+import org.bedework.calfacade.BwResourceContent;
+import org.bedework.dumprestore.restore.RestoreGlobals;
+
+/**
+ * @author Mike Douglass
+ * @version 1.0
+ */
+public class ResourceContentFieldRule extends EntityFieldRule {
+ ResourceContentFieldRule(final RestoreGlobals globals) {
+ super(globals);
+ }
+
+ @Override
+ public void field(final String name) throws Exception {
+ BwResourceContent rc = (BwResourceContent)top();
+
+ if (taggedEntityId(rc, name)) {
+ return;
+ }
+
+ if (name.equals("byteSize")) {
+ return;
+ }
+
+ if (name.equals("colPath")) {
+ rc.setColPath(stringFld());
+ } else if (name.equals("name")) {
+ rc.setName(stringFld());
+ } else if (name.equals("encodedContent")) {
+ rc.setEncodedContent(stringFld());
+ } else {
+ unknownTag(name);
+ }
+ }
+}
Added: trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentRule.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentRule.java (rev 0)
+++ trunk/src/org/bedework/dumprestore/restore/rules/ResourceContentRule.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -0,0 +1,52 @@
+/* ********************************************************************
+ Licensed to Jasig under one or more contributor license
+ agreements. See the NOTICE file distributed with this work
+ for additional information regarding copyright ownership.
+ Jasig licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a
+ copy of the License at:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+package org.bedework.dumprestore.restore.rules;
+
+import org.bedework.calfacade.BwResource;
+import org.bedework.calfacade.BwResourceContent;
+import org.bedework.dumprestore.restore.RestoreGlobals;
+
+/**
+ * @author Mike Douglass douglm rpi.edu
+ * @version 1.0
+ */
+public class ResourceContentRule extends EntityRule {
+ /** Constructor
+ *
+ * @param globals
+ */
+ public ResourceContentRule(final RestoreGlobals globals) {
+ super(globals);
+ }
+
+ @Override
+ public void end(final String ns, final String name) throws Exception {
+ BwResourceContent entity = (BwResourceContent)pop();
+
+ if (!(top() instanceof BwResource)) {
+ warn("Expected a resource object: found " + top());
+ return;
+ }
+
+ BwResource r = (BwResource)top();
+
+ r.setContent(entity);
+ }
+}
+
Added: trunk/src/org/bedework/dumprestore/restore/rules/ResourceFieldRule.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/ResourceFieldRule.java (rev 0)
+++ trunk/src/org/bedework/dumprestore/restore/rules/ResourceFieldRule.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -0,0 +1,82 @@
+/* ********************************************************************
+ Licensed to Jasig under one or more contributor license
+ agreements. See the NOTICE file distributed with this work
+ for additional information regarding copyright ownership.
+ Jasig licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a
+ copy of the License at:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+package org.bedework.dumprestore.restore.rules;
+
+import org.bedework.calfacade.BwResource;
+import org.bedework.dumprestore.restore.RestoreGlobals;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Mike Douglass douglm rpi.edu
+ * @version 1.0
+ */
+public class ResourceFieldRule extends EntityFieldRule {
+ private static Collection<String> skippedNames;
+
+ static {
+ skippedNames = new ArrayList<String>();
+ }
+
+ ResourceFieldRule(final RestoreGlobals globals) {
+ super(globals);
+ }
+
+ @Override
+ public void field(final String name) throws Exception {
+ if (skippedNames.contains(name)) {
+ return;
+ }
+
+ BwResource rs = (BwResource)top();
+
+ if (shareableContainedEntityTags(rs, name)) {
+ return;
+ }
+
+ if (name.equals("lastmod")) {
+ rs.setLastmod(stringFld());
+
+ } else if (name.equals("sequence")) {
+ rs.setSequence(intFld());
+
+ } else if (name.equals("created")) {
+ rs.setCreated(stringFld());
+
+ } else if (name.equals("name")) {
+ rs.setName(stringFld());
+
+ } else if (name.equals("contentType")) {
+ rs.setContentType(stringFld());
+
+ } else if (name.equals("encoding")) {
+ rs.setEncoding(stringFld());
+
+ } else if (name.equals("contentLength")) {
+ rs.setContentLength(longFld());
+
+ } else if (name.equals("byteSize")) {
+ rs.setByteSize(intFld());
+ } else {
+ unknownTag(name);
+ }
+ }
+}
+
Added: trunk/src/org/bedework/dumprestore/restore/rules/ResourceRule.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/ResourceRule.java (rev 0)
+++ trunk/src/org/bedework/dumprestore/restore/rules/ResourceRule.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -0,0 +1,64 @@
+/* ********************************************************************
+ Licensed to Jasig under one or more contributor license
+ agreements. See the NOTICE file distributed with this work
+ for additional information regarding copyright ownership.
+ Jasig licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a
+ copy of the License at:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+package org.bedework.dumprestore.restore.rules;
+
+import org.bedework.calfacade.BwResource;
+import org.bedework.dumprestore.restore.RestoreGlobals;
+
+/**
+ * @author Mike Douglass douglm rpi.edu
+ * @version 1.0
+ */
+public class ResourceRule extends EntityRule {
+ /** Cobstructor
+ *
+ * @param globals
+ */
+ public ResourceRule(final RestoreGlobals globals) {
+ super(globals);
+ }
+
+ @Override
+ public void end(final String ns, final String name) throws Exception {
+ BwResource entity = (BwResource)pop();
+
+ try {
+ if (entity.getOwnerHref() == null) {
+ error("Missing owner for " + entity);
+ return;
+ }
+
+ if (entity.getContent() == null) {
+ error("Missing content for " + entity);
+ return;
+ }
+
+ globals.counts[globals.resources]++;
+
+ if (globals.rintf != null) {
+ globals.rintf.restoreResource(entity);
+ }
+ } catch (Throwable t) {
+ error("Unable to restore admin group " + entity);
+ throw new Exception(t);
+ }
+ }
+}
+
Modified: trunk/src/org/bedework/dumprestore/restore/rules/RestoreRuleSet.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/RestoreRuleSet.java 2012-03-09 02:57:59 UTC (rev 464)
+++ trunk/src/org/bedework/dumprestore/restore/rules/RestoreRuleSet.java 2012-04-22 02:59:41 UTC (rev 465)
@@ -288,6 +288,13 @@
d.addRule("*/filter/?", ffr);
+ ResourceFieldRule rfr = new ResourceFieldRule(globals);
+ d.addRule("caldata/resources", new SectionRule(globals, sectionResources));
+ d.addRule("caldata/resources/resource", new ResourceRule(globals));
+ d.addRule("*/resource/?", rfr);
+ d.addRule("*/resource/content", new ResourceContentRule(globals));
+ d.addRule("*/resource/content/?", new ResourceContentFieldRule(globals));
+
/* ------------------ For imports from previous versions ----------------- */
// PRE3.5
More information about the Bedework-commit
mailing list