cmailleux 2005/10/03 18:32:26 CEST
Modified files:
core/src/java/org/jahia/services/importexport
ImportExportBaseService.java
Log:
Use the first date of the homepage revisions to start for first execution of
an export
Revision Changes Path
1.30 +39 -15
jahia/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java.diff?r1=1.29&r2=1.30&f=h
Index: ImportExportBaseService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ImportExportBaseService.java 30 Sep 2005 16:17:20 -0000 1.29
+++ ImportExportBaseService.java 3 Oct 2005 16:32:26 -0000 1.30
@@ -468,17 +468,6 @@
int vID = loadRequest.getVersionID();
if (vID == 0 && loadRequest.getWorkflowState() ==
EntryLoadRequest.ACTIVE_WORKFLOW_STATE) {
vID = 1;
- } else if (vID != 0) {
- SortedSet s = object.getEntryStates();
- for (Iterator iterator = s.iterator(); iterator.hasNext();) {
- ContentObjectEntryState contentObjectEntryState =
(ContentObjectEntryState) iterator.next();
- if (entryState == null ||
contentObjectEntryState.getVersionID() < vID) {
- entryState = contentObjectEntryState;
- } else {
- return entryState;
- }
- }
- return entryState;
}
if (object.isShared()) {
languageCode = ContentField.SHARED_LANGUAGE;
@@ -853,6 +842,20 @@
}
}
+ /**
+ * Export all modification on a site from a specified date, with a
particular profile.
+ * @param site the site to export
+ * @param targetName url of the site to upload the export result
+ * @param exportTime date of export
+ * @param username user on target site
+ * @param password password on target site
+ * @param previousCall date of previous call if null date of the first
version ever of the homepage of the source site
+ * @param member profile for export
+ * @return a webdav resource containing the result of the import
+ * @throws IOException
+ * @throws JahiaException
+ * @throws SAXException
+ */
public WebdavResource exportToSite(JahiaSite site, String targetName,
Date exportTime, String username,
String password, Date previousCall,
JahiaUser member)
throws IOException, JahiaException, SAXException {
@@ -863,19 +866,40 @@
new String(Base64.decode(password)));
WebdavResource webdavSession = new WebdavResource(httpURL,
credentials, WebdavResource.NOACTION, 0);
EntryLoadRequest from = null;
+ final ContentPage homeContentPage = site.getHomeContentPage();
+ // There is a previous call so export only modification from this
point in time
if (previousCall != null) {
- from = new
EntryLoadRequest(EntryLoadRequest.ACTIVE_WORKFLOW_STATE, new
Long(previousCall.getTime()).intValue(),
site.getLanguageSettingsAsLocales(true));
+ from = new
EntryLoadRequest(EntryLoadRequest.VERSIONED_WORKFLOW_STATE, new
Long(previousCall.getTime()).intValue(),
site.getLanguageSettingsAsLocales(true));
+ } else {
+ // There is no previous call so try to find the first version
ever for the homepage of the source site
+ List list = homeContentPage.getClosestVersionedEntryStates(0);
+ int vID = 0;
+ if (list.size() > 0) {
+ // The homepage have been versionned so lets take the oldest
one (the smallest value)
+ vID = Integer.MAX_VALUE;
+ for (int i = 0; i < list.size(); i++) {
+ ContentObjectEntryState entryState =
(ContentObjectEntryState) list.get(i);
+ if (entryState.getVersionID() < vID) {
+ vID = entryState.getVersionID();
+ }
+ }
+ } else {
+ // No version ever so let's take the active one
+ vID = homeContentPage.getActiveVersionID();
+ }
+ from = new
EntryLoadRequest(EntryLoadRequest.VERSIONED_WORKFLOW_STATE, vID,
site.getLanguageSettingsAsLocales(true));
}
File tempFile = File.createTempFile("exportFromSite_" +
site.getSiteKey() + "_" +
dateOfExport, ".zip");
FileOutputStream out = new FileOutputStream(tempFile);
- ProcessingContext threadParamBean = new ProcessingContext(null,
exportTime.getTime(), site, member, site.getHomeContentPage());
- export(site.getHomeContentPage(), getSiteLanguages(site), out,
- threadParamBean, null, true, EntryLoadRequest.CURRENT, from);
+ ProcessingContext threadParamBean = new ProcessingContext(null,
exportTime.getTime(), site, member, homeContentPage);
+ export(homeContentPage, getSiteLanguages(site), out,
+ threadParamBean, null, false, EntryLoadRequest.CURRENT, from);
out.close();
FileInputStream inputStream = new FileInputStream(tempFile);
webdavSession.putMethod(inputStream);
inputStream.close();
+ tempFile.deleteOnExit();
return webdavSession;
}