Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi All,
I have a few mashups. The access to these mashups is role based.
As an example, Mashup A can be accessed by Role A and Mashup B by Role B.
Currently if role B tries to access Mashup A, I get a message with the prompt "404- Entity not found". I understand that this is due to the visibility permissions I have applied.
But from the end user perspective for better readability and understanding,
If the user tries to access the mashups he is not permitted to view, I would like to show a message with something like "User not permitted" or "User does not have privileges".
Is there any way to achieve this?
Thanks And Regards,
Madhumita
Solved! Go to Solution.
The approach presented below has risks. Changes are being made to the Tomcat Server which may prevent it from working correctly. Always backup any files before making changes. Always test the updates in a development environment. The recommended approach would be to change the mashup navigation to address the issue.
For your education (Use at your own risk).
The Message “404- Entity Not found” is generated from the application server (Tomcat)
The file which defines the message is located at: <tomcat director>/webapps/Thingworx/WEB-INF/web.xml.
It contains something like:
<!-- 404 error handling -->
<servlet>
<servlet-name>PageNotFoundExceptionHandler</servlet-name>
<servlet-class>com.thingworx.handlers.PageNotFoundExceptionHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PageNotFoundExceptionHandler</servlet-name>
<url-pattern>/PageNotFoundExceptionHandler</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/PageNotFoundExceptionHandler</location>
</error-page>
This could be changed to access a different page for the error message:
<error-page>
<error-code>404</error-code>
<location>/Custom404Error.html</location>
</error-page
The file need to be placed in the “Thingworx” directory.
The file Custom404Error.html can contain normal HTML items such as:
<!doctype html>
<title>Thingworx Error Page</title>
<style>
body { text-align: center; padding: 50px; background-color:#2d2d2d; color:#fff; }
h1 { font-size: 40px; text-align:center; }
body { font: 16px Helvetica, sans-serif; color: #fff;text-align:center;}
article { display: block; text-align: left; width: 850px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #fff; text-decoration: none; }
p{text-align:center;}
</style>
<article>
<div align=”center”>
<img src="ThingworxLogo.png" alt="ThingWorx Logo" width=”200px”>
</div>
<h1>Page access is denied</h1>
<div>
<p>The page you are trying to access does not exist or you do not have the privliges to access that page.</p>
<p></p><hr>
<p>Go back to <a href=”https://www.ptc.com/”>ptc.com</a></p>
</div>
</article>
This sample page contains reference to a graphic file “ThingworxLogo.png”. The location which will be searched for this file is the same directory which contains the HTML file. This is provided as a sample and not intended to describe all possible approaches.
You could create a custom mashup page for users with no permissions that is only accessed by certain users using the expression function, checking current user info, perhaps? Otherwise, not sure but perhaps others may have other ideas.
Yes, in case of navigation from mashup -to -mashup, that is, navigating to other mashups from inside one mashup, it is possible through expressions/services.
But, I wanted a custom message shown to the user if he hits a mashup URL directly through the web browser and he doesn't have permissions to view this mashup. Currently, the message shown is 404 entity not found.
It would be really helpful if there is any way we can achieve this.
Regards,
Madhumita
The approach presented below has risks. Changes are being made to the Tomcat Server which may prevent it from working correctly. Always backup any files before making changes. Always test the updates in a development environment. The recommended approach would be to change the mashup navigation to address the issue.
For your education (Use at your own risk).
The Message “404- Entity Not found” is generated from the application server (Tomcat)
The file which defines the message is located at: <tomcat director>/webapps/Thingworx/WEB-INF/web.xml.
It contains something like:
<!-- 404 error handling -->
<servlet>
<servlet-name>PageNotFoundExceptionHandler</servlet-name>
<servlet-class>com.thingworx.handlers.PageNotFoundExceptionHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PageNotFoundExceptionHandler</servlet-name>
<url-pattern>/PageNotFoundExceptionHandler</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/PageNotFoundExceptionHandler</location>
</error-page>
This could be changed to access a different page for the error message:
<error-page>
<error-code>404</error-code>
<location>/Custom404Error.html</location>
</error-page
The file need to be placed in the “Thingworx” directory.
The file Custom404Error.html can contain normal HTML items such as:
<!doctype html>
<title>Thingworx Error Page</title>
<style>
body { text-align: center; padding: 50px; background-color:#2d2d2d; color:#fff; }
h1 { font-size: 40px; text-align:center; }
body { font: 16px Helvetica, sans-serif; color: #fff;text-align:center;}
article { display: block; text-align: left; width: 850px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #fff; text-decoration: none; }
p{text-align:center;}
</style>
<article>
<div align=”center”>
<img src="ThingworxLogo.png" alt="ThingWorx Logo" width=”200px”>
</div>
<h1>Page access is denied</h1>
<div>
<p>The page you are trying to access does not exist or you do not have the privliges to access that page.</p>
<p></p><hr>
<p>Go back to <a href=”https://www.ptc.com/”>ptc.com</a></p>
</div>
</article>
This sample page contains reference to a graphic file “ThingworxLogo.png”. The location which will be searched for this file is the same directory which contains the HTML file. This is provided as a sample and not intended to describe all possible approaches.