import org.jdom.input.SAXBuilder;
import org.jdom.Document;
import org.jdom.Element;
import java.io.*;
import java.util.*;
import com.xerox.docushare.*;
import com.xerox.docushare.object.*;
import com.xerox.docushare.property.*;
public class StrukturErstellen
{
private Document doc = null;
private DSServer dsserver = null;
private DSSession dssession = null;
private Element root = null;
private String ziel = "";
private Collection col = null;
private void strukturErzeugen(Element element, DSHandle aktuellerHandle)
{
DSHandle aktuellerHandleNeu;
List list = element.getChildren();
Iterator it = list.iterator();
while(it.hasNext())
{
try
{
Object objektNow = it.next();
Element elementNow = (Element) objektNow;
// urlPrototype
DSClass collectionClass = dssession.getDSClass( DSCollection.classname );
DSProperties collectionPrototype = collectionClass.createPrototype();
String name = elementNow.getAttributeValue("Titel");
collectionPrototype.setPropValue( DSObject.title, name );
//collection10
DSCollection collection13 = ( DSCollection ) dssession.getObject( aktuellerHandle,
DSSelectSet.NO_PROPERTIES );
aktuellerHandleNeu = dssession.createObject( collectionPrototype, DSLinkDesc.containment, collection13,
dssession.getLoginPrincipal(), null );
System.out.println("Objekt erzeugt: " + name);
strukturErzeugen(elementNow, aktuellerHandleNeu);
}
catch(Exception e)
{
System.out.println("Fehler bei der Rekursion");
}
}
}
public void login()
{
try
{
dsserver = DSFactory.createServer("localhost", 1099);
dssession = dsserver.createSession("DocuShare", "admin", "system");
}
catch(Exception e)
{
System.out.println("Fehler beim aufbauen der Verbindung");
}
}
public void inJDOMEinlesen()
{
try
{
SAXBuilder b = new SAXBuilder(true);
doc = b.build(new File("C:\\eigener Kram\\test.xml"));
Element root = doc.getRootElement();
strukturErzeugen(root, new DSHandle("Collection-13"));
}
catch (Exception e)
{
System.out.println("Fehler beim Verarbeiten");
}
}
public static void main(String[] args)
{
StrukturErstellen se = new StrukturErstellen();
se.login();
se.inJDOMEinlesen();
System.out.println("Fertig");
}
}