how to override paste as xml feature.

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

how to override paste as xml feature.

Post by shikhar_472 »

Hi Team,

I want to override paste as xml paste feature ,
So my issue is-
when i am trying to do paste as xml using paste special xmlns attribute is missing in string xml ,
so because of that its not working i want to add xmlns attribute manually through java code before insert fragment while doing paste as xml
insert fragment we are already overriding using documentModel.getAuthorDocumentController().setDocumentFilter(new AuthorDocumentFilter() {
@Override
public void insertFragment(AuthorDocumentFilterBypass filterBypass, int offset,
AuthorDocumentFragment frag) {

}

but i want to override paste as xml because when xmlns attribute is not present it is not coming till insertfragment method inside filterbypass might be some validation happening before that and i want to keep this option always true

<field name="isVerifyPasteAndDNDAction">
<Boolean>true</Boolean>
</field>

because i want to do validation while pasting.
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

Re: how to override paste as xml feature.

Post by mihaela »

Hello,

We already fixed this problem in our current development stream and the fix will be available starting with the next Web Author version, version 26.
The "Paste as XML" action will also insert the xmlns attribute, according to the context were the content is inserted.
In this case, I think there is no need for you to overwrite the action, right?

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: how to override paste as xml feature.

Post by shikhar_472 »

Hi Mihaela,
We have a production release in few days is there any way i can fix this issue right now.
Also when will be the 26th version will available
Thanks,
Shikhar.
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

Re: how to override paste as xml feature.

Post by mihaela »

Hello,

The release of Web Author version 26 is planed for October, this year.
If is urgent to fix this now maybe you could add an AuthorDocumentFilter[1] and update the fragments that are inserted in the document and contain empty xmlns. Here is the documentation for this API:

[1] https://www.oxygenxml.com/InstData/Edit ... ilter.html

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: how to override paste as xml feature.

Post by shikhar_472 »

Hi Mihela,

I tried updating it but the problem is in options <field name="isVerifyPasteAndDNDAction">
<Boolean>true</Boolean>
</field>
i have made this field true so because of that its not coming till insertFragment method if i will make false for isVerifyPasteAndDNDAction this field,
in that case it will work but i dont want to insert xml at wrong place so
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: how to override paste as xml feature.

Post by shikhar_472 »

Hi Mihela,

I tried updating it but the problem is in options <field name="isVerifyPasteAndDNDAction">
<Boolean>true</Boolean>
</field>
i have made this field true so because of that its not coming till insertFragment method if i will make false for isVerifyPasteAndDNDAction this field,
in that case it will work but i dont want to insert xml at wrong place so
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: how to override paste as xml feature.

Post by shikhar_472 »

Hi Mihela,

I tried updating it but the problem is in options <field name="isVerifyPasteAndDNDAction">
<Boolean>true</Boolean>
</field>
i have made this field true so because of that its not coming till insertFragment method if i will make false for isVerifyPasteAndDNDAction this field,
in that case it will work but i dont want to insert xml at wrong place so
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: how to override paste as xml feature.

Post by shikhar_472 »

here are the error logs -------------


2023-06-26 18:41:16,202 DEBUG [ http-nio-8084-exec-10 ] com.oxygenxml.webauthor.SecurityManager - java.lang.Exception
at ro.sync.ecss.webapp.i.b.f(Unknown Source)
at org.slf4j.Logger.debug(Logger.java:989)
at ro.sync.ecss.webapp.i.b.verifyHost(Unknown Source)
at ro.sync.security.ConnectionsSandbox.lambda$additionalCheckURL$2(ConnectionsSandbox.java:218)
at java.security.AccessController.doPrivileged(Native Method)
at ro.sync.security.ConnectionsSandbox.additionalCheckURL(ConnectionsSandbox.java:211)
at ro.sync.security.Sandbox.additionalCheckURL(Sandbox.java:200)
at ro.sync.security.manager.SandboxSecurityManager.checkUrl(SandboxSecurityManager.java:211)
at ro.sync.security.manager.SandboxSecurityManager.checkPermissionInternal(SandboxSecurityManager.java:304)
at ro.sync.security.manager.SandboxSecurityManager.checkPermission(SandboxSecurityManager.java:246)
at ro.sync.net.protocol.http.abstraction.l.q(Unknown Source)
at ro.sync.net.protocol.http.b.s.c(Unknown Source)
at ro.sync.net.protocol.http.abstraction.l.r(Unknown Source)
at ro.sync.net.protocol.http.abstraction.l.e(Unknown Source)
at ro.sync.net.protocol.http.WebdavHttpURLConnection.obtainResponse(Unknown Source)
at ro.sync.net.protocol.http.WebdavHttpURLConnection.getInputStream(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:1156)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
at org.apache.xerces.impl.xs.opti.SchemaDOMParserXerces.parse(SchemaDOMParserXerces.java:587)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2483)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:662)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidatorBase.findSchemaGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1547)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:400)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:227)
at org.apache.xerces.impl.XMLNSDocumentScannerImplXerces$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImplXerces.java:733)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1756)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:325)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.ditang.relaxng.defaults.RelaxDefaultsParserConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at ro.sync.ecss.dom.builder.n.b(Unknown Source)
at ro.sync.ecss.dom.builder.n.c(Unknown Source)
at ro.sync.ecss.dom.builder.n.m(Unknown Source)
at ro.sync.ecss.dom.builder.n.i(Unknown Source)
at ro.sync.ecss.dom.x.b(Unknown Source)
at ro.sync.ecss.strictediting.u.kh(Unknown Source)
at ro.sync.ecss.strictediting.b.kh(Unknown Source)
at ro.sync.ecss.strictediting.u.gh(Unknown Source)
at ro.sync.ecss.component.ui.f.f.fb.s(Unknown Source)
at ro.sync.ecss.component.ui.f.f.fb.m(Unknown Source)
at ro.sync.ecss.webapp.p.handleXmlPaste(Unknown Source)
at ro.sync.servlet.RESTDocumentController.insertXml(RESTDocumentController.java:357)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:192)
at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:141)
at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:32)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:60)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.servlet.config.UnlockDocumentsFilter.doFilter(UnlockDocumentsFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.ecss.webapp.d.h.doFilter(Unknown Source)
at ro.sync.ecss.extensions.api.webapp.license.LicenseEnforcerFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.servlet.config.OxygenLanguageFilter.doFilter(OxygenLanguageFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.servlet.config.OxygenContextFilter.doFilter(OxygenContextFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.servlet.config.UTF8CharsetEnforcer.doFilter(UTF8CharsetEnforcer.java:28)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.auth.CsrfFilter.doFilter(CsrfFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.auth.ClientSessionFilter.doFilter(ClientSessionFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at com.oxygenxml.examples.git.SynchronizedReposTrackerFilter.doFilter(SynchronizedReposTrackerFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at ro.sync.servlet.ssl.SSLRedirectFilter.doFilter(SSLRedirectFilter.java:69)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:450)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at ro.sync.auth.WebappShiroFilter.doFilterInternal(WebappShiroFilter.java:85)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

Re: how to override paste as xml feature.

Post by mihaela »

Hello,

I need more details from you in order to better understand what is the problem you encountered.
So, you have an AuthorDocumentFilter in your plugin and you want to update the fragment received in the insertFragment method, right?
When you have the isVerifyPasteAndDNDAction option set to true the insertFragment method from your filter is not called, right?
If this is your case, can you please answer the following questions (I am referring to the case when isVerifyPasteAndDNDAction option is set to true):
- after paste, the fragment is inserted in the document when insertFragment method is not called?
- did you try to paste the fragment in a place where the inserted element is accepted, according to the schema?

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: how to override paste as xml feature.

Post by shikhar_472 »

yes i tried at the right place--
did you try to paste the fragment in a place where the inserted element is accepted, according to the schema?

It is failing because xmlns attribute is not present in fragment which i can add in insertFragment method but while doing paste special it is failing in handleXmlPaste method
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

Re: how to override paste as xml feature.

Post by mihaela »

Hello,

Thank you for the explanation and the analysis, now I understand your conclusion: because the option is set to true, the fragment is not allowed to be entered into the document (because it has an empty namespace and the result will be invalid).

In this case, the AuthorDocumentFilter does not help, indeed. Another solution would be to try to replace the Paste Special operation with your own operation, but I do not know if this is doable in a few days (you said that this is your release date). As I said, the fix will be included in the next Web Author (version 26).

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply