Author: tdraier
Date: Tue Jan 10 12:03:42 2006
New Revision: 12730
URL: https://jahia.mine.nu/websvn/listing.php?sc=1&rev=12730&repname=jahia
Log:
import export api updates
Added:
trunk/core/src/java/org/jahia/services/importexport/VersionNumberHandler.java
Modified:
trunk/core/src/java/org/jahia/engines/importexport/ExportEngine.java
trunk/core/src/java/org/jahia/engines/importexport/ManageImportExport.java
trunk/core/src/java/org/jahia/services/importexport/ActivationContentPickerJob.java
trunk/core/src/java/org/jahia/services/importexport/ChangeContentPickerJob.java
trunk/core/src/java/org/jahia/services/importexport/CopyJob.java
trunk/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java
trunk/core/src/java/org/jahia/services/importexport/ImportExportService.java
trunk/core/src/java/org/jahia/services/importexport/ImportHandler.java
Modified: trunk/core/src/java/org/jahia/engines/importexport/ExportEngine.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/engines/importexport/ExportEngine.java&rev=12730&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/engines/importexport/ExportEngine.java
(original)
+++ trunk/core/src/java/org/jahia/engines/importexport/ExportEngine.java Tue
Jan 10 12:03:42 2006
@@ -13,6 +13,7 @@
import org.jahia.services.importexport.ImportExportService;
import org.jahia.content.ContentObject;
import org.jahia.content.ContentObjectKey;
+import org.jahia.content.StructuralRelationship;
import org.jahia.registries.ServicesRegistry;
import org.jahia.tools.files.FileUpload;
import org.apache.log4j.Logger;
@@ -102,26 +103,29 @@
}
- EntryLoadRequest from = null;
- EntryLoadRequest to = EntryLoadRequest.CURRENT;
+ Map params = new HashMap();
+ params.put(ImportExportService.LINK,
StructuralRelationship.ACTIVATION_PICKER_LINK);
+
+ // EXPORT
if ("diff".equals(processingContext.getParameter("exporttype"))) {
- from = EntryLoadRequest.CURRENT;
- to = EntryLoadRequest.STAGED;
+ params.put(ImportExportService.FROM, EntryLoadRequest.CURRENT);
+ params.put(ImportExportService.TO, EntryLoadRequest.STAGED);
} else if
("staging".equals(processingContext.getParameter("exporttype"))) {
- to = EntryLoadRequest.STAGED;
+ params.put(ImportExportService.TO, EntryLoadRequest.STAGED);
}
HttpServletResponse resp =
((ParamBean)processingContext).getResponse();
ServletOutputStream outputStream = resp.getOutputStream();
ImportExportService ie =
ServicesRegistry.getInstance().getImportExportService();
if ("zipfiles".equals(processingContext.getParameter("exportformat")))
{
resp.setContentType("application/zip");
- ie.export(object, languageCodes, outputStream, processingContext,
null, true, to, from);
+ params.put(ImportExportService.INCLUDE_FILES, Boolean.TRUE);
+ ie.exportZip(object, languageCodes, outputStream,
processingContext, params);
} else if
("zipnofiles".equals(processingContext.getParameter("exportformat"))) {
resp.setContentType("application/zip");
- ie.export(object, languageCodes, outputStream, processingContext,
null, false, to, from);
+ ie.exportZip(object, languageCodes, outputStream,
processingContext, params);
} else {
resp.setContentType("text/xml");
- ie.export(object, processingContext.getLocale().toString(),
outputStream, processingContext, null, to, from);
+ ie.exportFile(object, processingContext.getLocale().toString(),
outputStream, processingContext, params);
}
outputStream.close();
}
Modified:
trunk/core/src/java/org/jahia/engines/importexport/ManageImportExport.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/engines/importexport/ManageImportExport.java&rev=12730&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/engines/importexport/ManageImportExport.java
(original)
+++ trunk/core/src/java/org/jahia/engines/importexport/ManageImportExport.java
Tue Jan 10 12:03:42 2006
@@ -1,6 +1,7 @@
package org.jahia.engines.importexport;
import org.jahia.content.ContentObject;
+import org.jahia.content.StructuralRelationship;
import org.jahia.engines.JahiaEngine;
import org.jahia.exceptions.JahiaException;
import org.jahia.exceptions.JahiaSessionExpirationException;
@@ -121,27 +122,29 @@
}
}
+ Map params = new HashMap();
+ params.put(ImportExportService.LINK,
StructuralRelationship.ACTIVATION_PICKER_LINK);
+
// EXPORT
- EntryLoadRequest from = null;
- EntryLoadRequest to = EntryLoadRequest.CURRENT;
if ("diff".equals(jParams.getParameter("exporttype"))) {
- from = EntryLoadRequest.CURRENT;
- to = EntryLoadRequest.STAGED;
+ params.put(ImportExportService.FROM, EntryLoadRequest.CURRENT);
+ params.put(ImportExportService.TO, EntryLoadRequest.STAGED);
} else if ("staging".equals(jParams.getParameter("exporttype"))) {
- to = EntryLoadRequest.STAGED;
+ params.put(ImportExportService.TO, EntryLoadRequest.STAGED);
}
HttpServletResponse resp = ((ParamBean)jParams).getResponse();
try {
ServletOutputStream outputStream = resp.getOutputStream();
if ("zipfiles".equals(jParams.getParameter("exportformat"))) {
resp.setContentType("application/zip");
- ie.export(object, languageCodes, outputStream, jParams,
null, true, to, from);
+ params.put(ImportExportService.INCLUDE_FILES,
Boolean.TRUE);
+ ie.exportZip(object, languageCodes, outputStream, jParams,
params);
} else if
("zipnofiles".equals(jParams.getParameter("exportformat"))) {
resp.setContentType("application/zip");
- ie.export(object, languageCodes, outputStream, jParams,
null, false, to, from);
+ ie.exportZip(object, languageCodes, outputStream, jParams,
params);
} else {
resp.setContentType("text/xml");
- ie.export(object, jParams.getLocale().toString(),
outputStream, jParams, null, to, from);
+ ie.exportFile(object, jParams.getLocale().toString(),
outputStream, jParams, params);
}
outputStream.close();
engineMap.put (JahiaEngine.RENDER_TYPE_PARAM, new Integer(-1));
Modified:
trunk/core/src/java/org/jahia/services/importexport/ActivationContentPickerJob.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/importexport/ActivationContentPickerJob.java&rev=12730&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/services/importexport/ActivationContentPickerJob.java
(original)
+++
trunk/core/src/java/org/jahia/services/importexport/ActivationContentPickerJob.java
Tue Jan 10 12:03:42 2006
@@ -9,7 +9,6 @@
import org.jahia.content.StructuralRelationship;
import org.jahia.exceptions.JahiaException;
import org.jahia.services.version.EntryLoadRequest;
-import org.jahia.services.version.StateModificationContext;
import org.jahia.services.usermanager.JahiaUser;
import org.jahia.services.usermanager.JahiaGroup;
import org.jahia.services.usermanager.JahiaGroupManagerService;
@@ -67,10 +66,16 @@
toLoadRequest.setWithDeleted(true);
// System.out.println("----------> "+froms);
// System.out.println("---------->
"+toLoadRequest);
- ie.export(pickedObject, lang, dw, files, jParams, null,
toLoadRequest, froms, StructuralRelationship.ACTIVATION_PICKER_LINK);
+
+ Map params = new HashMap();
+ params.put(ImportExportService.LINK,
StructuralRelationship.ACTIVATION_PICKER_LINK);
+ params.put(ImportExportService.FROM, froms);
+ params.put(ImportExportService.TO, toLoadRequest);
+
+ ie.export(pickedObject, lang, dw, files, jParams, params);
ImportHandler handler = new ImportHandler(picker,jParams,
lang, destSite);
handler.setCopyUuid(true);
- ie.export(pickedObject, lang, handler, files, jParams, null,
toLoadRequest, froms, StructuralRelationship.ACTIVATION_PICKER_LINK);
+ ie.export(pickedObject, lang, handler, files, jParams, params);
}
} catch (Throwable t) {
logger.error("Error when content picking content",t);
@@ -121,9 +126,9 @@
String name;
if (o.isShared()) {
- name = "lastPickedVersion";
+ name = "lastImportedVersion";
} else {
- name = "lastPickedVersion-" + lang;
+ name = "lastImportedVersion-" + lang;
}
String last = o.getProperty(name);
if (last != null) {
Modified:
trunk/core/src/java/org/jahia/services/importexport/ChangeContentPickerJob.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/importexport/ChangeContentPickerJob.java&rev=12730&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/services/importexport/ChangeContentPickerJob.java
(original)
+++
trunk/core/src/java/org/jahia/services/importexport/ChangeContentPickerJob.java
Tue Jan 10 12:03:42 2006
@@ -86,7 +86,13 @@
handler.setUpdateOnly(true);
Set included = new HashSet();
included.add(source);
- ie.export(source, language, handler, null,
context, included ,EntryLoadRequest.STAGED, (EntryLoadRequest) null,
StructuralRelationship.CHANGE_PICKER_LINK);
+
+ Map params = new HashMap();
+ params.put(ImportExportService.LINK,
StructuralRelationship.CHANGE_PICKER_LINK);
+ params.put(ImportExportService.TO,
EntryLoadRequest.STAGED);
+ params.put(ImportExportService.INCLUDED,
included);
+
+ ie.export(source, language, handler, null,
context, params);
}
} catch (Throwable t) {
logger.error("Error when content picking
content",t);
@@ -111,7 +117,12 @@
checkFilesInChildren(source, context, ie,
destSite);
ImportHandler handler = new
ImportHandler(picker,context, language, destSite);
handler.setCopyUuid(true);
- ie.export(source, language, handler, null,
context, null ,EntryLoadRequest.STAGED, (EntryLoadRequest) null,
StructuralRelationship.CHANGE_PICKER_LINK);
+
+ Map params = new HashMap();
+ params.put(ImportExportService.LINK,
StructuralRelationship.CHANGE_PICKER_LINK);
+ params.put(ImportExportService.TO,
EntryLoadRequest.STAGED);
+
+ ie.export(source, language, handler, null,
context, params);
} catch (Throwable t) {
logger.error("Error when content picking
content",t);
} finally {
Modified: trunk/core/src/java/org/jahia/services/importexport/CopyJob.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/importexport/CopyJob.java&rev=12730&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/services/importexport/CopyJob.java (original)
+++ trunk/core/src/java/org/jahia/services/importexport/CopyJob.java Tue Jan 10
12:03:42 2006
@@ -47,13 +47,19 @@
ImportHandler handler = new ImportHandler(copy,context, lang);
handler.setCopyUuid(link != null);
-
ServicesRegistry.getInstance().getImportExportService().export(source, lang,
handler, null, context, null, EntryLoadRequest.STAGED,
EntryLoadRequest.CURRENT, link);
+
+ Map params = new HashMap();
+ params.put(ImportExportService.LINK, link);
+ params.put(ImportExportService.TO, EntryLoadRequest.STAGED);
+ params.put(ImportExportService.FROM, EntryLoadRequest.CURRENT);
+
+
ServicesRegistry.getInstance().getImportExportService().export(source, lang,
handler, null, context, params);
ContentObject main = handler.getLastObject();
for (;iterator.hasNext();) {
String nextLang = (String) iterator.next();
handler = new ImportHandler(main, context, nextLang);
handler.setUpdateOnly(true);
-
ServicesRegistry.getInstance().getImportExportService().export(source,
nextLang, handler, null, context, null, EntryLoadRequest.STAGED,
(EntryLoadRequest) null, link);
+
ServicesRegistry.getInstance().getImportExportService().export(source,
nextLang, handler, null, context, params);
}
ServicesRegistry.getInstance().getWorkflowService().setWorkflowMode(main,
WorkflowService.INACTIVE, null, null, context);
} else {
Modified:
trunk/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java&rev=12730&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java
(original)
+++
trunk/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java
Tue Jan 10 12:03:42 2006
@@ -111,31 +111,19 @@
this.platformTransactionManager = platformTransactionManager;
}
- public Document export(ContentObject object, String languageCodes,
ProcessingContext jParams, Set included) throws JahiaException, SAXException {
- return export(object, languageCodes, jParams, included,
EntryLoadRequest.CURRENT, null);
- }
-
- public Document export(ContentObject object, String languageCodes,
ProcessingContext jParams, Set included, EntryLoadRequest toLoadRequest,
EntryLoadRequest fromLoadRequest) throws JahiaException, SAXException {
+ public Document exportDocument(ContentObject object, String languageCodes,
ProcessingContext jParams, Map params) throws JahiaException, SAXException {
DocumentImpl doc = new DocumentImpl();
DOMBuilder db = new DOMBuilder(doc,doc);
- export(object, languageCodes, db, new HashSet(), jParams, included,
toLoadRequest, fromLoadRequest, null);
+ export(object, languageCodes, db, new HashSet(), jParams, params);
return doc;
}
- public void export(ContentObject object, String languageCode, OutputStream
out, ProcessingContext jParams, Set included) throws JahiaException,
SAXException, IOException {
- export(object, languageCode, out, jParams, included,
EntryLoadRequest.CURRENT, null);
- }
-
- public void export(ContentObject object, String languageCode, OutputStream
out, ProcessingContext jParams, Set included, EntryLoadRequest toLoadRequest,
EntryLoadRequest fromLoadRequest) throws JahiaException, SAXException,
IOException {
+ public void exportFile(ContentObject object, String languageCode,
OutputStream out, ProcessingContext jParams, Map params) throws JahiaException,
SAXException, IOException {
DataWriter dw = new DataWriter(new OutputStreamWriter(out, "UTF-8"));
- export(object, languageCode, dw, new HashSet(), jParams, included,
toLoadRequest, fromLoadRequest, null);
- }
-
- public void export(ContentObject object, Set languageCodes, OutputStream
out, ProcessingContext jParams, Set included, boolean zipWithFiles) throws
JahiaException, SAXException, IOException {
- export(object, languageCodes, out, jParams, included, zipWithFiles,
EntryLoadRequest.CURRENT, null);
+ export(object, languageCode, dw, new HashSet(), jParams, params);
}
- public void export(ContentObject object, Set languageCodes, OutputStream
out, ProcessingContext jParams, Set included, boolean zipWithFiles,
EntryLoadRequest toLoadRequest, EntryLoadRequest fromLoadRequest) throws
JahiaException, SAXException, IOException {
+ public void exportZip(ContentObject object, Set languageCodes,
OutputStream out, ProcessingContext jParams, Map params) throws JahiaException,
SAXException, IOException {
Set files = new HashSet();
byte[] buffer = new byte[4096];
@@ -150,10 +138,10 @@
zout.putNextEntry(anEntry);
DataWriter dw = new DataWriter(new OutputStreamWriter(zout,
"UTF-8"));
- export(object, l, dw, files, jParams, included, toLoadRequest,
fromLoadRequest, null);
+ export(object, l, dw, files, jParams, params);
}
- if (zipWithFiles) {
+ if (params != null && Boolean.TRUE.equals(params.get(INCLUDE_FILES))) {
ZipEntry anEntry = new ZipEntry("filesacl.xml");
zout.putNextEntry(anEntry);
@@ -177,29 +165,42 @@
zout.close();
}
- public void export(ContentObject object, String languageCode,
ContentHandler h, Set files, ProcessingContext jParams, Set included) throws
JahiaException, SAXException {
- export(object, languageCode, h, files, jParams, included,
EntryLoadRequest.CURRENT, (EntryLoadRequest)null, null);
- }
+ public void export(ContentObject object, String languageCode,
ContentHandler h, Set files, ProcessingContext jParams, Map params) throws
JahiaException, SAXException {
+ if (params == null) {
+ params = new HashMap();
+ }
+ EntryLoadRequest toLoadRequest = (EntryLoadRequest) params.get(TO);
+ if (toLoadRequest == null) {
+ toLoadRequest = new EntryLoadRequest(EntryLoadRequest.CURRENT);
+ } else {
+ toLoadRequest = new EntryLoadRequest(toLoadRequest);
+ }
- public void export(ContentObject object, String languageCode,
ContentHandler h, Set files, ProcessingContext jParams, Set included,
EntryLoadRequest toLoadRequest, EntryLoadRequest fromLoadRequest, String link)
throws JahiaException, SAXException {
- Map froms = new HashMap();
- froms.put(null, fromLoadRequest);
- export(object, languageCode, h, files, jParams, included,
toLoadRequest, froms, link);
- }
+ toLoadRequest.setFirstLocale(languageCode);
+ params.put(TO, toLoadRequest);
- public void export(ContentObject object, String language, ContentHandler
h, Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, Map froms, String link) throws JahiaException, SAXException {
- toLoadRequest = new EntryLoadRequest(toLoadRequest);
- toLoadRequest.setFirstLocale(language);
+ Object from = params.get(FROM);
+ Map froms;
+ if (from instanceof Map) {
+ froms = (Map) from;
+ } else {
+ froms = new HashMap();
+ if (from != null) {
+ froms.put(null, from);
+ }
+ }
for (Iterator iterator = new HashSet(froms.keySet()).iterator();
iterator.hasNext();) {
String key = (String) iterator.next();
EntryLoadRequest fromLoadRequest = (EntryLoadRequest)
froms.get(key);
if (fromLoadRequest != null) {
fromLoadRequest = new EntryLoadRequest(fromLoadRequest);
- fromLoadRequest.setFirstLocale(language);
+ fromLoadRequest.setFirstLocale(languageCode);
froms.put(key,fromLoadRequest);
}
}
+ params.put(FROM, froms);
+
h.startDocument();
h.startPrefixMapping("jahia", JAHIA_URI);
@@ -213,12 +214,12 @@
Stack elementStack = new Stack();
elementStack.add(new Siblings());
- export(object, language, h, files, jParams, included, true, false,
toLoadRequest, froms, link, elementStack);
+ export(object, languageCode, h, files, jParams, params, true, false,
elementStack);
h.endDocument();
}
- private void export(ContentObject object, String language, ContentHandler
h, Set files, ProcessingContext jParams, Set included, boolean top, boolean
parentAdded, EntryLoadRequest toLoadRequest, Map froms, String link, Stack
elementStack) throws JahiaException, SAXException {
+ private void export(ContentObject object, String languageCode,
ContentHandler h, Set files, ProcessingContext jParams, Map params, boolean
top, boolean parentAdded, Stack elementStack) throws JahiaException,
SAXException {
try {
AttributesImpl attr = new AttributesImpl();
if (top) {
@@ -235,13 +236,26 @@
Siblings mySiblings = (Siblings) elementStack.peek();
String changedStatus = null;
- boolean view = true;
if (!object.checkReadAccess(jParams.getUser())) {
return;
}
- ContentObjectEntryState entryState = getEntryState(object,
language, toLoadRequest);
+ boolean view = !Boolean.FALSE.equals(params.get(VIEW_CONTENT));
+ boolean viewVersionNumbers =
Boolean.TRUE.equals(params.get(VIEW_CONTENT));
+ boolean viewAcl = !Boolean.FALSE.equals(params.get(VIEW_CONTENT));
+ boolean viewMetadata =
!Boolean.FALSE.equals(params.get(VIEW_CONTENT));
+ String link = (String) params.get(LINK);
+
+ if (link != null) {
+ viewAcl = false;
+ viewVersionNumbers = true;
+ }
+
+ EntryLoadRequest toLoadRequest = (EntryLoadRequest) params.get(TO);
+ Map froms = (Map) params.get(FROM);
+
+ ContentObjectEntryState entryState = getEntryState(object,
languageCode, toLoadRequest);
String uuid = getUuid(object);
@@ -251,7 +265,7 @@
}
if (fromLoadRequest != null) {
- int stat = getDiffStatus(object, language, fromLoadRequest,
toLoadRequest);
+ int stat = getDiffStatus(object, languageCode,
fromLoadRequest, toLoadRequest);
if (parentAdded) {
if (stat == VersioningDifferenceStatus.TO_BE_REMOVED) {
return;
@@ -316,7 +330,7 @@
case JahiaPage.TYPE_URL:
elementName = "url";
if (view) {
- attr.addAttribute(JAHIA_URI, "value",
"jahia:value", "CDATA", cp.getURL(jParams, language));
+ attr.addAttribute(JAHIA_URI, "value",
"jahia:value", "CDATA", cp.getURL(jParams, languageCode));
if (title != null) {
attr.addAttribute(JAHIA_URI, "title",
"jahia:title", "CDATA", title);
}
@@ -337,23 +351,25 @@
Properties p = cc.getJahiaContainerList(jParams,
toLoadRequest).getProperties();
Enumeration en = p.keys();
- while (en.hasMoreElements()) {
- String s = (String) en.nextElement();
- if (s.startsWith("view_field_acl_")) {
- String prop = p.getProperty(s);
- if (prop != null) {
- try {
- int aclID = Integer.parseInt(prop);
- JahiaBaseACL theACL = null;
+ if (viewAcl) {
+ while (en.hasMoreElements()) {
+ String s = (String) en.nextElement();
+ if (s.startsWith("view_field_acl_")) {
+ String prop = p.getProperty(s);
+ if (prop != null) {
try {
- theACL = new JahiaBaseACL (aclID);
- exportAcl(theACL, s, attr, top);
- }
- catch (ACLNotFoundException ex) {
- }
- catch (JahiaException ex) {
+ int aclID = Integer.parseInt(prop);
+ JahiaBaseACL theACL = null;
+ try {
+ theACL = new JahiaBaseACL (aclID);
+ exportAcl(theACL, s, attr, top);
+ }
+ catch (ACLNotFoundException ex) {
+ }
+ catch (JahiaException ex) {
+ }
+ } catch ( Throwable t ){
}
- } catch ( Throwable t ){
}
}
}
@@ -387,7 +403,7 @@
}
- if (view) {
+ if (view && viewMetadata) {
// add meta data as properties or nodes ?
List md = object.getMetadatas();
for (Iterator iterator = md.iterator(); iterator.hasNext();) {
@@ -395,7 +411,7 @@
FieldDefinitionKey fdk = (FieldDefinitionKey)
metadataContentField.getDefinitionKey(toLoadRequest);
JahiaFieldDefinition jcd = (JahiaFieldDefinition)
ContentObject.getInstance(fdk);
String metadataName = jcd.getName();
- ContentObjectEntryState mdEntryState =
getEntryState(metadataContentField, language, toLoadRequest);
+ ContentObjectEntryState mdEntryState =
getEntryState(metadataContentField, languageCode, toLoadRequest);
if (mdEntryState != null) {
String fieldValue =
getFieldValue(metadataContentField, files, jParams, mdEntryState, attr);
if (fieldValue != null && !fieldValue.equals("")) {
@@ -425,7 +441,7 @@
attr.addAttribute(JAHIA_URI, "diff", "jahia:diff", "CDATA",
changedStatus);
}
- if (link == null) {
+ if (viewAcl) {
JahiaBaseACL acl = object.getACL();
exportAcl(acl, "acl", attr, top);
}
@@ -433,9 +449,22 @@
if (link != null) {
attr.addAttribute(JAHIA_URI, "linkkey", "jahia:linkkey",
"CDATA", object.getObjectKey().toString());
attr.addAttribute(JAHIA_URI, "linktype", "jahia:linktype",
"CDATA", link);
+ }
+
+ if (viewVersionNumbers) {
if (entryState != null && entryState.getVersionID()>0) {
attr.addAttribute(JAHIA_URI, "version", "jahia:version",
"CDATA", Integer.toString(entryState.getVersionID()));
}
+ String name;
+ if (object.isShared()) {
+ name = "lastImportedVersion";
+ } else {
+ name = "lastImportedVersion-" + languageCode;
+ }
+ String last = object.getProperty(name);
+ if (last != null) {
+ attr.addAttribute(JAHIA_URI, "lastImportedVersion",
"jahia:version", "CDATA", last);
+ }
}
currentElement = new Element(uri, elementName, prefix + ":" +
elementName, attr);
@@ -479,13 +508,14 @@
}
Siblings siblings = new Siblings();
elementStack.add(siblings);
+ Set included = (Set) params.get(INCLUDED);
for (Iterator iterator = l.iterator(); iterator.hasNext();) {
ContentObject child = (ContentObject) iterator.next();
if (included == null ||
included.contains(child.getObjectKey())) {
- export(child, language, h, files, jParams, included,
false, "added".equals(changedStatus), toLoadRequest, froms, link, elementStack);
+ export(child, languageCode, h, files, jParams, params,
false, "added".equals(changedStatus), elementStack);
} else if (object instanceof ContentContainerList &&
fromLoadRequest != null) {
if
(((ContentContainer)child).getJahiaContainer(jParams,fromLoadRequest) != null) {
- export(child, language, h, files, jParams,
included, false, "added".equals(changedStatus), fromLoadRequest, froms, link,
elementStack);
+ export(child, languageCode, h, files, jParams,
params, false, "added".equals(changedStatus), elementStack);
}
}
}
@@ -681,72 +711,69 @@
}
}
- public void importFile(ContentObject parent, final ProcessingContext
jParams, InputStream inputStream, boolean setUuid) {
+ public ContentObject importFile(ContentObject parent, final
ProcessingContext jParams, InputStream inputStream, boolean setUuid) throws
IOException {
final MyZipInputStream zis = new MyZipInputStream(inputStream);
Map xmlImports = new HashMap();
- try {
- ContentObject obj = null;
- while (true) {
- ZipEntry zipentry = zis.getNextEntry();
+ ContentObject obj = null;
+ while (true) {
+ ZipEntry zipentry = zis.getNextEntry();
- if (zipentry == null) break;
+ if (zipentry == null) break;
- String name = zipentry.getName();
+ String name = zipentry.getName();
- if (!name.startsWith("export") &&
!name.equals("filesacl.xml")) {
- name = "/" + name;
- if (zipentry.isDirectory()) {
- } else {
- DAVFileAccess dir = ensureDir(name.substring(0,
name.lastIndexOf('/')), jParams, jParams.getSite());
- String filename = name.substring(name.lastIndexOf('/')
+ 1);
- if (dir != null) {
- String contentType =
Jahia.getStaticServletConfig().getServletContext().getMimeType(filename);
- dir.beginTransaction();
- dir.uploadFile(filename, zis, zipentry.getSize(),
contentType);
- dir.commitTransaction();
- }
- }
+ if (!name.startsWith("export") && !name.equals("filesacl.xml")) {
+ name = "/" + name;
+ if (zipentry.isDirectory()) {
} else {
- OutputStream os = new ByteArrayOutputStream();
- byte[] buf = new byte[4096];
- int r;
- while ((r = zis.read(buf)) > 0) {
- os.write(buf,0,r);
+ DAVFileAccess dir = ensureDir(name.substring(0,
name.lastIndexOf('/')), jParams, jParams.getSite());
+ String filename = name.substring(name.lastIndexOf('/') +
1);
+ if (dir != null) {
+ String contentType =
Jahia.getStaticServletConfig().getServletContext().getMimeType(filename);
+ dir.beginTransaction();
+ dir.uploadFile(filename, zis, zipentry.getSize(),
contentType);
+ dir.commitTransaction();
}
- xmlImports.put(name, os);
}
- zis.closeEntry();
+ } else {
+ OutputStream os = new ByteArrayOutputStream();
+ byte[] buf = new byte[4096];
+ int r;
+ while ((r = zis.read(buf)) > 0) {
+ os.write(buf,0,r);
+ }
+ xmlImports.put(name, os);
}
+ zis.closeEntry();
+ }
- zis.myClose();
+ zis.myClose();
- for (Iterator iterator = xmlImports.keySet().iterator();
iterator.hasNext();) {
- String name = (String) iterator.next();
- ByteArrayOutputStream os = (ByteArrayOutputStream)
xmlImports.get(name);
- InputStream is = new ByteArrayInputStream(os.toByteArray());
+ for (Iterator iterator = xmlImports.keySet().iterator();
iterator.hasNext();) {
+ String name = (String) iterator.next();
+ ByteArrayOutputStream os = (ByteArrayOutputStream)
xmlImports.get(name);
+ InputStream is = new ByteArrayInputStream(os.toByteArray());
- if (name.startsWith("export")) {
- String locale;
- if (name.indexOf("_") != -1) {
- locale = name.substring(7,name.lastIndexOf("."));
- } else {
- locale = jParams.getLocale().toString();
- }
- if (obj == null) {
- obj = importDocument(parent, locale, jParams, is,
false, setUuid);
- } else {
- importDocument(obj, locale, jParams, is, true,
setUuid);
- }
- } else if (name.equals("filesacl.xml")) {
- importFilesAcl(jParams, is);
+ if (name.startsWith("export")) {
+ String locale;
+ if (name.indexOf("_") != -1) {
+ locale = name.substring(7,name.lastIndexOf("."));
+ } else {
+ locale = jParams.getLocale().toString();
+ }
+ if (obj == null) {
+ obj = importDocument(parent, locale, jParams, is, false,
setUuid);
+ } else {
+ importDocument(obj, locale, jParams, is, true, setUuid);
}
+ } else if (name.equals("filesacl.xml")) {
+ importFilesAcl(jParams, is);
}
- } catch (IOException e) {
- e.printStackTrace();
}
+ return obj;
}
- public DAVFileAccess ensureDir(String name, ProcessingContext jParams,
JahiaSite site) {
+ private DAVFileAccess ensureDir(String name, ProcessingContext jParams,
JahiaSite site) {
DAVFileAccess dir = JahiaWebdavBaseService.getInstance
().getDAVFileAccess (jParams, site, jParams.getUser(), name);
if (!dir.isValid()) {
int endIndex = name.lastIndexOf('/');
@@ -828,7 +855,7 @@
return uuid;
}
- public void exportFilesAcl(ContentHandler ch, Set files) throws
SAXException {
+ private void exportFilesAcl(ContentHandler ch, Set files) throws
SAXException {
ch.startDocument();
ch.startPrefixMapping("jahia", JAHIA_URI);
ch.endPrefixMapping("jahia");
@@ -873,7 +900,7 @@
ch.endDocument();
}
- public void importFilesAcl(ProcessingContext jParams, InputStream is) {
+ private void importFilesAcl(ProcessingContext jParams, InputStream is) {
try {
SAXParserFactory factory;
@@ -925,11 +952,15 @@
Iterator iterator = languages.iterator();
String lang = (String) iterator.next();
+ Map params = new HashMap();
+ params.put(LINK, link);
+ params.put(TO, loadRequest);
+
// Copy first lang only
ImportHandler handler = new ImportHandler(parentDest,jParams,
lang);
handler.setCopyUuid(link != null);
handler.setCopyReadAccessOnly(true);
- export(source, lang, handler, null, jParams, null, loadRequest,
(EntryLoadRequest)null, link);
+ export(source, lang, handler, null, jParams, params);
ContentObject main = handler.getLastObject();
for (;iterator.hasNext();) {
String nextLang = (String) iterator.next();
@@ -937,10 +968,10 @@
handler.setUpdateOnly(true);
handler.setCopyUuid(link != null);
handler.setCopyReadAccessOnly(true);
- export(source, nextLang, handler, null, jParams, null,
loadRequest, (EntryLoadRequest)null, link);
+ export(source, nextLang, handler, null, jParams, params);
}
if (StructuralRelationship.ACTIVATION_PICKER_LINK.equals(link)) {
- main.setProperty("lastPickedVersion",
Long.toString(System.currentTimeMillis()/1000));
+ main.setProperty("lastImportedVersion",
Long.toString(System.currentTimeMillis()/1000));
}
return main;
@@ -1094,8 +1125,13 @@
ProcessingContext threadParamBean = new ProcessingContext(null,
exportTime.getTime(), site, member, homeContentPage);
EntryLoadRequest toLoadRequest = new
EntryLoadRequest(EntryLoadRequest.VERSIONED_WORKFLOW_STATE, new
Long(System.currentTimeMillis()/1000).intValue(), languageSettingsAsLocales);
toLoadRequest.setWithDeleted(true);
- export(homeContentPage, getSiteLanguages(site), out,
- threadParamBean, null, true, toLoadRequest, from);
+
+ Map params = new HashMap();
+ params.put(TO, toLoadRequest);
+ params.put(FROM, from);
+ params.put(VIEW_VERSION, Boolean.TRUE);
+ params.put(INCLUDE_FILES, Boolean.TRUE);
+ exportZip(homeContentPage, getSiteLanguages(site), out,
threadParamBean, params);
out.close();
FileInputStream inputStream = new FileInputStream(tempFile);
webdavSession.putMethod(inputStream);
Modified:
trunk/core/src/java/org/jahia/services/importexport/ImportExportService.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/importexport/ImportExportService.java&rev=12730&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/services/importexport/ImportExportService.java
(original)
+++
trunk/core/src/java/org/jahia/services/importexport/ImportExportService.java
Tue Jan 10 12:03:42 2006
@@ -48,35 +48,37 @@
String PRODUCTION_CONTEXTNAME_PROPERTY = "prod_context_";
String PRODUCTION_ADDRESS_PROPERTY = "prod_address_";
- Document export(ContentObject object, String languageCodes,
ProcessingContext jParams, Set included) throws JahiaException, SAXException;
+ String FROM = "from";
+ String TO = "to";
+ String INCLUDE_FILES = "files";
+ String LINK = "link";
+ String VIEW_CONTENT = "content";
+ String VIEW_VERSION = "version";
+ String VIEW_METADATA = "metadata";
+ String VIEW_ACL = "acl";
+ String INCLUDED = "included";
- Document export(ContentObject object, String languageCodes,
ProcessingContext jParams, Set included, EntryLoadRequest toLoadRequest,
EntryLoadRequest fromLoadRequest) throws JahiaException, SAXException;
+ // Export
- void export(ContentObject object, Set languageCodes, OutputStream out,
ProcessingContext jParams, Set included, boolean zipWithFiles) throws
JahiaException, SAXException, IOException;
+ Document exportDocument(ContentObject object, String languageCode,
ProcessingContext jParams, Map params) throws JahiaException, SAXException;
- void export(ContentObject object, Set languageCodes, OutputStream out,
ProcessingContext jParams, Set included, boolean zipWithFiles, EntryLoadRequest
toLoadRequest, EntryLoadRequest fromLoadRequest) throws JahiaException,
SAXException, IOException;
+ void exportFile(ContentObject object, String languageCode, OutputStream
out, ProcessingContext jParams, Map params) throws JahiaException,
SAXException, IOException;
- void export(ContentObject object, String languageCode, OutputStream out,
ProcessingContext jParams, Set included) throws JahiaException, SAXException,
IOException;
+ void exportZip(ContentObject object, Set languageCodes, OutputStream out,
ProcessingContext jParams, Map params) throws JahiaException, SAXException,
IOException;
- void export(ContentObject object, String languageCode, OutputStream out,
ProcessingContext jParams, Set included, EntryLoadRequest toLoadRequest,
EntryLoadRequest fromLoadRequest) throws JahiaException, SAXException,
IOException;
+ void export(ContentObject object, String languageCodes, ContentHandler h,
Set files, ProcessingContext jParams, Map params) throws JahiaException,
SAXException;
- void export(ContentObject object, String languageCodes, ContentHandler h,
Set files, ProcessingContext jParams, Set included) throws JahiaException,
SAXException;
+ // Imports
- void export(ContentObject object, String languageCodes, ContentHandler h,
Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, EntryLoadRequest fromLoadRequest, String link) throws
JahiaException, SAXException;
-
- void export(ContentObject object, String languageCodes, ContentHandler h,
Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, Map froms, String link) throws JahiaException, SAXException;
-
- void importFile(ContentObject parent, ProcessingContext jParams,
InputStream inputStream, boolean setUuid);
+ ContentObject importFile(ContentObject parent, ProcessingContext jParams,
InputStream inputStream, boolean setUuid) throws IOException;
ContentObject importDocument(ContentObject parent, String lang,
ProcessingContext jParams, Reader reader, boolean updateOnly, boolean setUuid);
ContentObject importDocument(ContentObject parent, String lang,
ProcessingContext jParams, InputStream inputStream, boolean updateOnly, boolean
setUuid);
- ContentObject importDocument(ContentObject parent, String lang,
ProcessingContext jParams, InputSource is, boolean updateOnly, boolean setUuid);
+ ContentObject importDocument(ContentObject parent, String lang,
ProcessingContext jParams, InputSource inputSource, boolean updateOnly, boolean
setUuid);
- void exportFilesAcl(ContentHandler ch, Set files) throws SAXException;
-
- void importFilesAcl(ProcessingContext jParams, InputStream is);
+ // Copy
ContentObject copy(ContentObject source, ContentObject parentDest,
ProcessingContext jParams, EntryLoadRequest loadRequest, String link);
@@ -86,8 +88,6 @@
boolean isPicker(ContentObject object) throws JahiaException;
- DAVFileAccess ensureDir(String name, ProcessingContext jParams, JahiaSite
site);
-
void ensureFile(DAVFileAccess file, ProcessingContext jParams, JahiaSite
destSite);
WebdavResource exportToSite(JahiaSite site, String targetName, Date
exportTime, String username, String password, Date previousCall, JahiaUser
member, String sitename, String servletname) throws IOException,
JahiaException, SAXException;
Modified: trunk/core/src/java/org/jahia/services/importexport/ImportHandler.java
URL:
https://jahia.mine.nu/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/importexport/ImportHandler.java&rev=12730&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/services/importexport/ImportHandler.java
(original)
+++ trunk/core/src/java/org/jahia/services/importexport/ImportHandler.java Tue
Jan 10 12:03:42 2006
@@ -336,9 +336,9 @@
String version = atts.getValue(ImportExportBaseService.JAHIA_URI,
"version");
if (version != null) {
if (currentObject.isShared()) {
- currentObject.setProperty("lastPickedVersion", version);
+ currentObject.setProperty("lastImportedVersion", version);
} else {
- currentObject.setProperty("lastPickedVersion-"+language,
version);
+ currentObject.setProperty("lastImportedVersion-"+language,
version);
}
}
} catch (Throwable e) {
Added:
trunk/core/src/java/org/jahia/services/importexport/VersionNumberHandler.java
URL:
https://jahia.mine.nu/websvn/filedetails.php?path=/trunk/core/src/java/org/jahia/services/importexport/VersionNumberHandler.java&rev=12730&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/services/importexport/VersionNumberHandler.java
(added)
+++
trunk/core/src/java/org/jahia/services/importexport/VersionNumberHandler.java
Tue Jan 10 12:03:42 2006
@@ -0,0 +1,39 @@
+package org.jahia.services.importexport;
+
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.jahia.services.version.EntryLoadRequest;
+import org.jahia.params.ProcessingContext;
+import org.jahia.exceptions.JahiaException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: toto
+ * Date: 9 janv. 2006
+ * Time: 16:43:51
+ * To change this template use File | Settings | File Templates.
+ */
+public class VersionNumberHandler extends DefaultHandler {
+ private Map uuidToVersions = new HashMap();
+ private ProcessingContext jParams;
+
+ public VersionNumberHandler(ProcessingContext jParams) {
+ this.jParams = jParams;
+ }
+
+ public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
+ String value = attributes.getValue("lastImportedVersion");
+ if (value != null) {
+ try {
+ uuidToVersions.put(attributes.getValue("uuid"), new
EntryLoadRequest(EntryLoadRequest.VERSIONED_WORKFLOW_STATE,
Integer.parseInt(value), jParams.getLocales()));
+ } catch (JahiaException e) {
+ // ....
+ }
+ }
+ }
+
+}