-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
kparoth Jul 8, 2014 7:16 AM (in response to shipra)Hi,
I've implemented an example to use custom rest services.
At first we implement a simple service class, based on the "com.jivesoftware.api.core.v2.services.BaseService", because we can use Jive implemented api.core.v2 features.
CustomUserService.java
@Produces("application/json") @Path("/users") public class CustomUserService extends BaseService { // Dependency Injections private UserProvider userProvider; /** * Sets the value of userProvider. * @param userProvider the userProvider to set. */ @Required public void setUserProvider(UserProvider userProvider) { this.userProvider = userProvider; } /** * Returns the current user. * @return the current user. */ @GET public UserEntity getCurrentUser() { // Return the current user... return userProvider.getMyUser(); } }
And now we need the possibility to register our new service class. The "CoreApiExtensionManager" allows to register own service extensions.
ServiceRegistrar.java
public class ServiceRegistrar { // Dependency Injections private CoreApiExtensionManager coreApiExtensionManager; private List<Object> serviceBeans; private String version; private String name; /** * Sets the value of coreApiExtensionManager. * @param coreApiExtensionManager the coreApiExtensionManager to set. */ @Required public void setCoreApiExtensionManager( CoreApiExtensionManager coreApiExtensionManager) { this.coreApiExtensionManager = coreApiExtensionManager; } /** * Sets the value of serviceBeans. * @param serviceBeans the serviceBeans to set. */ @Required public void setServiceBeans(List<Object> serviceBeans) { this.serviceBeans = serviceBeans; } /** * Sets the value of version. * @param version the version to set. */ @Required public void setVersion(String version) { this.version = version; } /** * Sets the value of name. * @param name the name to set. */ @Required public void setName(String name) { this.name = name; } /** * Registers Spring defined services. */ public void register() { register(name, version, serviceBeans); } /** * Registers the given service beans. * @param name the service name. * @param version the service API version. * @param serviceBeans the service beans to register. */ public void register(String name, String version, List<Object> serviceBeans) { coreApiExtensionManager.registerServiceExtension(name, version, serviceBeans); } }
We would like to register our service during the Plugin initialization.
RestPlugin.java
public class RestPlugin implements Plugin { // Dependency Injections private ServiceRegistrar serviceRegistrar; /** * Sets the value of serviceRegistrar. * @param serviceRegistrar the serviceRegistrar to set. */ @Required public void setServiceRegistrar(ServiceRegistrar serviceRegistrar) { this.serviceRegistrar = serviceRegistrar; } /* (non-Javadoc) * @see com.jivesoftware.base.plugin.Plugin#initPlugin() */ @Override public void initPlugin() { // Register services... serviceRegistrar.register(); } /* (non-Javadoc) * @see com.jivesoftware.base.plugin.Plugin#destroy() */ @Override public void destroy() { // Nothing to do! } }
...and we have to define the spring context.
spring.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xmlns:core="http://www.jivesoftware.com/schema/core" xsi:schemaLocation=" http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.jivesoftware.com/schema/core classpath:/com/jivesoftware/api/core/spring/core.xsd" default-autowire="no" default-init-method="init" default-destroy-method="destroy"> <bean class="de.unoso.plugin.RestPlugin"> <property name="serviceRegistrar" ref="serviceRegistrar" /> </bean> <!-- Service Initialization --> <core:service id="customUserServiceImpl" v="2" class="de.unoso.plugin.services.CustomUserService" parent="baseServiceV2"> <property name="userProvider" ref="userProviderV2"/> </core:service> <!-- Service Registration --> <!-- <jive.context>/api/core/ext/custom/v2/<service.url> --> <bean id="serviceRegistrar" class="de.unoso.plugin.services.ServiceRegistrar"> <property name="coreApiExtensionManager" ref="coreApiExtensionManager" /> <property name="version" value="v2" /> <property name="serviceBeans"> <list> <ref bean="customUserServiceImpl" /> </list> </property> <property name="name" value="custom" /> </bean> </beans>
That's it!
Regards,
Kai
-
jive7-rest-plugin-src.zip 7.9 KB
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
srilasyab Jul 11, 2014 7:15 PM (in response to kparoth)Hi,
Thanks for the example. I am trying to implement this and I got an error in my spring.xml file.
Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
'core:service'.
Do you have any idea about this?
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
kparoth Jul 14, 2014 1:51 AM (in response to srilasyab)Hi,
comparisons again your declaration:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:core="http://www.jivesoftware.com/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.jivesoftware.com/schema/core classpath:/com/jivesoftware/api/core/spring/core.xsd"
default-autowire="no" default-init-method="init" default-destroy-method="destroy">
And look for the required file "core.xsd" (Located in your jive-core-7xx.jar -> /com/jivesoftware/api/core/spring/).
Regards,
Kai
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
srilasyab Jul 14, 2014 3:02 PM (in response to kparoth)There were some class path issues in my eclipse. I apologize for not providing more detail about this error. I don't see this error when I package the plugin using maven.
-
Re: Re: Can someone share an example to implement rest web services in jive 7 Plugin!
allenh Dec 20, 2014 6:42 PM (in response to kparoth)Kai Paroth First of all, thank you so much for posting the plugin sample.
I built a plugin from it, and the installion went well. After that, when I tested with http://localhost:8080/api/core/ext/custom/v2/users/, the Tomcat console showed error as following:
I also attached the plugin.
Could you please take a look at it and see why it errored out?
Thanks
[WARNING] [talledLocalContainer] Dec 20, 2014 9:34:28 PM org.apache.catalina.core.StandardWrapperValve invoke
[WARNING] [talledLocalContainer] SEVERE: Servlet.service() for servlet [APICXFServlet] in context with path [] threw exception
[WARNING] [talledLocalContainer] java.lang.RuntimeException: org.apache.cxf.interceptor.Fault
[WARNING] [talledLocalContainer] at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116)
[WARNING] [talledLocalContainer] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:331)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
[WARNING] [talledLocalContainer] at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
[WARNING] [talledLocalContainer] at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.NoCacheDevModeFilter.doFilterInternal(NoCacheDevModeFilter.java:39)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.struts.JiveFilterDispatcher.doFilter(JiveFilterDispatcher.java:87)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.ActivityRequestFilter.doFilter(ActivityRequestFilter.java:100)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.directwebremoting.servlet.DwrWebContextFilter.doFilter(DwrWebContextFilter.java:91)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.robots.RobotDetectorFilter.doFilterInternal(RobotDetectorFilter.java:62)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.aaa.UserResponseHeaderFilter.doFilter(UserResponseHeaderFilter.java:45)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:163)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.base.profiling.http.RequestProfilingFilter.doFilter(RequestProfilingFilter.java:47)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.P3PCompactPolicyFilter.doFilter(P3PCompactPolicyFilter.java:48)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.RemoveJsessionIdFilter.doFilter(RemoveJsessionIdFilter.java:40)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.ApplicationStateFilter.doFilter(ApplicationStateFilter.java:157)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:163)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.filters.CoreApiTermsAndConditionsAcceptanceFilter.doFilter(CoreApiTermsAndConditionsAcceptanceFilter.java:32)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.runas.CoreApiRunAsFilter.doFilter(CoreApiRunAsFilter.java:73)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.filters.AllowGuestAccessFilter.doFilter(AllowGuestAccessFilter.java:94)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.audit.RequestResponseAuditServletFilter.doFilter(RequestResponseAuditServletFilter.java:63)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.common.filters.ApiExceptionTranslatorFilter.doFilter(ApiExceptionTranslatorFilter.java:49)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.aaa.JiveRememberMeAuthenticationFilter.doFilter(JiveRememberMeAuthenticationFilter.java:79)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.filters.ClientIDContextFilter.doFilter(ClientIDContextFilter.java:34)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.oauth2.filter.JiveOAuth2ResourceRequestFilter.doFilter(JiveOAuth2ResourceRequestFilter.java:54)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.aaa.JiveBasicAuthenticationFilter.doFilter(JiveBasicAuthenticationFilter.java:37)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.oauth.filter.OAuth2PasscodeRequiredFilter.doFilter(OAuth2PasscodeRequiredFilter.java:60)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.oauth.spring.JiveOAuth2ProtectedResourceFilter.doFilter(JiveOAuth2ProtectedResourceFilter.java:43)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.oauth2.provider.OAuth2ExceptionHandlerFilter.doFilter(OAuth2ExceptionHandlerFilter.java:36)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:163)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.filters.CoreApiContextFilter.doFilter(CoreApiContextFilter.java:53)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.webservices.server.RequireSSLFilter.doFilter(RequireSSLFilter.java:53)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:163)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.filters.LogCorrelationIDFilter.doFilter(LogCorrelationIDFilter.java:96)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
[WARNING] [talledLocalContainer] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.AbstractApplicationStateFilter.doFilter(AbstractApplicationStateFilter.java:61)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.XFrameOptionsFilter.doFilter(XFrameOptionsFilter.java:50)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.base.plugin.PluginFilter.doFilter(PluginFilter.java:54)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.ResourceRoutingFilter.doFilter(ResourceRoutingFilter.java:44)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.base.profiling.http.ServerLatencyFilter.doFilter(ServerLatencyFilter.java:62)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[WARNING] [talledLocalContainer] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.security.XHRTokenFilter.doFilter(XHRTokenFilter.java:42)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.MetricsFilter.doFilter(MetricsFilter.java:120)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.SetRequestCharacterEncodingFilter.doFilter(SetRequestCharacterEncodingFilter.java:75)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at com.jivesoftware.community.web.filter.DispatchContextResetFilter.doFilter(DispatchContextResetFilter.java:39)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
[WARNING] [talledLocalContainer] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
[WARNING] [talledLocalContainer] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
[WARNING] [talledLocalContainer] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
[WARNING] [talledLocalContainer] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
[WARNING] [talledLocalContainer] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
[WARNING] [talledLocalContainer] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
[WARNING] [talledLocalContainer] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
[WARNING] [talledLocalContainer] at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2430)
[WARNING] [talledLocalContainer] at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2419)
[WARNING] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[WARNING] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[WARNING] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745)
[WARNING] [talledLocalContainer] Caused by: org.apache.cxf.interceptor.Fault
[WARNING] [talledLocalContainer] at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
[WARNING] [talledLocalContainer] at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
[WARNING] [talledLocalContainer] at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:198)
[WARNING] [talledLocalContainer] at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:100)
[WARNING] [talledLocalContainer] at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
[WARNING] [talledLocalContainer] at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
[WARNING] [talledLocalContainer] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
[WARNING] [talledLocalContainer] ... 178 more
[WARNING] [talledLocalContainer] Caused by: java.lang.NullPointerException
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.cxf.CxfServiceRegistry.getTypeServiceInfo(CxfServiceRegistry.java:74)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.uri.CoreRegistryUriConverter.getTypeServiceInfo(CoreRegistryUriConverter.java:70)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.uri.CoreRegistryUriConverter.apply(CoreRegistryUriConverter.java:47)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.uri.CoreRegistryUriConverter.apply(CoreRegistryUriConverter.java:1)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.links.StaticKeyLinkConverter.apply(StaticKeyLinkConverter.java:54)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.links.StaticKeyLinkConverter.apply(StaticKeyLinkConverter.java:1)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.util.ConversionUtils.addLinks(ConversionUtils.java:64)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.BaseEntityConverter.addLinks(BaseEntityConverter.java:31)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.users.UserSummaryConverter.createEntity(UserSummaryConverter.java:90)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.users.UserEntityConverter.createEntity(UserEntityConverter.java:50)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.MyUserEntityConverter.createEntity(MyUserEntityConverter.java:65)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.MyUserEntityConverter.apply(MyUserEntityConverter.java:60)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.users.UserEntityConverter.apply(UserEntityConverter.java:1)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.converters.users.UserSummaryConverter.apply(UserSummaryConverter.java:1)
[WARNING] [talledLocalContainer] at com.jivesoftware.api.core.v2.providers.users.UserProvider.getMyUser(UserProvider.java:170)
[WARNING] [talledLocalContainer] at de.unoso.plugin.services.CustomUserService.getCurrentUser(CustomUserService.java:54)
[WARNING] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[WARNING] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[WARNING] [talledLocalContainer] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[WARNING] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:606)
[WARNING] [talledLocalContainer] at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
[WARNING] [talledLocalContainer] at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
[WARNING] [talledLocalContainer] ... 183 more
[WARNING] [talledLocalContainer]
-
rest-7.0.2.1-0-SNAPSHOT.jar 13.8 KB
-
Re: Re: Can someone share an example to implement rest web services in jive 7 Plugin!
benjamin.walker Dec 29, 2014 1:12 PM (in response to allenh)Allen, these are all [WARNING]s, not [ERROR]s. How's the functionality working?
-
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
wipkands Jan 15, 2016 5:39 PM (in response to allenh)Allen Han I am also seeing system error when I tried the plugin, could you please help me in sharing what was the fix applied to address the issue
Thanks much,
Suneel
-
-
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
wipkands Jan 15, 2016 5:42 PM (in response to allenh)Kai Paroth I am seeing system error as Allen was seeing, and looks like you helped to address the issue, could you please share fix?
Thanks much,
Suneel
-
-
-
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
cgum Dec 9, 2014 10:21 PM (in response to kparoth)Thanks a lot for posting this, Kai Paroth. This information really helped me out while upgrading a number of Jive 6 plugins to Jive 7.
I owe you a beer.
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
tomsinicki Jul 30, 2015 12:47 PM (in response to kparoth)Works also fine for Jive8 and v3 services. Owe you a beer too
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
Likrant Sep 7, 2015 6:01 AM (in response to kparoth)Thanks, Kai, it was helpful.
I have overwrote class CoreApiExtensionManagerImpl, changed url path to "core/v3/myservice" and call that manager directly so now it looks like v3
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
firas Jan 15, 2016 9:35 AM (in response to kparoth)Works great, Thx man ! Owe you a beer too !
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
nayanasyamala Apr 18, 2016 6:17 PM (in response to kparoth)Hi,
This is a useful post for adding custom web services.
I have a plugin which I am developing to create two custom services.
In service registration , I am passing a list of two beans , which represents my two custom services.
However, only one of them gets registered. The other one, while invoking is giving 404.
Can't we use plugin to register more than one services?
Thanks,
Nayana
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
kparoth Apr 19, 2016 11:36 PM (in response to nayanasyamala)Hi Nayana Chemmukathu Syamala,
yes, you can register more than one service.
Here my example for V3 services:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:core="http://www.jivesoftware.com/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.jivesoftware.com/schema/core classpath:/com/jivesoftware/api/core/spring/core.xsd"
default-autowire="no" default-init-method="init" default-destroy-method="destroy">
<bean class="de.unoso.plugin.RestPlugin">
<property name="serviceRegistrar" ref="serviceRegistrar" />
</bean>
<!-- Service Initialization -->
<core:service id="customUserServiceImpl" v="3" class="de.unoso.plugin.services.CustomUserService" parent="abstractServiceV3">
<property name="userManager" ref="userManagerImpl"/>
<property name="registrationManager" ref="registrationManagerImpl"/>
</core:service>
<core:service id="customProfileServiceImpl" v="3" class="de.unoso.plugin.services.CustomProfileService" parent="abstractServiceV3">
<property name="userManager" ref="userManagerImpl"/>
<property name="profileManager" ref="profileManagerImpl"/>
</core:service>
<!-- Service Registration -->
<!-- <jive.context>/api/core/ext/custom/v3/<service.url> -->
<bean id="serviceRegistrarV3" class="de.unoso.plugin.services.ServiceRegistrar">
<property name="coreApiExtensionManager" ref="coreApiExtensionManager" />
<property name="version" value="v3" />
<property name="serviceBeans">
<list>
<ref bean="customUserServiceImpl" />
<ref bean="customProfileServiceImpl" />
</list>
</property>
<property name="name" value="custom" />
</bean>
</beans>
Regards
Kai
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
nayanasyamala Apr 20, 2016 10:38 AM (in response to kparoth)Hi Kai Paroth,
Thank you for your reply showing an example . Appreciate that.
This was how I tried first, but I found that only the first service gets invoked (Here customreviewsverviceimpl) . I couldn't find out why, though I could see two beans getting passed in CoreApiExtensionManager.registerServiceExtension().
I have two services , one for review and another for rating. While invoking second one(rating), I always get below line sbs.log
"org.apache.cxf.jaxrs.utils.JAXRSUtils - No operation matching request path "/api/core/ext/custom/v3/ratings/1005/4" is found" .
It is as if the service at that endpoint doesn't exist. But if I interchange the order or comment out reviewService, then rating service gets invoked.
First version, some section in package name masked
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:core="http://www.jivesoftware.com/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.jivesoftware.com/schema/core http://www.jivesoftware.com/schema/core.xsd"
default-autowire="no" default-init-method="init" default-destroy-method="destroy">
<bean class="com.*.communities.TestCommunitiesPlugin">
<property name="serviceRegistration" ref="serviceRegistration" />
</bean>
<core:service id="customReviewServiceImpl" v="3" class="com.*.communities.plugin.service.CustomReviewService" parent="abstractServiceV3">
<property name="commentProvider" ref="commentProviderV3"/>
</core:service>
<core:service id="customRatingServiceImpl" v="3" class="com.*.communities.plugin.service.CustomRatingService" parent="abstractServiceV3">
<property name="ratingServiceImpl" ref="ratingServiceImpl"/>
</core:service>
<bean id="serviceRegistration" class="com.*.communities.plugin.service.ServiceRegistration">
<property name="coreApiExtensionManager" ref="coreApiExtensionManager" />
<property name="version" value="v3" />
<property name="serviceBeans">
<list>
<ref bean="customReviewServiceImpl" />
<ref bean="customRatingServiceImpl" />
</list>
</property>
<property name="name" value="custom" />
</bean>
</beans>
Second version, I ended up creating two service registrations with different uri, This one worked. Though it didn't make sense to me passing only one bean in a list of beans to service registration.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:core="http://www.jivesoftware.com/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.jivesoftware.com/schema/core http://www.jivesoftware.com/schema/core.xsd"
default-autowire="no" default-init-method="init" default-destroy-method="destroy">
<bean class="com.*.communities.TestCommunitiesPlugin">
<property name="ratingServiceRegistration" ref="ratingServiceRegistration" />
<property name="reviewServiceRegistration" ref="reviewServiceRegistration" />
</bean>
<core:service id="customReviewServiceImpl" v="3" class="com.*.communities.plugin.service.CustomReviewService" parent="abstractServiceV3">
<property name="commentProvider" ref="commentProviderV3"/>
</core:service>
<core:service id="customRatingServiceImpl" v="3" class="com.*.communities.plugin.service.CustomRatingService" parent="abstractServiceV3">
<property name="ratingServiceImpl" ref="ratingServiceImpl"/>
</core:service>
<bean id="ratingServiceRegistration" class="com.*.communities.plugin.service.ServiceRegistration">
<property name="coreApiExtensionManager" ref="coreApiExtensionManager" />
<property name="version" value="v3" />
<property name="serviceBeans">
<list>
<ref bean="customRatingServiceImpl" />
</list>
</property>
<property name="name" value="ratings" />
</bean>
<bean id="reviewServiceRegistration" class="com.*.communities.plugin.service.ServiceRegistration">
<property name="coreApiExtensionManager" ref="coreApiExtensionManager" />
<property name="version" value="v3" />
<property name="serviceBeans">
<list>
<ref bean="customReviewServiceImpl" />
</list>
</property>
<property name="name" value="reviews" />
</bean>
</beans>
Thanks,
Nayana
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
Scott A Johnson Apr 20, 2016 12:12 PM (in response to nayanasyamala)2 people found this helpfulHey Nayana,
The reason your first example doesn't work is that the custom service endpoint "name" is being reused in that custom service registration class. Effectively creating two services for the same url. One has to win.
My understanding was that you shouldnt need to create a custom service registration class.
Here's an example:
spring.xml
<core:service id="customUserService" v="3" parent="abstractServiceV3" class="com.custom.v3.services.CustomUserServiceV3"> <property name="customUserProvider" ref="customUserProvider" /> </core:service>
CustomUserServiceV3.java
package com.custom.v3.services; ... @Path("/users") @CoreApiExtensionService(name = "my-custom", version = "3") public class CustomUserServiceV3 extends AbstractService { private CustomUserProvider customUserProvider; @GET @Path("/recentModifiedUsers/{cutoffTimestamp}") @RequiresAuthentication @Trace @Produces(MediaType.APPLICATION_XML) public CustomUserEntitiesList getRecentModifedUsers(@PathParam("cutoffTimestamp") long cutoffTimestamp) throws BadRequestException, ForbiddenException, NotFoundException { ... } public void setCustomUserProvider(CustomUserProvider customUserProvider) { this.customUserProvider = customUserProvider; } }
This creates a service at a url such as below which produces an XML output.
.../api/core/ext/my-custom/v3/users/recentModifiedUsers/1458496901000
The name and thus the url of the extension service is defined by the annotation CoreApiExtensionService, the endpoint "/users/recentModifiedUsers/{parameter}" is defined by the Path annotations on the class and method.
Hope this helps.
Scott
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
nayanasyamala Apr 20, 2016 3:03 PM (in response to Scott A Johnson)Hi Scott,
Make sense in the service uri perspective. Will try without using service registration.
Thank you.
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
akhila May 6, 2016 7:14 AM (in response to Scott A Johnson)Hi Scott A Johnson, Nayana Chemmukathu Syamala Kai Paroth
I have tried using this above example to create a web service in Jive 8.0.3 .I tried using both V2 and V3 api for developing a custom service but both are having issues.
V2 services
With this I get 404 not found error when I try to access my service through url
http://localhost:8080/api/core/ext/v3/customusers
and in logs I see below mentioned error. Not sure what am I missing in Url.
2016-05-06 19:30:12,932 [http-bio-8080-exec-2] [-1::REGULAR] WARN org.apache.cxf.jaxrs.utils.JAXRSUtils - No operation matching request path "/api/core/ext/custom/v3/customusers" is found, Relative Path: /core/ext/custom/v3/customusers, HTTP Method: POST, ContentType: text/plain;charset=UTF-8, Accept: */*,. Please enable FINE/TRACE log level for more details.
2016-05-06 19:30:12,937 [http-bio-8080-exec-2] [-1::REGULAR] WARN org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - javax.ws.rs.ClientErrorException
my spring .xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:core="http://www.jivesoftware.com/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.jivesoftware.com/schema/core http://www.jivesoftware.com/schema/core.xsd"
default-autowire="no" default-init-method="init" default-destroy-method="destroy"><bean class="com.apple.jivesoftware.bullwinkle.RadarIntegrationPlugin">
<property name="serviceRegistrar" ref="serviceRegistrar" />
</bean>
<!-- Service Initialization -->
<core:service id="customUserServiceImpl" v="2" class="com.apple.jivesoftware.bullwinkle.radarJiveService.webServices.CustomUserService" parent="baseServiceV2"><property name="userProvider" ref="userProviderV2"/>
</core:service>
<!-- Service Registration -->
<!-- <jive.context>/api/core/ext/custom/v2/<service.url> -->
<bean id="serviceRegistrar" class="com.apple.jivesoftware.bullwinkle.radarJiveService.webServices.ServiceRegistrar"><property name="coreApiExtensionManager" ref="coreApiExtensionManager" />
<property name="version" value="v2" />
<property name="serviceBeans">
<list>
<ref bean="customUserServiceImpl" />
</list>
</property>
<property name="name" value="custom" />
</bean>
I have used same serviceRegistrar and CustomUserService as mentioned in the original thread.
I tried converting the above sample to user V3 services with below mentioned changes to spring and CustomUserService but it fails on server startup stating bean creation error
Spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:core="http://www.jivesoftware.com/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.jivesoftware.com/schema/core http://www.jivesoftware.com/schema/core.xsd"
default-autowire="no" default-init-method="init" default-destroy-method="destroy"><!--<bean id="echoServiceImpl" class="com.apple.jivesoftware.bullwinkle.radarJiveService.webServices.EchoServiceImpl" />-->
<bean class="com.apple.jivesoftware.bullwinkle.RadarIntegrationPlugin"><property name="serviceRegistrar" ref="serviceRegistrar" />
</bean>
<!-- Service Initialization -->
<core:service id="customUserServiceImpl" v="3" class="com.apple.jivesoftware.bullwinkle.radarJiveService.webServices.CustomUserService" parent="abstractProviderV3"><property name="userProvider" ref="userProviderV2"/>
</core:service>
<!-- Service Registration -->
<!-- <jive.context>/api/core/ext/custom/v2/<service.url> -->
<bean id="serviceRegistrar" class="com.apple.jivesoftware.bullwinkle.radarJiveService.webServices.ServiceRegistrar"><property name="coreApiExtensionManager" ref="coreApiExtensionManager" />
<property name="version" value="v3" />
<property name="serviceBeans">
<list>
<ref bean="customUserServiceImpl" />
</list>
</property>
<property name="name" value="custom" />
</bean>
</beans>
CustomUserService .java looks like this
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.jivesoftware.api.core.v3.providers.AbstractProvider;
import org.springframework.beans.factory.annotation.Required;
import com.jivesoftware.api.core.v2.entities.users.UserEntity;
import com.jivesoftware.api.core.v2.providers.users.UserProvider;
import com.jivesoftware.api.core.v2.services.BaseService;
import com.jivesoftware.api.core.v3.*;
import org.apache.log4j.Logger;
@Produces("application/json")
@Path("/customusers")
public class CustomUserService extends AbstractProvider {
// Dependency Injections
private UserProvider userProvider;private static final Logger log = Logger.getLogger(CustomUserService.class);
/**
* Sets the value of userProvider.
* @param userProvider the userProvider to set.
*/
@Required
public void setUserProvider(UserProvider userProvider) {log.info("inside set user provider");
this.userProvider = userProvider;
log.info("after setting user provider"+userProvider.toString());
}
/**
* Returns the current user.
* @return the current user.
*/
@GET
public String getCurrentUser() {log.info("inside get current user");
// Return the current user...
//return userProvider.getMyUser();
return "Hello World";}
}
I am not sure why this is giving me error on bean creation .
Any input on either of the method is much appreciated.
Thanks,
Akhila
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
Scott A Johnson May 6, 2016 9:49 AM (in response to akhila)Hard to say. The url you mention at the beginning of your post does not appear to match what you've defined. It seems to be missing the /custom/ in the middle.
That said, your error message appears to be receiving a request at the correct url path, but it is complaining of no POST method being defined. In the code snippet you've shown, you have only defined a GET method handler, so it makes sense that if you're testing by POSTing a request, it will give you a 404. If you change your test to GET, does it return anything?
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
akhila May 8, 2016 9:23 PM (in response to Scott A Johnson)Hi Scott A Johnson,
I tried that but GET returns 404 as well. I am trying this using postman and providing admin credentials with Basic authentication request. Also I rechecked the URL but its pointing to correct one.
Thanks,
Akhila
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
akhila May 8, 2016 9:33 PM (in response to Scott A Johnson)I could this in my logs , Do you see anything wrong being set in this request .
2016-05-09 10:04:35,132 [http-bio-8080-exec-7] [-1::REGULAR] WARN org.apache.cxf.jaxrs.utils.JAXRSUtils - No operation matching request path "/api/core/ext/custom/v3/customusers" is found, Relative Path: /core/ext/custom/v3/customusers, HTTP Method: GET, ContentType: */*, Accept: */*,. Please enable FINE/TRACE log level for more details.
2016-05-09 10:04:35,138 [http-bio-8080-exec-7] [-1::REGULAR] WARN org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - javax.ws.rs.ClientErrorException
at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:110)
at org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:149)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:478)
Thanks,
Akhila
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
matt.hillMay 8, 2016 10:38 PM (in response to akhila)
1 person found this helpfulHi Akhila,
My guess would be that your service is being exposed at another path other than /api/core/ext/custom/v3/customusers. In the example above, provided by Scott A Johnson, a portion of the path for his service is defined the CoreApiExtensionService annotation.
@CoreApiExtensionService(name = "my-custom", version = "3")
If you provide that annotation and an appropriate unique name parameter, your service should then be available at /api/core/ext/<annotation-name-parameter>/v3/customusers. If you do not want to provide a name using that annotation, it looks like you can put a breakpoint in the ServiceMethodProvider's init method to see what your custom extension's service path will be:
Hopefully that gets you back on track,
Matt
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
akhila May 9, 2016 3:28 AM (in response to matt.hill)Hi D H / Scott A Johnson
I tried checking the end point url getting set at registerServiceExtension method in CoreApiExtensionManagerImpl "http://localhost:8080/api/core/ext/radar-integration-plugin/v2/CustomUsers" where radar-integration-plugin is my plugin name. I have not set this explicitly to the url anywhere .
Do you know why this is getting set .
Thanks,
Akhila
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
matt.hillMay 9, 2016 9:01 AM (in response to akhila)
Looks like it's defaulted from the path if you aren't explicitly setting it, in the init method I mentioned above. I'm guessing the plugin you're working in is called radar-integration-plugin? If you want to explicitly set the service path, you can use the CoreApiExtensionService annotation.
Are you able to access the service method at the radar-integration-plugin url?
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
akhila May 9, 2016 8:56 PM (in response to matt.hill)Hi D H ,
Yes I was able to access the service with this URL
http://localhost:8080/api/core/ext/radar-integration-plugin/v2/CustomUsers
where my plugin name is radar-integration-plugin and my service path at CustomUsers. If we are not setting name explicitly the url is formed along with the plugin name even though we mention "name" property in the spring.
Thanks,
Akhila
-
-
-
-
-
-
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
ggopalkrishna May 9, 2016 4:49 PM (in response to Scott A Johnson)Scott A Johnson Hi Scott,
I tried the same approach however only one service is getting registered. Also i expected my api to have following path. Can you please suggest.
Expected:
./api/core/ext/my-custom/v3/users/recentModifiedUsers/1458496901000
Actual
./api/core/ext/plugin-name/v3/users/recentModifiedUsers/
@Path("/users")
@CoreApiExtensionService(name = "my-custom", version = "v3")
public class SampleRestService extends AbstractService {
@GET
@Path("/rest/recentuser")
@Produces("application/json")
public String getRecentModifedUsers()
throws BadRequestException, NotFoundException {
return "success message";
}
<core:service id="testService" v="3" class="com.plugin.service.SampleRestService" parent="abstractServiceV3">
</core:service>
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
Scott A Johnson May 9, 2016 5:55 PM (in response to ggopalkrishna)1 person found this helpfulIt seems I was mistaken. It appears that the custom services do not use the value set in the name field of that annotation. My name just happened to be the same as my plugin name.
You could do some more digging through the initialization code for services to see if you can find out how it gets the plugin name and see if there's any way to override it, but otherwise, you may be stuck with using the plugin name.
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
akhila May 9, 2016 9:55 PM (in response to ggopalkrishna)I tried overriding CoreApiExtensionManagerImpl class with method registerServiceExtension. I am setting the "name" to my custom service before calling the registerServiceExtension of the CoreApiExtensionManagerImpl.
This worked for me.
Thanks Scott A Johnson D H for your inputs.
Thanks,
Akhila
-
-
-
-
-
-
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
atishc Dec 11, 2014 7:44 AM (in response to shipra)Hi Shipra,
If you want your SOAP based Web Service to work below is the code in spring.xml file. Note that you will not be able to use Jive shipped SOAP based service that you were using before as those class doesn't exisit in Jive 7 binary.You have to define your won set of functionality.
<beans ...... xmlns:jaxws="http://cxf.apache.org/jaxws" .... xsi:schemaLocation=".... http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd..." >
...
<jaxws:endpoint id="createByEmialListSoapService" address="/soap/CreateByEmialListService" bus="rpcCxfBus">
<jaxws:implementor>
<ref bean="createByEmialListServiceImpl" />
</jaxws:implementor>
<jaxws:outFaultInterceptors>
<ref bean="serverExceptionInterceptor" />
</jaxws:outFaultInterceptors>
<jaxws:inInterceptors>
<ref bean="saajInInterceptor" />
<ref bean="wss4jInInterceptor" />
<ref bean="validationCheckInterceptor" />
</jaxws:inInterceptors>
</jaxws:endpoint>
<bean id="createByEmialListServiceImpl" class="com.vmware.community.mail.impl.CreateByEmialListServiceImpl">
<property name="createByEmailManager" ref="createByEmailManager"/>
</bean>
I have tested it using Jive 7.0.2 version.
~Atish
-
Re: Can someone share an example to implement rest web services in jive 7 Plugin!
prabhakar.pateti Mar 6, 2015 2:19 AM (in response to shipra)Hello Shipra,
I am Prabhakar. I am looking for solution that "How to invoke web service call from Jive for a particular activity " ( Ex., when new document posted, when new reply came in etc ) from a 3rd party Server.
Basically we are working on Automatic Push Notification task., and whenever there is new post in my Jive, I should be able to get push from Jive to my Mobile App to notify the news / feeds in my personnel community Can you please help me if possible ?
Prabhakar