fixed bug with checkboxes

partially removed need for sample instance xml - i'm doing a bunch of hacks at the moment to get around it - basically using xmlbeans to generate the sample xml, and then cleaning it up.  ended up not needing to do insane things in javascript with this approach.  emailed joern at chiba to see if he has suggestions for how others deal with this issue.
serializing the template configuration using object serialization for now.  it'll work good for the demo and we'll do something more robust/human readable post demo.  this required a bunch of refactoring and springifying the TemplateService, but we're now reading back xsds and xsls from the repository which is sorta a nice thing i think.
remove the preview form wizard step from create xml content type flow.
tried getting rid of a temporary file in generating the xform but failed.  need to find a way to get an url to a noderef that the xform can use to reference the xsd.  emailed london people about that.  but still did some refactoring along those lines.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3558 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-08-21 22:34:59 +00:00
parent d385022212
commit 80bf0acd64
18 changed files with 472 additions and 224 deletions

View File

@@ -34,16 +34,86 @@ import org.xml.sax.SAXException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class TemplatingService
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.model.ContentModel;
import org.alfresco.util.TempFileProvider;
public final class TemplatingService
implements Serializable
{
////////////////////////////////////////////////////////////////////////////
private static class Configuration
{
private final static File CONFIG_FILE =
new File(TempFileProvider.getTempDir(), "templating_configuration.xml");
public static void load()
throws IOException
{
if (!CONFIG_FILE.exists())
return;
final TemplatingService ts = TemplatingService.getInstance();
final ObjectInputStream out = new ObjectInputStream(new FileInputStream(CONFIG_FILE));
try
{
final List<TemplateType> tt = (List<TemplateType>)out.readObject();
for (TemplateType t : tt)
{
ts.registerTemplateType(t);
}
out.close();
}
catch (ClassNotFoundException cnfe)
{
assert false : cnfe;
TemplatingService.LOGGER.error(cnfe);
}
}
public static void save()
throws IOException
{
if (!CONFIG_FILE.exists())
CONFIG_FILE.createNewFile();
final TemplatingService ts = TemplatingService.getInstance();
final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(CONFIG_FILE));
out.writeObject(ts.getTemplateTypes());
out.close();
}
}
////////////////////////////////////////////////////////////////////////////
public static final org.alfresco.service.namespace.QName TT_QNAME =
org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt");
private static final Log LOGGER = LogFactory.getLog(TemplatingService.class);
private final static TemplatingService INSTANCE = new TemplatingService();
private static TemplatingService INSTANCE;
private ArrayList<TemplateType> templateTypes =
new ArrayList<TemplateType>();
private final ContentService contentService;
private TemplatingService()
public TemplatingService(final ContentService contentService)
{
this.contentService = contentService;
if (INSTANCE == null)
{
INSTANCE = this;
try
{
Configuration.load();
}
catch (IOException ioe)
{
LOGGER.error(ioe);
}
}
}
public static TemplatingService getInstance()
@@ -71,12 +141,20 @@ public class TemplatingService
public void registerTemplateType(final TemplateType tt)
{
this.templateTypes.add(tt);
try
{
Configuration.save();
}
catch (IOException ioe)
{
LOGGER.error(ioe);
}
}
public TemplateType newTemplateType(final String name,
final Document schema)
final NodeRef schemaNodeRef)
{
return new TemplateTypeImpl(name, schema);
return new TemplateTypeImpl(name, schemaNodeRef);
}
public Document newDocument()
@@ -125,7 +203,6 @@ public class TemplatingService
public void writeXML(final Node n, final File output)
throws IOException
{
this.writeXML(n, new FileWriter(output));
}
@@ -144,6 +221,17 @@ public class TemplatingService
return this.parseXML(new ByteArrayInputStream(source.getBytes()));
}
public Document parseXML(final NodeRef nodeRef)
throws ParserConfigurationException,
SAXException,
IOException
{
final ContentReader contentReader =
this.contentService.getReader(nodeRef, ContentModel.TYPE_CONTENT);
final InputStream in = contentReader.getContentInputStream();
return this.parseXML(in);
}
public Document parseXML(final File source)
throws ParserConfigurationException,
SAXException,