// START TRANSACTION
try {
orgSession.getSessionManager().beginTransaction();
} catch (DfException e) {
monitor.log().debug(e);
throw new CaoException(e);
}
}
try {
session = orgSession.getSessionManager().getSession(orgSession.getDocbaseName());
monitor.beginTask("count", CaoMonitor.UNKNOWN);
int cnt = 0;
for (Object element : sources.getElements()) {
cnt = count( (DctmElement)element, cnt );
}
monitor.beginTask("copy", cnt);
cnt = 0;
for (Object element : sources.getElements()) {
cnt = copy( target, (DctmElement)element, cnt );
// element.getConnection().fireElementCreated(target.getId()+"/"+element.getName());
}
session.getSessionManager().release(session);
if (useTransaction) {
monitor.log().debug("Commit transaction");
orgSession.getSessionManager().commitTransaction();
}
} catch (Throwable t) {
monitor.log().error(t);
if (session!=null) session.getSessionManager().release(session);
if (useTransaction) {
monitor.log().debug("Abort transaction");
try {
orgSession.getSessionManager().abortTransaction();
} catch (DfException e) {
monitor.log().debug(e);
throw new CaoException(e);
}
}
}
session = null;