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