Delete the useless commetd
authornancylizi <li.zi30@zte.com.cn>
Thu, 1 Sep 2016 10:37:24 +0000 (18:37 +0800)
committernancylizi <li.zi30@zte.com.cn>
Thu, 1 Sep 2016 10:37:24 +0000 (18:37 +0800)
Change-Id: I40c2e11d23df61b38ab69910ac88c387a1260747
Signed-off-by: nancylizi <li.zi30@zte.com.cn>
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdException.java [deleted file]
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdService.java [deleted file]
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdServlet.java [deleted file]
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdUtil.java [deleted file]
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
catalog-core/distribution/catalog-all/src/main/assembly/startup.sh

index 6357782..2cd532b 100644 (file)
@@ -115,7 +115,7 @@ public class CatalogApp extends Application<CatalogAppConfiguration> {
     environment.jersey().register(MultiPartFeature.class);\r
 \r
     initSwaggerConfig(environment, configuration);\r
-    initCometd(environment);\r
+//    initCometd(environment);\r
     Config.setConfigration(configuration);\r
     initService();\r
     LOGGER.info("Initialize catalogue finished.");\r
@@ -159,17 +159,17 @@ public class CatalogApp extends Application<CatalogAppConfiguration> {
    * \r
    * @param environment environment information\r
    */\r
-  private void initCometd(Environment environment) {\r
-    // add filter\r
-    environment.getApplicationContext().addFilter(CrossOriginFilter.class,\r
-        "/api/nsoccataloguenotification/v1/*",\r
-        EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));\r
-    // add servlet\r
-    environment.getApplicationContext()\r
-        .addServlet("org.cometd.server.CometDServlet", "/api/nsoccataloguenotification/v1/*")\r
-        .setInitOrder(1);\r
-    // add servlet\r
-    environment.getApplicationContext()\r
-        .addServlet("CometdServlet", "/api/nsoccataloguenotification/v1").setInitOrder(2);\r
-  }\r
+//  private void initCometd(Environment environment) {\r
+//    // add filter\r
+//    environment.getApplicationContext().addFilter(CrossOriginFilter.class,\r
+//        "/api/nsoccataloguenotification/v1/*",\r
+//        EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));\r
+//    // add servlet\r
+//    environment.getApplicationContext()\r
+//        .addServlet("org.cometd.server.CometDServlet", "/api/nsoccataloguenotification/v1/*")\r
+//        .setInitOrder(1);\r
+//    // add servlet\r
+//    environment.getApplicationContext()\r
+//        .addServlet("CometdServlet", "/api/nsoccataloguenotification/v1").setInitOrder(2);\r
+//  }\r
 }\r
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdException.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdException.java
deleted file mode 100644 (file)
index 65b1d5a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/**\r
- * Copyright 2016 [ZTE] and others.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.openo.commontosca.catalog.cometd;\r
-\r
-\r
-public class CometdException extends Exception {\r
-  private static final long serialVersionUID = 497640895744777904L;\r
-\r
-  public static final int ERROR_CODE_BAYEUX = 0;\r
-  public static final int ERROR_CODE_PRARM_ERROR = 1;\r
-  public static final int ERROR_CODE_SESSION_ERROR = 2;\r
-  public static final int ERROR_CODE_SUBSCRIBE_TIMEOUT = 3;\r
-\r
-  private int errorCode = -1;\r
-\r
-  public CometdException(String message) {\r
-    super(message);\r
-  }\r
-\r
-  public CometdException(Throwable e1) {\r
-    super(e1);\r
-  }\r
-\r
-  public CometdException(int code, String message) {\r
-    super(message);\r
-    this.errorCode = code;\r
-  }\r
-\r
-  public int getErrorCode() {\r
-    return this.errorCode;\r
-  }\r
-\r
-  @Override\r
-  public String toString() {\r
-    String str = getClass().getName();\r
-    String message = getLocalizedMessage();\r
-    message = (message != null) ? (str + ": " + message) : str;\r
-    return "errorcode: " + this.errorCode + ";" + message;\r
-  }\r
-}\r
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdService.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdService.java
deleted file mode 100644 (file)
index 823e5d1..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/**\r
- * Copyright 2016 [ZTE] and others.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.openo.commontosca.catalog.cometd;\r
-\r
-import org.cometd.bayeux.server.BayeuxServer;\r
-import org.cometd.bayeux.server.ConfigurableServerChannel;\r
-import org.cometd.bayeux.server.LocalSession;\r
-import org.cometd.bayeux.server.ServerChannel;\r
-\r
-import java.io.IOException;\r
-\r
-public class CometdService {\r
-  private BayeuxServer bayeux;\r
-  private LocalSession session;\r
-\r
-  /**\r
-   * meta channel.\r
-   */\r
-  private static final String bayeuxChannel = "/meta/";\r
-\r
-  /**\r
-   * service channel.\r
-   */\r
-  private static final String serviceChannel = "/service/";\r
-\r
-  private static CometdService cometdService = null;\r
-\r
-  /**\r
-   * get cometd service instance.\r
-   * \r
-   * @return cometdService\r
-   */\r
-  public static CometdService getInstance() {\r
-    if (cometdService == null) {\r
-      cometdService = new CometdService();\r
-    }\r
-    return cometdService;\r
-  }\r
-\r
-  /**\r
-   * publish commetd.\r
-   * @param channel commetd channel\r
-   * @param message message to commet\r
-   * @throws CometdException e1\r
-   */\r
-  public void publish(String channel, Object message) throws CometdException {\r
-    if (bayeux == null) {\r
-      this.bayeux = CometdUtil.getBayeuxServer();\r
-      checkBayeuxServer();\r
-      this.session = this.bayeux.newLocalSession("openo_catalogue_local_session");\r
-      this.session.handshake();\r
-    }\r
-    String jsonMsg;\r
-    try {\r
-      jsonMsg = CometdUtil.convertBean2Json(message);\r
-    } catch (IOException e1) {\r
-      throw new CometdException(e1);\r
-    }\r
-\r
-    checkAndInit(channel);\r
-    ServerChannel serverChannel = this.bayeux.getChannel(channel);\r
-    serverChannel.publish(this.session, jsonMsg);\r
-  }\r
-\r
-  private void checkBayeuxServer() throws CometdException {\r
-    if (this.bayeux == null) {\r
-      throw new CometdException(CometdException.ERROR_CODE_BAYEUX, "bayeux is null.");\r
-    }\r
-  }\r
-\r
-  private void checkAndInit(String channel) throws CometdException {\r
-    checkBayeuxServer();\r
-    checkSession();\r
-    checkChannel(channel);\r
-    bayeux.createChannelIfAbsent(channel, new ConfigurableServerChannel.Initializer() {\r
-      @Override\r
-      public void configureChannel(ConfigurableServerChannel channel) {\r
-        channel.setPersistent(true);\r
-        channel.setLazy(true);\r
-      }\r
-    });\r
-  }\r
-\r
-  private void checkSession() throws CometdException {\r
-    if (session == null || !session.isConnected()) {\r
-      throw new CometdException(CometdException.ERROR_CODE_SESSION_ERROR, "session is invalid.");\r
-    }\r
-  }\r
-\r
-  private void checkChannel(String channel) throws CometdException {\r
-    if (channel == null || "".equals(channel)) {\r
-      throw new CometdException(CometdException.ERROR_CODE_PRARM_ERROR, "channel is null.");\r
-    }\r
-    if (channel.startsWith(bayeuxChannel)) {\r
-      throw new CometdException(CometdException.ERROR_CODE_PRARM_ERROR, "channel [" + channel\r
-          + "] is bayeuxChannel.");\r
-    }\r
-    if (channel.startsWith(serviceChannel)) {\r
-      throw new CometdException(CometdException.ERROR_CODE_PRARM_ERROR, "channel [" + channel\r
-          + "] is serviceChannel.");\r
-    }\r
-  }\r
-}\r
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdServlet.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdServlet.java
deleted file mode 100644 (file)
index d44c330..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/**\r
- * Copyright 2016 [ZTE] and others.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.openo.commontosca.catalog.cometd;\r
-\r
-import org.cometd.annotation.Listener;\r
-import org.cometd.annotation.ServerAnnotationProcessor;\r
-import org.cometd.annotation.Service;\r
-import org.cometd.bayeux.Message;\r
-import org.cometd.bayeux.server.BayeuxServer;\r
-import org.cometd.bayeux.server.ServerChannel;\r
-import org.cometd.bayeux.server.ServerMessage;\r
-import org.cometd.bayeux.server.ServerSession;\r
-import org.cometd.server.authorizer.GrantAuthorizer;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.GenericServlet;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.ServletResponse;\r
-import javax.servlet.UnavailableException;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-\r
-\r
-public class CometdServlet extends GenericServlet {\r
-\r
-  private static final long serialVersionUID = 1L;\r
-\r
-  private static final Logger logger = LoggerFactory.getLogger(CometdServlet.class);\r
-\r
-  @Override\r
-  public void init() throws ServletException {\r
-    super.init();\r
-\r
-    final BayeuxServer bayeux =\r
-        (BayeuxServer) getServletContext().getAttribute(BayeuxServer.ATTRIBUTE);\r
-    if (bayeux == null) {\r
-      throw new UnavailableException("No BayeuxServer!");\r
-    }\r
-\r
-    // Allow anybody to handshake\r
-    bayeux.getChannel(ServerChannel.META_HANDSHAKE).addAuthorizer(GrantAuthorizer.GRANT_PUBLISH);\r
-\r
-    // start server processor\r
-    ServerAnnotationProcessor processor = new ServerAnnotationProcessor(bayeux);\r
-    processor.process(new Monitor());\r
-\r
-    CometdUtil.setBayeuxServer(bayeux);\r
-  }\r
-\r
-  @Override\r
-  public void service(ServletRequest paramServletRequest, ServletResponse paramServletResponse)\r
-      throws ServletException, IOException {\r
-    ((HttpServletResponse) paramServletResponse).sendError(503);\r
-  }\r
-\r
-  @Service("monitor")\r
-  public static class Monitor {\r
-    @Listener("/meta/subscribe")\r
-    public void monitorSubscribe(ServerSession session, ServerMessage message) {\r
-      logger.info("Monitored subscribe from " + session + " for "\r
-          + message.get(Message.SUBSCRIPTION_FIELD));\r
-    }\r
-\r
-    @Listener("/meta/unsubscribe")\r
-    public void monitorUnsubscribe(ServerSession session, ServerMessage message) {\r
-      logger.info("Monitored unsubscribe from " + session + " for "\r
-          + message.get(Message.SUBSCRIPTION_FIELD));\r
-    }\r
-\r
-    @Listener("/meta/*")\r
-    public void monitorMeta(ServerSession session, ServerMessage message) {\r
-      logger.debug(message.toString());\r
-    }\r
-  }\r
-}\r
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/cometd/CometdUtil.java
deleted file mode 100644 (file)
index 400fcc3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/**\r
- * Copyright 2016 [ZTE] and others.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.openo.commontosca.catalog.cometd;\r
-\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import org.cometd.bayeux.server.BayeuxServer;\r
-\r
-import java.io.IOException;\r
-import java.util.Map;\r
-\r
-\r
-\r
-public class CometdUtil {\r
-  private static BayeuxServer bayeuxServer;\r
-\r
-  public static BayeuxServer getBayeuxServer() {\r
-    return bayeuxServer;\r
-  }\r
-\r
-  public static void setBayeuxServer(BayeuxServer bayeuxServer) {\r
-    CometdUtil.bayeuxServer = bayeuxServer;\r
-  }\r
-\r
-  public static String convertBean2Json(Object object) throws IOException {\r
-    ObjectMapper mapper = new ObjectMapper();\r
-    return mapper.writeValueAsString(object);\r
-  }\r
-\r
-  @SuppressWarnings("rawtypes")\r
-  public static Map convertJson2Map(String json) throws IOException {\r
-    ObjectMapper mapper = new ObjectMapper();\r
-    return mapper.readValue(json, Map.class);\r
-  }\r
-}\r
index 9656cb6..2837fd3 100644 (file)
@@ -27,7 +27,6 @@ import java.util.List;
 \r
 import javax.ws.rs.NotFoundException;\r
 \r
-import org.openo.commontosca.catalog.cometd.CometdException;\r
 import org.openo.commontosca.catalog.common.CommonConstant;\r
 import org.openo.commontosca.catalog.common.FileUtil;\r
 import org.openo.commontosca.catalog.common.MsbAddrConfig;\r
@@ -175,7 +174,7 @@ public class PackageWrapperUtil {
     return result;\r
   }\r
 \r
-  public static boolean isExistInstanceCSAR(String csarId) throws CometdException {\r
+  public static boolean isExistInstanceCSAR(String csarId) {\r
     // 查询各O(GSO、NFVO、SDNO)的资源实例数据库,查询指定csarId对应的服务模版\r
     ArrayList<ServiceTemplate> templateList = queryAvailableTemplatesByCsar(csarId);\r
     // 调生命周期的接口查询所有实例,查询实例中是否包含指定csarId对应的服务模析ID\r
index 2e2dfe2..67c58f7 100644 (file)
@@ -1,5 +1,4 @@
-#!/bin/sh
-#
+#
 # Copyright 2016 [ZTE] and others.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");