[opencms-dev] CategoryWidget brakes when creating a new file via direct edit

Graeme Kidd coolkidd3 at hotmail.com
Mon Apr 19 02:16:18 CEST 2010




Hi all,

 

Before I submit this as a bug (currently having difficulties
submitting bugs at the moment) I thought I would see if anyone wanted to
comment on this.



Basically the CategoryWidget doesn't seem to work when creating a new file via
"Direct edit". The widget simply doesn't appear and the following
error is shown in opencms.log file:



16 Apr 2010 12:34:50,010 ERROR [ce.editors.CmsXmlContentEditor:1871] Error in
the XML editor.

java.lang.NullPointerException

    at org.opencms.file.CmsRequestContext.getSitePath(CmsRequestContext.java:370)

    at
org.opencms.file.CmsObject.getSitePath(CmsObject.java:1822)

    at
org.opencms.widgets.CmsCategoryWidget.getResource(CmsCategoryWidget.java:463)

    at
org.opencms.widgets.CmsCategoryWidget.getDialogWidget(CmsCategoryWidget.java:207)

    at
org.opencms.workplace.editors.CmsXmlContentEditor.getXmlEditorForm(CmsXmlContentEditor.java:1828)

    at
org.opencms.workplace.editors.CmsXmlContentEditor.getXmlEditorForm(CmsXmlContentEditor.java:802)

    at org.apache.jsp.WEB_002dINF.jsp.offline.system.workplace.editors.xmlcontent.editor_005fform_jsp._jspService(editor_005fform_jsp.java:564)

    at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)

    at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)

    at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)

    at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)

    at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)

    at
org.opencms.flex.CmsFlexRequestDispatcher.includeExternal(CmsFlexRequestDispatcher.java:194)

    at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:169)

    at org.opencms.loader.CmsJspLoader.service(CmsJspLoader.java:555)

    at
org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWithCache(CmsFlexRequestDispatcher.java:423)

    at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:173)

    at org.opencms.loader.CmsJspLoader.dispatchJsp(CmsJspLoader.java:829)

    at
org.opencms.loader.CmsJspLoader.load(CmsJspLoader.java:512)

    at
org.opencms.loader.CmsResourceManager.loadResource(CmsResourceManager.java:1052)

    at org.opencms.main.OpenCmsCore.showResource(OpenCmsCore.java:1490)

    at
org.opencms.main.OpenCmsServlet.doGet(OpenCmsServlet.java:153)

    at
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

    at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)

    at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

    at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)

    at java.lang.Thread.run(Unknown Source)





One line in particular seems to suggest the problem:

org.opencms.widgets.CmsCategoryWidget.getResource(CmsCategoryWidget.java:463)



Which refers to this line of code:

CmsFile file = value.getDocument().getFile();



In the documentation for getFile() it says this:

"Returns the file this document was generated from, may be null if the file not available.

The file may not be available if the document was generated from a String or a
pure XML document."

http://www.opencms.org/javadoc/core/org/opencms/xml/I_CmsXmlDocument.html#getFile%28%29



My understanding is that new files created via the direct edit feature are done
so via a String. This means that although the file exists, it exits as a
temporary file. So far I have been unable to retrieve the location of the
temporary file. The only way I can think of would be to create a custom
collector that saves the location to a property on a file which I then read
from.



Even if I were to retrieve the location of the temporary file the CmsDefaultXmlContentHandler
 does not save categories information
when the file is temporary. This means I would have to override the
writeCategories() function as well.



Does anyone have any other ideas of how I can retrieve
the location of the temporary file from within the widget code?

 

Thanks

Graeme

 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/195013117/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100419/c38da64b/attachment.htm>


More information about the opencms-dev mailing list