Search in sources :

Example 1 with AliasEntry

use of org.bedework.dumprestore.AliasEntry in project bw-calendar-engine by Bedework.

the class Dumpling method dumpCollection.

private void dumpCollection(final BwCalendar col) throws Throwable {
    col.dump(xml);
    if (col.getInternalAlias() && !col.getTombstoned()) {
        final String target = col.getInternalAliasPath();
        final AliasInfo ai = new AliasInfo(col.getPath(), target, col.getPublick(), col.getOwnerHref());
        AliasEntry ae = globals.aliasInfo.get(target);
        if (ae == null) {
            ae = new AliasEntry();
            ae.setTargetPath(target);
            globals.aliasInfo.put(target, ae);
        }
        ae.getAliases().add(ai);
        globals.counts[globals.aliases]++;
    }
    if (col.getExternalSub() && !col.getTombstoned()) {
        globals.counts[globals.externalSubscriptions]++;
        globals.externalSubs.add(AliasInfo.getExternalSubInfo(col.getPath(), col.getAliasUri(), col.getPublick(), col.getOwnerHref()));
    }
    // Should I be dumping external subscriptions?
    final Collection<BwCalendar> cs = globals.di.getChildren(col);
    if (cs != null) {
        // noinspection unchecked
        dumpCollection((Iterator<T>) cs.iterator());
    }
}
Also used : AliasInfo(org.bedework.dumprestore.AliasInfo) AliasEntry(org.bedework.dumprestore.AliasEntry) BwCalendar(org.bedework.calfacade.BwCalendar)

Example 2 with AliasEntry

use of org.bedework.dumprestore.AliasEntry in project bw-calendar-engine by Bedework.

the class CalendarRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    final BwCalendar entity = (BwCalendar) pop();
    globals.counts[globals.collections]++;
    if ((globals.counts[globals.collections] % 100) == 0) {
        info("Restore calendar # " + globals.counts[globals.collections]);
    }
    fixSharableEntity(entity, "Calendar");
    if (!entity.getTombstoned()) {
        if (entity.getExternalSub()) {
            globals.counts[globals.externalSubscriptions]++;
            globals.externalSubs.add(AliasInfo.getExternalSubInfo(entity.getPath(), entity.getAliasUri(), entity.getPublick(), entity.getOwnerHref()));
        } else if (entity.getInternalAlias() && !entity.getPublick()) {
            final String target = entity.getInternalAliasPath();
            final AliasInfo ai = new AliasInfo(entity.getPath(), target, entity.getPublick(), entity.getOwnerHref());
            AliasEntry ae = globals.aliasInfo.get(target);
            if (ae == null) {
                ae = new AliasEntry();
                ae.setTargetPath(target);
                globals.aliasInfo.put(target, ae);
            }
            ae.getAliases().add(ai);
            globals.counts[globals.aliases]++;
        }
    }
    try {
        if (globals.rintf != null) {
            /* If the parent is null then this should be one of the root calendars,
         */
            final String parentPath = entity.getColPath();
            if (parentPath == null) {
                // Ensure root
                globals.rintf.saveRootCalendar(entity);
            } else {
                globals.rintf.addCalendar(entity);
            }
        }
    } catch (final Throwable t) {
        throw new Exception(t);
    }
}
Also used : AliasInfo(org.bedework.dumprestore.AliasInfo) BwCalendar(org.bedework.calfacade.BwCalendar) AliasEntry(org.bedework.dumprestore.AliasEntry)

Aggregations

BwCalendar (org.bedework.calfacade.BwCalendar)2 AliasEntry (org.bedework.dumprestore.AliasEntry)2 AliasInfo (org.bedework.dumprestore.AliasInfo)2