I have an EJB which I hosted as a webservice the URL is something like
http://<>:7005/PurgeReportSessionEJBBean/PurgeReportSessionEJBBeanService?WSDL
Now I want to change it to
http://<>:7005/jasperserver-pro/PurgeReportSessionEJBBean/PurgeReportSessionEJBBeanService?WSDL
What should I do in the EJB so that the WSDl URL changes as above
If you're declaring the webservice via the #WebService annotation, then you can specify #WebService(wsdlLocation="http://...:7005/jasperserver-pro/..."). There is a similar attribute on the #WebServiceProvider annotation.
Related
I setup MVC breadcumbs for my website using MvcSiteMapProvider (Nuget package MvcSiteMapProvider.MVC5 (version 4.6.22)).
It works fine.
Then I want to update Url of Sitemap dynamically like:
SiteMaps.Current.CurrentNode.Url = Url.Action("Index");
Then I got this error:
SiteMapNode is readonly, property 'Url' cannot be modified
Note that I am still able to update Title:
SiteMaps.Current.CurrentNode.Title = "/Index";
Any idea?
The SiteMap is a statically cached object that is shared between all users. Technically, all of the properties are read-only at runtime. However, some of the properties (such as Title) are request-cached so you can safely update them at runtime without affecting other users.
The Url property is a special property that dynamically builds the URL through the MVC UrlHelper class (which is directly driven from your routes). It makes no sense to set it to Url.Action("Index") because that is effectively what it does just by itself (unless you are using a dynamic node provider or custom ISiteMapNodeProvider - those are startup extension points where you load the node configuration, so the properties are read-write).
You just need to set the correct controller and action in your node configuration (which could be XML, attribute based, or code based) and the URL will resolve on its own.
XML Example
<mvcSiteMapNode title="Projects" controller="Project" action="Index"/>
NOTE: You need to account for all route values in the request, either by adding them as another attribute myId="123" or by using preservedRouteParameters="myId" (which tells it to include the myId from the current request when building the URL). See this article for a detailed description of using these options.
NOTE: Setting a URL in the SiteMap configuration effectively overrides MVC support for that node. So, you shouldn't set a URL at all unless it is a non-MVC URL.
I want to get the URL accessed by the Struts2 web application. For instance, if user accesses http://www.webpage.com or https://www.webpage.com, I need the protocol; http or https. I tried implementing the action with ServletRequestAware and using request.isSecure() or request.getScheme(). However, I am getting false and 'http' even if I access 'https://..' link.
Is there any way to get the protocol ?
You can extract it from the header:
System.out.println(request.getHeader("referer"));
OUTPUT:
https://www.webpage.com
I think you forgot to try one more thing.
Implement Action with ServletRequestAware and use
request.getProtocol();
Else you can use the following code in your action class:
HttpServletRequest request=ServletActionContext.getRequest();
String protocol=request.getProtocol();
System.out.println("Protocol Used::"+protocol);
I am trying to secure a controller:
#Secured(['ROLE_ADMIN'])
class FooBarController {
}
I have the controller mapped in UrlMappings:
"/foo/bar"
It seems that when I try and access the controller as /foo/bar the annotations are effectively ignored.
I saw something that said I need to use the controllerAnnotations.staticRules. My first question is:
Do I need to duplicate all my rules in the static rules or is it enough to say it's secured and the filters will pick up the specific rules from the annotations?
I have another scenario where I secure a contoller with UrlMappings, the default URL path is changed but not the controller name e.g.
#Secured(['ROLE_ADMIN'])
MyApiController {
}
UrlMapping is: /api/company/1/myApi
In this case the annotation is picked up without any necessary configuration in the staticRules so I'm pretty confused by what needs to be configured where and under what circumstances.
It looks like the problem here is that the UrlMapping doesn't match the default controller mapping convention. i.e. the Config.groovy mapping is referring to the UrlMapping instead of referring to the actual controller name.
See this answer: https://stackoverflow.com/a/16737980/57357 for a fuller explanation.
IMO this is non-intuitive, but that's the way it currently works. Note that it does not work this way if you use the InterceptUrlMap style of configuration. If you use the InterceptorUrlMap style, you do refer to the UrlMappings.groovy's URL mappings.
I've been searching the net but couldn't find a solution for this. I need help on how to store my application specific configuration parameters into a flat text file or xml file. Is there a java package or class that provides this service?
For example configuration for datatable pagination length, etc. So I don't have to recompile my application whenever I need to change the pagination parameters.
Something like this: Maybe myApp.cfg file which contain this.
pagination: 10,20,30,50
And then in my xhtml file I would have something like this.
<p:dataTable id="dtClientList" value="#{saClientController.lazyModel}" rowsPerPageTemplate="#{myApp.cfg.pagination}">
And maybe even access the configuration parameter from within my session scoped or application scoped backing bean. Then reuse them for multiple users.
Is it possible to user resource bundle properties file to store configuration parameters such as pagination length and access the parameters into backing bean like this?
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle bundle = fc.getApplication().getResourceBundle(fc,"bundle_name");
bundle.getString("resource_identifier");
Im searching for something similar to app.config file in dot net implementation which is XML.
Please help. And if my question does not make sense, do let me know. Big Thank You.
You can use a properties file (simple text file) with content like this:
key1 = value1
key2 = value2
Name this file for instance MyResources.properties and put it in your source path root.
Then you can access a property file with the ResourceBundle class:
import java.util.ResourceBundle;
...
ResourceBundle rb = ResourceBundle.getBundle("MyResources");
String myValue1 = rb.getString("key1");
You can access this file from any session scoped bean you like. If the parameters are session independent, you could also use an application scoped bean instead.
is there a way to access URL parameters in a Jetspeed2 Portlet/Portal?
like: www.bla.com/portal/page.psml?param=12345
I can only find some tools for liferay (PortalUtil.java) to access the httpservletrequest, but as far as i know there is no such thing for jetspeed?
I thought the public render parameters can be used for such thing, but i'm a little confused here? Didn't anyone had this problem before?
thanks in advance :)
found the answer:
Until version 2.1, Jetspeed merged portal request parameters with portlet specific
parameters, effectively allowing "shared" parameters.
This is not compliant with the JSR-168 PLT.11, so by default this is now disabled.
By setting merge.portal.parameters.with.portlet.parameters=true this feature can
be "restored".
In the situation of portal and portlet parameters with the same name, by default
the portlet parameters will be provided first in the values array, but this too
can be overridden by setting merge.portal.parameters.before.portlet.parameters=true
Setting both these properties to true will deliver the "old" pre-2.1 behavior.
Note: for individual portlets, these global settings can be overridden by setting these properties as metadata in jetspeed-portlet.xml
merge.portal.parameters.with.portlet.parameters=false
merge.portal.parameters.before.portlet.parameters=false
To use public render parameters from the 2.0 spec
Don't know if it works for jetspeed, but you can try getting the httprequest like this:
HttpServletRequest httpRequest = (HttpServletRequest) request.getAttribute("javax.servlet.request");
Then find the query string in a header like this:
String referer = httpRequest.getHeader("referer");
You'll then have the full page referer so you can parse the query string.