[opencms-dev] "Wrong XML content type, ErrorCode: 20" when trying to add plain/text file

Alex ! kingofkingston at hotmail.com
Mon Feb 23 16:32:02 CET 2004


Thanks Olli.

Having done that though, I now get an Access Denied everytime. Although, the 
xml file is written to the vfs fine. I tried (out of curiosity) to see if 
switching to a temporary project id would work, but still the same error. I 
guess I've just missed something again.

Before:

CmsResource newfile = 
cmsObj.createResource("/test/","test_plain.xml","plain", resProperties, 
resContents);
CmsXmlControlFile controlFile = new 
CmsXmlControlFile(cmsObj,(CmsFile)newfile);
//controlFile.setMasterTemplate("/system/modules/com.opencms.default/templates/empty");
controlFile.write();

Now:

CmsResource newFile = cmsObj.createResource("/test/", "test_xml.xml", 
"plain", resProperties, resContents);
cmsObj.writeFile((CmsFile)newFile);

(btw. I am logged in as admin and launching the jsp from the workspace 
window).

Thanks

Alex.


>From: "Olli Aro" <olli_aro at yahoo.co.uk>
>Reply-To: opencms-dev at opencms.org
>To: <opencms-dev at opencms.org>
>Subject: RE: [opencms-dev] "Wrong XML content type, ErrorCode: 20" when 
>trying to add plain/text file
>Date: Mon, 23 Feb 2004 07:58:27 -0000
>
>Alex,
>
>You cannot use CmsXmlControlFile to write a plain file because it does not
>have a control file. Please try cms.writeFile (or was it cms.writeResource
>cannot remember without reading the API) method instead.
>
>Regards,
>
>Olli
>
>-----Original Message-----
>From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
>On Behalf Of Alex !
>Sent: 23 February 2004 03:57
>To: opencms-dev at opencms.org
>Subject: [opencms-dev] "Wrong XML content type, ErrorCode: 20" when trying
>to add plain/text file
>
>Hi,
>
>I am trying to add a plain type file via jsp, (code below), containing xml,
>but get the following error code + message:
>
>CMSErrorCode: 20
>CMSError: Wrong XML content type
>
>I cannot find any documentation for error codes anywhere, nor can I figure
>out what the problem is, i've tried a few things but nothing is working.
>
>The file is added to the vfs, but the exception is still thrown (the xml
>content is added correctly too).
>
>I'm sure it is a simple mistake.
>
>Your help is much appreciated.
>
>Alex.
>
>
>
>(note: seems to make no difference if setMasterTemplate() is called or not,
>therefore I have left it commented since I assume text/plain type files 
>dont
>
>have a master template?)
>
><%@ page import = "java.util.*, com.opencms.flex.jsp.*, com.opencms.file.*,
>com.opencms.template.*, com.opencms.core.CmsException" %>
><%
>
>	CmsJspActionElement cmsJspAE = new CmsJspActionElement(pageContext,
>request, response);
>	CmsObject cmsObj = cmsJspAE.getCmsObject();
>
>	String contents = new String();
>	contents = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
>	contents += "<advert>\n";
>	contents += " <element1>\n";
>	contents += "  content for element1\n";
>	contents += " </element1>\n";
>	contents += " <element2>\n";
>	contents += "  content for element2\n";
>	contents += " </element2>\n";
>	contents += "</advert>\n";
>
>	//byte[] resContents = new byte[0];
>	byte[] resContents = contents.getBytes();
>
>	Hashtable resProperties = new Hashtable();
>	resProperties.put("Title", "This is the title");
>/*	resProperties.put("Description", "This is the description");
>	resProperties.put("Keywords", "keyword1, keyword2, keyword3");
>	resProperties.put("NavText", "test add html page");
>	resProperties.put("NavPos", "10");
>    resProperties.put("content-encoding", "ISO-8859-1");
>*/
>	try
>	{
>		//CmsResource newfile = cmsObj.createResource("/test/",
>"test_page.html",
>"page", resProperties, resContents);
>		CmsResource newfile = cmsObj.createResource("/test/",
>"test_plain.xml",
>"plain", resProperties, resContents);
>		CmsXmlControlFile controlFile = new
>CmsXmlControlFile(cmsObj,
>(CmsFile)newfile);
>
>//controlFile.setMasterTemplate("/system/modules/com.opencms.default/templat
>es/empty");
>		controlFile.write();
>	}
>
>	catch(CmsException e)
>	{
>		out.println("<p>Exception whilst trying to create a new CMS
>resource!</p>"
>						+ "<p>CMSErrorCode: " +
>e.getType() + "</p>"
>						+ "<p>CMSError: " +
>e.C_EXTXT[e.getType()] + "</p>" );
>	}
>
>%>
>
>_________________________________________________________________
>It's fast, it's easy and it's free. Get MSN Messenger today!
>http://www.msn.co.uk/messenger
>
>_______________________________________________
>This mail is send to you from the opencms-dev mailing list
>To change your list options, or to unsubscribe from the list, please visit
>http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.580 / Virus Database: 367 - Release Date: 06/02/2004
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.580 / Virus Database: 367 - Release Date: 06/02/2004
>
>
>_______________________________________________
>This mail is send to you from the opencms-dev mailing list
>To change your list options, or to unsubscribe from the list, please visit
>http://mail.opencms.org/mailman/listinfo/opencms-dev

_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection 
http://www.msn.co.uk/specials/btbroadband




More information about the opencms-dev mailing list