tdraier 2005/12/21 15:49:02 CET
Modified files:
core/src/java/org/jahia/services/importexport
ImportExportBaseService.java
ImportExportService.java
Log:
few updates on diff import and linked import
Revision Changes Path
1.58 +62 -57
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.57&r2=1.58&f=h
1.15 +3 -0
jahia/core/src/java/org/jahia/services/importexport/ImportExportService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/importexport/ImportExportService.java.diff?r1=1.14&r2=1.15&f=h
Index: ImportExportBaseService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/importexport/ImportExportBaseService.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- ImportExportBaseService.java 7 Dec 2005 15:42:23 -0000 1.57
+++ ImportExportBaseService.java 21 Dec 2005 14:49:01 -0000 1.58
@@ -177,20 +177,28 @@
}
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, null, false);
+ export(object, languageCode, h, files, jParams, included,
EntryLoadRequest.CURRENT, (EntryLoadRequest)null, false);
}
- public void export(ContentObject object, String language, ContentHandler
h, Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, EntryLoadRequest fromLoadRequest, boolean link) throws
JahiaException, SAXException {
+ public void export(ContentObject object, String languageCode,
ContentHandler h, Set files, ProcessingContext jParams, Set included,
EntryLoadRequest toLoadRequest, EntryLoadRequest fromLoadRequest, boolean link)
throws JahiaException, SAXException {
+ Map froms = new HashMap();
+ froms.put(null, fromLoadRequest);
+ export(object, languageCode, h, files, jParams, included,
EntryLoadRequest.CURRENT, froms, link);
+ }
+
+ public void export(ContentObject object, String language, ContentHandler
h, Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, Map froms, boolean link) throws JahiaException, SAXException {
toLoadRequest = new EntryLoadRequest(toLoadRequest);
toLoadRequest.setFirstLocale(language);
- if (fromLoadRequest != null) {
- fromLoadRequest = new EntryLoadRequest(fromLoadRequest);
- fromLoadRequest.setFirstLocale(language);
-
-// export(object, language, p, files, jParams, included, true,
toLoadRequest, fromLoadRequest, false, pruneMode)
+ 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);
+ froms.put(key,fromLoadRequest);
+ }
}
-
h.startDocument();
h.startPrefixMapping("jahia", JAHIA_URI);
@@ -204,12 +212,12 @@
Stack elementStack = new Stack();
elementStack.add(new Siblings());
- export(object, language, h, files, jParams, included, true,
toLoadRequest, fromLoadRequest, link, elementStack);
+ export(object, language, h, files, jParams, included, true, false,
toLoadRequest, froms, link, elementStack);
h.endDocument();
}
- private void export(ContentObject object, String language,
ContentHandler h, Set files, ProcessingContext jParams, Set included, boolean
top, EntryLoadRequest toLoadRequest, EntryLoadRequest fromLoadRequest, boolean
link, Stack elementStack) throws JahiaException, SAXException {
+ private void export(ContentObject object, String language,
ContentHandler h, Set files, ProcessingContext jParams, Set included, boolean
top, boolean parentAdded, EntryLoadRequest toLoadRequest, Map froms, boolean
link, Stack elementStack) throws JahiaException, SAXException {
try {
AttributesImpl attr = new AttributesImpl();
if (top) {
@@ -234,8 +242,22 @@
ContentObjectEntryState entryState = getEntryState(object,
language, toLoadRequest);
+ String uuid = getUuid(object);
+
+ EntryLoadRequest fromLoadRequest = (EntryLoadRequest)
froms.get(uuid);
+ if (fromLoadRequest == null) {
+ fromLoadRequest = (EntryLoadRequest) froms.get(null);
+ }
+
if (fromLoadRequest != null) {
int stat = getDiffStatus(object, language, fromLoadRequest,
toLoadRequest);
+ if (parentAdded) {
+ if (stat == VersioningDifferenceStatus.TO_BE_REMOVED) {
+ return;
+ } else {
+ stat = VersioningDifferenceStatus.ADDED;
+ }
+ }
switch (stat) {
case VersioningDifferenceStatus.UNCHANGED:
changedStatus = "unchanged";
@@ -252,6 +274,8 @@
view = false;
break;
}
+ } else if (!froms.isEmpty()) {
+ changedStatus = "added";
} else if (!(object instanceof ContentPage) && entryState ==
null) {
return;
}
@@ -296,7 +320,7 @@
attr.addAttribute(JAHIA_URI, "title",
"jahia:title", "CDATA", title);
}
}
- attr.addAttribute(JCR_URI, "uuid", "jcr:uuid",
"CDATA", getUuid(object));
+ attr.addAttribute(JCR_URI, "uuid", "jcr:uuid",
"CDATA", uuid);
break;
}
} else if (object instanceof ContentContainerList) {
@@ -334,7 +358,7 @@
}
}
- attr.addAttribute(JCR_URI, "uuid", "jcr:uuid", "CDATA",
getUuid(object));
+ attr.addAttribute(JCR_URI, "uuid", "jcr:uuid", "CDATA",
uuid);
} else if (object instanceof ContentContainer) {
ContentContainer cc = (ContentContainer) object;
ContainerDefinitionKey cdk = (ContainerDefinitionKey)
cc.getDefinitionKey(toLoadRequest);
@@ -345,7 +369,7 @@
attr.addAttribute(JCR_URI, "primaryType",
"jcr:primaryType", "CDATA", jParams.getSiteKey()+"nt:"+pt);
}
elementName = jcd.getName();
- attr.addAttribute(JCR_URI, "uuid", "jcr:uuid", "CDATA",
getUuid(object));
+ attr.addAttribute(JCR_URI, "uuid", "jcr:uuid", "CDATA",
uuid);
} else if (object instanceof ContentField) {
ContentField cf = (ContentField) object;
FieldDefinitionKey fdk = (FieldDefinitionKey)
cf.getDefinitionKey(toLoadRequest);
@@ -354,7 +378,7 @@
if (view) {
String fieldValue = getFieldValue(cf, files, jParams,
entryState, attr);
- attr.addAttribute(JCR_URI, "uuid", "jcr:uuid", "CDATA",
getUuid(object));
+ attr.addAttribute(JCR_URI, "uuid", "jcr:uuid", "CDATA",
uuid);
if (fieldValue != null && !(object instanceof
ContentPageField)) {
attr.addAttribute(JAHIA_URI, "value", "jahia:value",
"CDATA", fieldValue);
}
@@ -399,12 +423,17 @@
if (changedStatus != null) {
attr.addAttribute(JAHIA_URI, "diff", "jahia:diff", "CDATA",
changedStatus);
}
- JahiaBaseACL acl = new JahiaBaseACL (object.getAclID());
- String attrName = "acl";
- exportAcl(acl, "acl", attr, top);
+ if (!link) {
+ JahiaBaseACL acl = object.getACL();
+ exportAcl(acl, "acl", attr, top);
+ }
+
if (link) {
attr.addAttribute(JAHIA_URI, "linkkey", "jahia:linkkey",
"CDATA", object.getObjectKey().toString());
+ if (entryState != null && entryState.getVersionID()>0) {
+ attr.addAttribute(JAHIA_URI, "version", "jahia:version",
"CDATA", Integer.toString(entryState.getVersionID()));
+ }
}
currentElement = new Element(uri, elementName, prefix + ":" +
elementName, attr);
@@ -451,10 +480,10 @@
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, toLoadRequest, fromLoadRequest, link, elementStack);
+ export(child, language, h, files, jParams, included,
false, "added".equals(changedStatus), toLoadRequest, froms, link, elementStack);
} else if (object instanceof ContentContainerList &&
fromLoadRequest != null) {
if
(((ContentContainer)child).getJahiaContainer(jParams,fromLoadRequest) != null) {
- export(child, language, h, files, jParams,
included, false, fromLoadRequest, fromLoadRequest, link, elementStack);
+ export(child, language, h, files, jParams,
included, false, "added".equals(changedStatus), fromLoadRequest, froms, link,
elementStack);
}
}
}
@@ -631,7 +660,7 @@
entryState =
ContentObjectEntryState.getEntryState (vID,
languageCode);
- entryState = object.getEntryState (entryState, true, true);
+ entryState = object.getEntryState (entryState, false, true);
return entryState;
}
@@ -702,9 +731,9 @@
locale = jParams.getLocale().toString();
}
if (obj == null) {
- obj = importDocument(parent, locale, jParams, is,
false, false);
+ obj = importDocument(parent, locale, jParams, is,
false, setUuid);
} else {
- importDocument(obj, locale, jParams, is, true,
false);
+ importDocument(obj, locale, jParams, is, true,
setUuid);
}
} else if (name.equals("filesacl.xml")) {
importFilesAcl(jParams, is);
@@ -776,6 +805,7 @@
ImportHandler handler = new ImportHandler(parent,jParams, lang);
handler.setUpdateOnly(updateOnly);
+ handler.setCopyUuid(setUuid);
parser.parse(is, handler);
return handler.getLastObject();
@@ -788,38 +818,10 @@
}
public String getUuid(ContentObject object) throws JahiaException {
- String uuid = null;
- if (object instanceof ContentField) {
- uuid = (String)
((ContentField)object).getProperties().get("uuid");
- if (uuid == null) {
- uuid = idGen.nextIdentifier().toString();
- ((ContentField)object).getProperties().put("uuid", uuid);
- ((ContentField)object).storeProperties();
- }
- } else if (object instanceof ContentPage) {
- PageProperty pageLocalProperty =
((ContentPage)object).getPageLocalProperty("uuid");
- if (pageLocalProperty == null) {
- uuid = idGen.nextIdentifier().toString();
- ((ContentPage)object).setProperty("uuid",uuid);
- } else {
- uuid = (String) pageLocalProperty.getValue();
- }
- } else if (object instanceof ContentContainer) {
- uuid = (String)
ServicesRegistry.getInstance().getJahiaContainersService().getContainerProperties(object.getID()).get("uuid");
- if (uuid == null) {
- uuid = idGen.nextIdentifier().toString();
- Map p =
ServicesRegistry.getInstance().getJahiaContainersService().getContainerProperties(object.getID());
- p.put("uuid",uuid);
-
ServicesRegistry.getInstance().getJahiaContainersService().setContainerProperties(object.getID(),
object.getSiteID(), p);
- }
- } else if (object instanceof ContentContainerList) {
- uuid = (String)
ServicesRegistry.getInstance().getJahiaContainersService().getContainerListProperties(object.getID()).get("uuid");
- if (uuid == null) {
- uuid = idGen.nextIdentifier().toString();
- Map p =
ServicesRegistry.getInstance().getJahiaContainersService().getContainerListProperties(object.getID());
- p.put("uuid",uuid);
-
ServicesRegistry.getInstance().getJahiaContainersService().setContainerListProperties(object.getID(),
object.getSiteID(), p);
- }
+ String uuid = object.getProperty("uuid");
+ if (uuid == null) {
+ uuid = idGen.nextIdentifier().toString();
+ object.setProperty("uuid", uuid);
}
return uuid;
}
@@ -923,14 +925,17 @@
// Copy first lang only
ImportHandler handler = new ImportHandler(parentDest,jParams,
lang);
- export(source, lang, handler, null, jParams, null, loadRequest,
null, link);
+ handler.setCopyUuid(link);
+ export(source, lang, handler, null, jParams, null, loadRequest,
(EntryLoadRequest)null, link);
ContentObject main = handler.getLastObject();
-
for (;iterator.hasNext();) {
String nextLang = (String) iterator.next();
handler = new ImportHandler(main, jParams, nextLang);
handler.setUpdateOnly(true);
- export(source, nextLang, handler, null, jParams, null,
loadRequest, null, link);
+ export(source, nextLang, handler, null, jParams, null,
loadRequest, (EntryLoadRequest)null, link);
+ }
+ if (link) {
+ main.setProperty("lastPickedVersion",
Long.toString(System.currentTimeMillis()/1000));
}
return main;
Index: ImportExportService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/importexport/ImportExportService.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ImportExportService.java 5 Dec 2005 14:59:47 -0000 1.14
+++ ImportExportService.java 21 Dec 2005 14:49:01 -0000 1.15
@@ -20,6 +20,7 @@
import java.io.Reader;
import java.util.Set;
import java.util.Date;
+import java.util.Map;
import java.text.ParseException;
/**
@@ -63,6 +64,8 @@
void export(ContentObject object, String languageCodes, ContentHandler
h, Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, EntryLoadRequest fromLoadRequest, boolean link) throws
JahiaException, SAXException;
+ void export(ContentObject object, String languageCodes, ContentHandler
h, Set files, ProcessingContext jParams, Set included, EntryLoadRequest
toLoadRequest, Map froms, boolean link) throws JahiaException, SAXException;
+
void importFile(ContentObject parent, ProcessingContext jParams,
InputStream inputStream, boolean setUuid);
ContentObject importDocument(ContentObject parent, String lang,
ProcessingContext jParams, Reader reader, boolean updateOnly, boolean setUuid);