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(),
|
||||
src.toString(),
|
||||
dst.getOID().toString());
|
||||
//mapping.save();
|
||||
mapping.save();
|
||||
}
|
||||
|
||||
public String getSystemID() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
package com.arsdigita.london.importer;
|
||||
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import java.io.File;
|
||||
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for TagParser implementations handling
|
||||
|
|
@ -13,7 +14,6 @@ import java.io.File;
|
|||
*/
|
||||
public abstract class DomainObjectParser extends AbstractTagParser {
|
||||
|
||||
private String m_objectType;
|
||||
private DomainObject m_object;
|
||||
private File m_lobDir;
|
||||
private DomainObjectMapper m_mapper;
|
||||
|
|
@ -34,8 +34,6 @@ public abstract class DomainObjectParser extends AbstractTagParser {
|
|||
File lobDir,
|
||||
DomainObjectMapper mapper) {
|
||||
super(tagName, tagURI);
|
||||
|
||||
m_objectType = objectType;
|
||||
m_lobDir = lobDir;
|
||||
m_mapper = mapper;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.arsdigita.runtime.RuntimeConfig;
|
|||
* PDL for {@link RemoteOidMapping}.
|
||||
*
|
||||
* @author Sebastian Skracic (sskracic@redhat.com)
|
||||
* @version $Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class Initializer extends CompoundInitializer {
|
||||
|
||||
|
|
|
|||
|
|
@ -18,24 +18,13 @@
|
|||
|
||||
package com.arsdigita.london.importer;
|
||||
|
||||
import com.arsdigita.runtime.ScriptContext;
|
||||
import com.arsdigita.loader.PackageLoader;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import com.arsdigita.runtime.ScriptContext;
|
||||
|
||||
/**
|
||||
* Loader for importer application.
|
||||
*
|
||||
* @version $Id: Loader.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
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) {
|
||||
// Nada yet
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,13 +58,20 @@ public class ParserDispatcher extends DefaultHandler {
|
|||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(new File(importFile));
|
||||
XML.parse(is, this);
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
"cannot load file " + importFile,
|
||||
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;
|
||||
|
||||
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.util.List;
|
||||
|
||||
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 {
|
||||
|
||||
private List m_lazyItems;
|
||||
|
||||
public AssetImportTool() {
|
||||
super("Asset Import Tool",
|
||||
"1.0.0",
|
||||
"INDEX-FILE ASSET-DIR");
|
||||
}
|
||||
|
||||
|
||||
protected void doRun(CommandLine cmdLine) {
|
||||
final String[] args = cmdLine.getArgs();
|
||||
if (args.length != 2) {
|
||||
|
|
@ -64,9 +56,6 @@ public class AssetImportTool extends Program {
|
|||
}
|
||||
final DomainObjectMapper mapper = new DomainObjectMapper();
|
||||
|
||||
ContentSection section = (ContentSection)ContentSection
|
||||
.retrieveApplicationForPath("/content/");
|
||||
|
||||
Transaction session = new Transaction() {
|
||||
public void doRun() {
|
||||
ParserDispatcher parser = new ParserDispatcher();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
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 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.
|
||||
|
|
@ -15,8 +12,6 @@ import org.apache.log4j.Logger;
|
|||
* @see com.arsdigita.london.importer
|
||||
*/
|
||||
public class AssetParser extends ItemParser {
|
||||
private static Logger s_log =
|
||||
Logger.getLogger(AssetParser.class);
|
||||
|
||||
public AssetParser(File lobDir, DomainObjectMapper mapper) {
|
||||
this("asset", CMS.CMS_XML_NS, Asset.BASE_DATA_OBJECT_TYPE, lobDir, mapper);
|
||||
|
|
|
|||
|
|
@ -18,30 +18,26 @@
|
|||
|
||||
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.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
|
||||
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.
|
||||
* It can be invoked by:
|
||||
|
|
@ -62,6 +58,13 @@ public class ItemImportTool extends Program {
|
|||
"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) {
|
||||
final String[] args = cmdLine.getArgs();
|
||||
if (args.length != 3) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class ItemParser extends DomainObjectParser {
|
|||
* change from one CCM instance to another. Importer will not try
|
||||
* 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.contenttypes.IsoCountry"
|
||||
};
|
||||
|
|
@ -342,7 +342,7 @@ public class ItemParser extends DomainObjectParser {
|
|||
* @return the end of lifecycle date, might be null
|
||||
*/
|
||||
public Date getArchiveDate() {
|
||||
return m_archiveDate;
|
||||
return (Date)m_archiveDate.clone();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ public class ItemParser extends DomainObjectParser {
|
|||
count = assocCount.intValue();
|
||||
}
|
||||
count++;
|
||||
parentObject.put(propName + COUNT_SUFFIX, new Integer(count));
|
||||
parentObject.put(propName + COUNT_SUFFIX, Integer.valueOf(count));
|
||||
parentObject.put(propName + COUNT_SUFFIX + count, childObject);
|
||||
m_currentDataObject = parentObject;
|
||||
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.
|
||||
*/
|
||||
private Map getDataObject(OID srcOid) {
|
||||
String type = getTypeFromOid(srcOid.toString());
|
||||
String type = srcOid.getObjectType().getQualifiedName();
|
||||
Map newDataObject = new HashMap();
|
||||
newDataObject.put(OID_ATTR, srcOid);
|
||||
// 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) {
|
||||
String domainClass = (String) properties.get(DEFAULT_DOMAIN_CLASS);
|
||||
if (domainClass == null) {
|
||||
// Default to persistence ObjectType -- possibly dangerous.
|
||||
domainClass = getTypeFromOid(dobj.getOID());
|
||||
domainClass = dobj.getOID().getObjectType().getQualifiedName();
|
||||
}
|
||||
debugLog("Creating " + domainClass + " ...");
|
||||
try {
|
||||
|
|
@ -685,25 +671,30 @@ public class ItemParser extends DomainObjectParser {
|
|||
FileInputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(lobFile);
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = -1;
|
||||
try {
|
||||
while ((length = in.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw new UncheckedWrapperException(ioe);
|
||||
}
|
||||
byte[] content = os.toByteArray();
|
||||
dobj.put(key, content);
|
||||
debugLog("Successfully loaded file " + lobFile
|
||||
+ ", length: " + content.length + " bytes");
|
||||
} catch (FileNotFoundException e) {
|
||||
s_log.error("Lob file: " + lobFile + " does not exist!", e);
|
||||
return;
|
||||
}
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = -1;
|
||||
try {
|
||||
while ((length = in.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, length);
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
s_log.warn("Failed to close " + lobFile, e);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw new UncheckedWrapperException(ioe);
|
||||
}
|
||||
byte[] content = os.toByteArray();
|
||||
dobj.put(key, content);
|
||||
debugLog("Successfully loaded file " + lobFile
|
||||
+ ", length: " + content.length + " bytes");
|
||||
} else {
|
||||
s_log.warn("Don't know how to handle property " +
|
||||
key + ", type: " + propertyClass.getName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue