Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

CLEREZZA-722: adding stanbol menu items to a stanbol-category of the …

…clerezz global manu

git-svn-id: https://svn.apache.org/repos/asf/incubator/clerezza/trunk@1424404 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 94ac4e380db2be6f0de1347fe76b4434e7bc7e94 1 parent 08d08bf
Reto Gmür authored December 20, 2012
4  jaxrs.stanbol.fragments/pom.xml
@@ -65,6 +65,10 @@
65 65
 			<artifactId>org.json.simple</artifactId>
66 66
 		</dependency>
67 67
         <dependency>
  68
+			<groupId>org.apache.clerezza</groupId>
  69
+			<artifactId>platform.dashboard.core</artifactId>
  70
+		</dependency>
  71
+        <dependency>
68 72
             <groupId>org.apache.stanbol</groupId>
69 73
             <artifactId>org.apache.stanbol.commons.web.base</artifactId>
70 74
             <version>0.11.0-SNAPSHOT</version>
34  ...stanbol.fragments/src/main/scala/org/apache/clerezza/jaxrs/stanbol/webfragements/WebFragmentRunner.scala
@@ -29,6 +29,8 @@ import javax.servlet.http.HttpServlet
29 29
 import javax.ws.rs.ext.ContextResolver
30 30
 import javax.ws.rs.ext.Provider
31 31
 import org.apache.clerezza.osgi.services.ActivationHelper
  32
+import org.apache.clerezza.platform.dashboard.GlobalMenuItem
  33
+import org.apache.clerezza.platform.dashboard.GlobalMenuItemsProvider
32 34
 import org.apache.felix.scr.annotations._
33 35
 import org.apache.stanbol.commons.web.base.LinkResource
34 36
 import org.apache.stanbol.commons.web.base.NavigationLink
@@ -47,9 +49,9 @@ import org.slf4j.scala.Logging
47 49
            policy = ReferencePolicy.DYNAMIC)
48 50
 //@Service(Array(classOf[Servlet]))
49 51
 //@Property(name = "alias", value = Array("/stanbol-ugly-servlet-context-initializer"))
50  
-@Service(value = Array(classOf[javax.servlet.Filter]))
  52
+@Service(value = Array(classOf[javax.servlet.Filter], classOf[GlobalMenuItemsProvider]))
51 53
 @Property(name ="pattern", value=Array(".*"))
52  
-class WebFragmentRunner extends javax.servlet.Filter with Logging {
  54
+class WebFragmentRunner extends javax.servlet.Filter with GlobalMenuItemsProvider with Logging {
53 55
 
54 56
   @Reference
55 57
   private var winkRequestProcessor: WinkRequestProcessor = _
@@ -84,7 +86,8 @@ class WebFragmentRunner extends javax.servlet.Filter with Logging {
84 86
   private var corsOrigins : java.util.Set[String] = _
85 87
   private var exposedHeaders : java.util.Set[String] = _
86 88
   private var contextResolverImpl : ContextResolverImpl = _
87  
-
  89
+  
  90
+  val menuItems = new java.util.HashSet[GlobalMenuItem]
88 91
 
89 92
 
90 93
   @Activate
@@ -168,6 +171,12 @@ class WebFragmentRunner extends javax.servlet.Filter with Logging {
168 171
     linkResources.addAll(f.getLinkResources());
169 172
     scriptResources.addAll(f.getScriptResources());
170 173
     navigationLinks.addAll(f.getNavigationLinks());
  174
+    {
  175
+      import scala.collection.JavaConverters._
  176
+      for (nl <- f.getNavigationLinks.asScala) {
  177
+        menuItems.add(new GlobalMenuItem("/"+nl.path, nl.label, nl.label, nl.order, "Stanbol"))
  178
+      }
  179
+    };
171 180
     synchronized {
172 181
       webFragments ::= f
173 182
       activator.foreach { a =>
@@ -182,6 +191,12 @@ class WebFragmentRunner extends javax.servlet.Filter with Logging {
182 191
     linkResources.removeAll(f.getLinkResources());
183 192
     scriptResources.removeAll(f.getScriptResources());
184 193
     navigationLinks.removeAll(f.getNavigationLinks());
  194
+    {
  195
+      import scala.collection.JavaConverters._
  196
+      for (nl <- f.getNavigationLinks.asScala) {
  197
+        menuItems.remove(new GlobalMenuItem("/"+nl.path, nl.label, nl.label, nl.order, "Stanbol"))
  198
+      }
  199
+    };
185 200
     synchronized {
186 201
       webFragments = webFragments diff List(f)
187 202
       activator.foreach { a=>
@@ -208,7 +223,7 @@ class WebFragmentRunner extends javax.servlet.Filter with Logging {
208 223
     servletContext.setAttribute(BaseStanbolResource.NAVIGATION_LINKS, navigationLinks);
209 224
     servletContext.setAttribute(CORS_ORIGIN, corsOrigins);
210 225
     servletContext.setAttribute(CORS_ACCESS_CONTROL_EXPOSE_HEADERS, exposedHeaders);
211  
-    contextResolverImpl = new ContextResolverImpl(servletContext, bundleContext)
  226
+    contextResolverImpl = new ContextResolverImpl(servletContext)
212 227
     winkRequestProcessor.bindComponent(contextResolverImpl)
213 228
   }
214 229
   
@@ -221,11 +236,13 @@ class WebFragmentRunner extends javax.servlet.Filter with Logging {
221 236
       winkRequestProcessor.unbindComponent(contextResolverImpl)
222 237
 	}
223 238
 
  239
+  def getMenuItems() : java.util.Set[GlobalMenuItem]  = {
224 240
 
225  
-}
  241
+    return menuItems
  242
+  }
226 243
 
227  
-@Provider
228  
-class ContextResolverImpl(servletContext: ServletContext, bundleContext: BundleContext) extends ContextResolver[ServletContext] {
  244
+  @Provider
  245
+  class ContextResolverImpl(servletContext: ServletContext) extends ContextResolver[ServletContext] {
229 246
 
230 247
     def getContext(clazz: Class[_]): ServletContext = {
231 248
         def wrapped = servletContext;
@@ -270,4 +287,7 @@ class ContextResolverImpl(servletContext: ServletContext, bundleContext: BundleC
270 287
 			def getContextPath() :String = { wrapped.getContextPath()}
271 288
         }
272 289
     }
  290
+  }
273 291
 }
  292
+
  293
+

0 notes on commit 94ac4e3

Please sign in to comment.
Something went wrong with that request. Please try again.