Incorporating TUV patches r1851/1853/1854/1855/1857
git-svn-id: https://svn.libreccm.org/ccm/trunk@97 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9434792c52
commit
01e3da6984
|
|
@ -59,7 +59,7 @@ public class DomainObjectMapper {
|
||||||
getSystemID(),
|
getSystemID(),
|
||||||
src.toString(),
|
src.toString(),
|
||||||
dst.getOID().toString());
|
dst.getOID().toString());
|
||||||
//mapping.save();
|
mapping.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSystemID() {
|
public String getSystemID() {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
package com.arsdigita.london.importer;
|
package com.arsdigita.london.importer;
|
||||||
|
|
||||||
import com.arsdigita.domain.DomainObject;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for TagParser implementations handling
|
* Base class for TagParser implementations handling
|
||||||
|
|
@ -13,7 +14,6 @@ import java.io.File;
|
||||||
*/
|
*/
|
||||||
public abstract class DomainObjectParser extends AbstractTagParser {
|
public abstract class DomainObjectParser extends AbstractTagParser {
|
||||||
|
|
||||||
private String m_objectType;
|
|
||||||
private DomainObject m_object;
|
private DomainObject m_object;
|
||||||
private File m_lobDir;
|
private File m_lobDir;
|
||||||
private DomainObjectMapper m_mapper;
|
private DomainObjectMapper m_mapper;
|
||||||
|
|
@ -34,8 +34,6 @@ public abstract class DomainObjectParser extends AbstractTagParser {
|
||||||
File lobDir,
|
File lobDir,
|
||||||
DomainObjectMapper mapper) {
|
DomainObjectMapper mapper) {
|
||||||
super(tagName, tagURI);
|
super(tagName, tagURI);
|
||||||
|
|
||||||
m_objectType = objectType;
|
|
||||||
m_lobDir = lobDir;
|
m_lobDir = lobDir;
|
||||||
m_mapper = mapper;
|
m_mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import com.arsdigita.runtime.RuntimeConfig;
|
||||||
* PDL for {@link RemoteOidMapping}.
|
* PDL for {@link RemoteOidMapping}.
|
||||||
*
|
*
|
||||||
* @author Sebastian Skracic (sskracic@redhat.com)
|
* @author Sebastian Skracic (sskracic@redhat.com)
|
||||||
* @version $Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $
|
|
||||||
*/
|
*/
|
||||||
public class Initializer extends CompoundInitializer {
|
public class Initializer extends CompoundInitializer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,24 +18,13 @@
|
||||||
|
|
||||||
package com.arsdigita.london.importer;
|
package com.arsdigita.london.importer;
|
||||||
|
|
||||||
import com.arsdigita.runtime.ScriptContext;
|
|
||||||
import com.arsdigita.loader.PackageLoader;
|
import com.arsdigita.loader.PackageLoader;
|
||||||
|
import com.arsdigita.runtime.ScriptContext;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader for importer application.
|
* Loader for importer application.
|
||||||
*
|
|
||||||
* @version $Id: Loader.java 287 2005-02-22 00:29:02Z sskracic $
|
|
||||||
*/
|
*/
|
||||||
public class Loader extends PackageLoader {
|
public class Loader extends PackageLoader {
|
||||||
public final static String versionId =
|
|
||||||
"$Id: Loader.java 287 2005-02-22 00:29:02Z sskracic $" +
|
|
||||||
"$Author: sskracic $" +
|
|
||||||
"$DateTime: 2004/01/30 08:35:49 $";
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(Loader.class);
|
|
||||||
|
|
||||||
public void run(final ScriptContext ctx) {
|
public void run(final ScriptContext ctx) {
|
||||||
// Nada yet
|
// Nada yet
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,20 @@ public class ParserDispatcher extends DefaultHandler {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try {
|
try {
|
||||||
is = new FileInputStream(new File(importFile));
|
is = new FileInputStream(new File(importFile));
|
||||||
|
XML.parse(is, this);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot load file " + importFile,
|
"cannot load file " + importFile,
|
||||||
ex);
|
ex);
|
||||||
|
} finally {
|
||||||
|
if (is != null) {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
s_log.warn("Failed to close " + importFile, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XML.parse(is, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,20 +18,15 @@
|
||||||
|
|
||||||
package com.arsdigita.london.importer.cms;
|
package com.arsdigita.london.importer.cms;
|
||||||
|
|
||||||
import com.arsdigita.london.util.Program;
|
|
||||||
import com.arsdigita.london.util.Transaction;
|
|
||||||
|
|
||||||
import com.arsdigita.london.importer.ParserDispatcher;
|
|
||||||
import com.arsdigita.london.importer.DomainObjectMapper;
|
|
||||||
import com.arsdigita.london.importer.ImportParser;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.london.importer.DomainObjectMapper;
|
||||||
|
import com.arsdigita.london.importer.ImportParser;
|
||||||
|
import com.arsdigita.london.importer.ParserDispatcher;
|
||||||
|
import com.arsdigita.london.util.Transaction;
|
||||||
|
import com.arsdigita.packaging.Program;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,15 +42,12 @@ import com.arsdigita.cms.ContentSection;
|
||||||
*/
|
*/
|
||||||
public class AssetImportTool extends Program {
|
public class AssetImportTool extends Program {
|
||||||
|
|
||||||
private List m_lazyItems;
|
|
||||||
|
|
||||||
public AssetImportTool() {
|
public AssetImportTool() {
|
||||||
super("Asset Import Tool",
|
super("Asset Import Tool",
|
||||||
"1.0.0",
|
"1.0.0",
|
||||||
"INDEX-FILE ASSET-DIR");
|
"INDEX-FILE ASSET-DIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void doRun(CommandLine cmdLine) {
|
protected void doRun(CommandLine cmdLine) {
|
||||||
final String[] args = cmdLine.getArgs();
|
final String[] args = cmdLine.getArgs();
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
|
|
@ -64,9 +56,6 @@ public class AssetImportTool extends Program {
|
||||||
}
|
}
|
||||||
final DomainObjectMapper mapper = new DomainObjectMapper();
|
final DomainObjectMapper mapper = new DomainObjectMapper();
|
||||||
|
|
||||||
ContentSection section = (ContentSection)ContentSection
|
|
||||||
.retrieveApplicationForPath("/content/");
|
|
||||||
|
|
||||||
Transaction session = new Transaction() {
|
Transaction session = new Transaction() {
|
||||||
public void doRun() {
|
public void doRun() {
|
||||||
ParserDispatcher parser = new ParserDispatcher();
|
ParserDispatcher parser = new ParserDispatcher();
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
package com.arsdigita.london.importer.cms;
|
package com.arsdigita.london.importer.cms;
|
||||||
|
|
||||||
import com.arsdigita.london.importer.DomainObjectMapper;
|
|
||||||
|
|
||||||
import com.arsdigita.cms.Asset;
|
|
||||||
import com.arsdigita.cms.CMS;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import com.arsdigita.cms.Asset;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.london.importer.DomainObjectMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asset importer, handling the <cms:asset> XML subblock.
|
* Asset importer, handling the <cms:asset> XML subblock.
|
||||||
|
|
@ -15,8 +12,6 @@ import org.apache.log4j.Logger;
|
||||||
* @see com.arsdigita.london.importer
|
* @see com.arsdigita.london.importer
|
||||||
*/
|
*/
|
||||||
public class AssetParser extends ItemParser {
|
public class AssetParser extends ItemParser {
|
||||||
private static Logger s_log =
|
|
||||||
Logger.getLogger(AssetParser.class);
|
|
||||||
|
|
||||||
public AssetParser(File lobDir, DomainObjectMapper mapper) {
|
public AssetParser(File lobDir, DomainObjectMapper mapper) {
|
||||||
this("asset", CMS.CMS_XML_NS, Asset.BASE_DATA_OBJECT_TYPE, lobDir, mapper);
|
this("asset", CMS.CMS_XML_NS, Asset.BASE_DATA_OBJECT_TYPE, lobDir, mapper);
|
||||||
|
|
|
||||||
|
|
@ -18,30 +18,26 @@
|
||||||
|
|
||||||
package com.arsdigita.london.importer.cms;
|
package com.arsdigita.london.importer.cms;
|
||||||
|
|
||||||
import com.arsdigita.london.util.Program;
|
|
||||||
import com.arsdigita.london.util.Transaction;
|
|
||||||
import com.arsdigita.london.importer.ParserDispatcher;
|
|
||||||
import com.arsdigita.london.importer.DomainObjectMapper;
|
|
||||||
import com.arsdigita.london.importer.ImportParser;
|
|
||||||
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import com.arsdigita.cms.ContentSection;
|
|
||||||
import com.arsdigita.cms.Folder;
|
|
||||||
import com.arsdigita.cms.ContentBundle;
|
|
||||||
import com.arsdigita.cms.ContentItem;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentBundle;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.Folder;
|
||||||
|
import com.arsdigita.london.importer.DomainObjectMapper;
|
||||||
|
import com.arsdigita.london.importer.ImportParser;
|
||||||
|
import com.arsdigita.london.importer.ParserDispatcher;
|
||||||
|
import com.arsdigita.london.util.Transaction;
|
||||||
|
import com.arsdigita.packaging.Program;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standalone command-line tool which invokes the importer.
|
* Standalone command-line tool which invokes the importer.
|
||||||
* It can be invoked by:
|
* It can be invoked by:
|
||||||
|
|
@ -62,6 +58,13 @@ public class ItemImportTool extends Program {
|
||||||
"INDEX-FILE ITEM-DIR ASSET-DIR");
|
"INDEX-FILE ITEM-DIR ASSET-DIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemImportTool(boolean startup) {
|
||||||
|
super("Item Import Tool",
|
||||||
|
"1.0.0",
|
||||||
|
"INDEX-FILE ITEM-DIR ASSET-DIR",
|
||||||
|
startup);
|
||||||
|
}
|
||||||
|
|
||||||
protected void doRun(CommandLine cmdLine) {
|
protected void doRun(CommandLine cmdLine) {
|
||||||
final String[] args = cmdLine.getArgs();
|
final String[] args = cmdLine.getArgs();
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class ItemParser extends DomainObjectParser {
|
||||||
* change from one CCM instance to another. Importer will not try
|
* change from one CCM instance to another. Importer will not try
|
||||||
* to create any of those.
|
* to create any of those.
|
||||||
*/
|
*/
|
||||||
public static final String[] GLOBAL_OID_TYPES = new String[] {
|
static final String[] GLOBAL_OID_TYPES = new String[] {
|
||||||
"com.arsdigita.cms.MimeType",
|
"com.arsdigita.cms.MimeType",
|
||||||
"com.arsdigita.cms.contenttypes.IsoCountry"
|
"com.arsdigita.cms.contenttypes.IsoCountry"
|
||||||
};
|
};
|
||||||
|
|
@ -342,7 +342,7 @@ public class ItemParser extends DomainObjectParser {
|
||||||
* @return the end of lifecycle date, might be null
|
* @return the end of lifecycle date, might be null
|
||||||
*/
|
*/
|
||||||
public Date getArchiveDate() {
|
public Date getArchiveDate() {
|
||||||
return m_archiveDate;
|
return (Date)m_archiveDate.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -397,7 +397,7 @@ public class ItemParser extends DomainObjectParser {
|
||||||
count = assocCount.intValue();
|
count = assocCount.intValue();
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
parentObject.put(propName + COUNT_SUFFIX, new Integer(count));
|
parentObject.put(propName + COUNT_SUFFIX, Integer.valueOf(count));
|
||||||
parentObject.put(propName + COUNT_SUFFIX + count, childObject);
|
parentObject.put(propName + COUNT_SUFFIX + count, childObject);
|
||||||
m_currentDataObject = parentObject;
|
m_currentDataObject = parentObject;
|
||||||
m_objectStack.pop();
|
m_objectStack.pop();
|
||||||
|
|
@ -544,7 +544,7 @@ public class ItemParser extends DomainObjectParser {
|
||||||
* retrieved and stored in the returned Map, and DO_NOT_SAVE flag set to TRUE.
|
* retrieved and stored in the returned Map, and DO_NOT_SAVE flag set to TRUE.
|
||||||
*/
|
*/
|
||||||
private Map getDataObject(OID srcOid) {
|
private Map getDataObject(OID srcOid) {
|
||||||
String type = getTypeFromOid(srcOid.toString());
|
String type = srcOid.getObjectType().getQualifiedName();
|
||||||
Map newDataObject = new HashMap();
|
Map newDataObject = new HashMap();
|
||||||
newDataObject.put(OID_ATTR, srcOid);
|
newDataObject.put(OID_ATTR, srcOid);
|
||||||
// For MimeType, OIDs are "global"
|
// For MimeType, OIDs are "global"
|
||||||
|
|
@ -580,25 +580,11 @@ public class ItemParser extends DomainObjectParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// <cms:item oid="[com.arsdigita.london.cms.dublin.types.DublinArticle:{id=34094}]">
|
|
||||||
private String getTypeFromOid(String oid) {
|
|
||||||
return oid.substring(0, oid.indexOf("-"));
|
|
||||||
//return oid.substring(oid.indexOf('[')+1, oid.indexOf(':'));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTypeFromOid(OID oid) {
|
|
||||||
return getTypeFromOid(oid.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ACSObject createACSObject(DataObject dobj, Map properties) {
|
private ACSObject createACSObject(DataObject dobj, Map properties) {
|
||||||
String domainClass = (String) properties.get(DEFAULT_DOMAIN_CLASS);
|
String domainClass = (String) properties.get(DEFAULT_DOMAIN_CLASS);
|
||||||
if (domainClass == null) {
|
if (domainClass == null) {
|
||||||
// Default to persistence ObjectType -- possibly dangerous.
|
// Default to persistence ObjectType -- possibly dangerous.
|
||||||
domainClass = getTypeFromOid(dobj.getOID());
|
domainClass = dobj.getOID().getObjectType().getQualifiedName();
|
||||||
}
|
}
|
||||||
debugLog("Creating " + domainClass + " ...");
|
debugLog("Creating " + domainClass + " ...");
|
||||||
try {
|
try {
|
||||||
|
|
@ -685,10 +671,6 @@ public class ItemParser extends DomainObjectParser {
|
||||||
FileInputStream in = null;
|
FileInputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = new FileInputStream(lobFile);
|
in = new FileInputStream(lobFile);
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
s_log.error("Lob file: " + lobFile + " does not exist!", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
|
|
@ -704,6 +686,15 @@ public class ItemParser extends DomainObjectParser {
|
||||||
dobj.put(key, content);
|
dobj.put(key, content);
|
||||||
debugLog("Successfully loaded file " + lobFile
|
debugLog("Successfully loaded file " + lobFile
|
||||||
+ ", length: " + content.length + " bytes");
|
+ ", length: " + content.length + " bytes");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
s_log.error("Lob file: " + lobFile + " does not exist!", e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
s_log.warn("Failed to close " + lobFile, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
s_log.warn("Don't know how to handle property " +
|
s_log.warn("Don't know how to handle property " +
|
||||||
key + ", type: " + propertyClass.getName());
|
key + ", type: " + propertyClass.getName());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue