05-10-2021 01:05 AM
Hi,
I have uploaded html file in documentlibrary.
When I use View in Browser , it is ignoring html style and display plain text only.
it is loading in browser so It should display like normal html file we are opening in browser with style.
05-10-2021 04:28 AM
Unfortunately, Alfresco Share has a very aggressive "HTML stripping" functionality to prevent malicious content / hijacking in HTML files, which applies to the "view in browser" feature for HTML files. Essentially, the style markup is transparently removed from the HTML when it is being loaded from the backend, resulting in the plain-text-like display. In one of my modules I circumvent that URL-based handling by mapping a default functionality to a custom URL, and then reconfigure the "view in browser" action in a customer system to use that non-processed URL instead of the default.
05-10-2021 08:34 AM
Please help to achieve that scenario.
How Can I change code?
Is it proper way to override bean?
05-12-2021 09:39 AM
I do not advocate changing Alfresco code for this. I primarily advocate mapping the download web script to a different URL (similar to how I do it via a custom web script mapped to a bean extended from the same parent ), and then reconfiguring the view-content action to use a different href that maps to the custom web script (the default viewUrl is calculated here using https://github.com/Alfresco/share/blob/master/share-services/src/main/resources/alfresco/templates/w... ). E.g. for my web script I would have to configure the following href pattern:
/share/proxy/alfresco/acosix/api/utility/node/slingshot/{node.nodeRef.storeType}/{node.nodeRef.storeId}/{node.nodeRef.id}
If you wanted to eliminate the /share/proxy/alfresco/ prefix and use constants with deployment specific values (technically both "share" and "alfresco" in the prefix could be different in some deployments, but 99.99% stick to the default, and most people probably don't know how it could be changed to begin with), you would have to write a JavaScript based action, register and use it as documented on docs.alfresco.com.
05-13-2021 01:04 AM
I did the same thing but I am getting error like
org.springframework.extensions.webscripts.WebScriptException - 04130115 Web Script format '' is not registered |
Step 1 : this path I have created given .xml file with same content for test.
Step 2: Created bean in webscript-context.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans> <bean id="webscript.de.acosix.acosix-utility.slingshot-content.get" parent="webscript.default" /> </beans>
Step 3 : Create javascript base custom action and opening url.
(function() { YAHOO.Bubbling .fire("registerAction", { actionName : "viewInBrowser", fn : function viewInBrowser(file) { console.log(file); var contentUrl = Alfresco.constants.PROXY_URI+"acosix/api/utility/node/slingshot/"+file.nodeRef.replace(":/","")+"/"+file.fileName; window.open(contentUrl); } }); })();
Do I need to override all the bean of this file?
05-14-2021 07:58 AM
You need to set the parent of the bean to "webscript.org.alfresco.slingshot.download.get". This is done by a dynamic component in my module, but you may simply set it on the existing bean without the dynamic handling (that handling is only in place to be compatible with Alfresco installations where Share Services is not installed)
05-15-2021 02:09 AM
I did the same thing but getting NullPointerException.
2021-05-15 12:46:57,840 ERROR [extensions.webscripts.AbstractRuntime] [http-bio-9090-exec-2] Exception from executeScript - redirecting to status template error: null java.lang.NullPointerException at org.alfresco.repo.web.scripts.content.ContentGet.execute(ContentGet.java:108) at org.alfresco.slingshot.web.scripts.SlingshotContentGet.execute(SlingshotContentGet.java:114) at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:505) at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:457) at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:580) at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:649) at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:421) at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:301) at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378) at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209) at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
Here I am attching Demo .
Here is bean .
Action Name is View In Browser HTML
Am i doing anything wrong?
@afaust Any Suggestion?
06-02-2021 09:07 AM
This error is due to the fact that you are calling the web script without any URL parameters. The implementation expects that there is at least one parameter (e.g. the `?a=true` to trigger sending the response with attachment disposition), and does not check for null - so you could say you are simply running into a bug / implementation mistake by an Alfresco developer here.
05-24-2022 10:52 AM
Hi @afaust ,
i followed the steps as is and I am getting the same null pointer exception but it is not resolved after adding ?a=true.
My URL:
The LOGS:
my-all-in-one-acs_1 | 2022-05-24 14:43:56,425 ERROR [extensions.webscripts.AbstractRuntime] [http-nio-8080-exec-4] Exception from executeScript: null
my-all-in-one-acs_1 | java.lang.NullPointerException
my-all-in-one-acs_1 | at org.alfresco.repo.web.scripts.content.ContentGet.execute(ContentGet.java:131)
my-all-in-one-acs_1 | at org.alfresco.slingshot.web.scripts.SlingshotContentGet.execute(SlingshotContentGet.java:133)
my-all-in-one-acs_1 | at org.alfresco.repo.web.scripts.RepositoryContainer.lambda$transactionedExecute$2(RepositoryContainer.java:553)
my-all-in-one-acs_1 | at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
my-all-in-one-acs_1 | at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:544)
my-all-in-one-acs_1 | at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:685)
my-all-in-one-acs_1 | at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:721)
my-all-in-one-acs_1
05-24-2022 11:35 AM
Unfortunately Alfresco's base class is missing a null check for a technically optional property} URL template fragment. In your case you are not providing it. Though I do not recognise your URL as a valid URL for either the default ContentGet nor my patched one.
Explore our Alfresco products with the links below. Use labels to filter content by product module.