mirror of
https://github.com/apache/sqoop.git
synced 2025-05-21 19:31:13 +08:00
SQOOP-2544. Sqoop2: Drop connectors servlet
(Jarcec via Hari)
This commit is contained in:
parent
bf09850c33
commit
7e5075b2af
@ -26,7 +26,6 @@
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.sqoop.audit.AuditLoggerManager;
|
||||
import org.apache.sqoop.common.SqoopException;
|
||||
import org.apache.sqoop.connector.ConnectorManager;
|
||||
import org.apache.sqoop.json.ConnectorBean;
|
||||
import org.apache.sqoop.json.ConnectorsBean;
|
||||
@ -35,29 +34,19 @@
|
||||
import org.apache.sqoop.model.MResource;
|
||||
import org.apache.sqoop.security.authorization.AuthorizationEngine;
|
||||
import org.apache.sqoop.server.RequestContext;
|
||||
import org.apache.sqoop.server.RequestContext.Method;
|
||||
import org.apache.sqoop.server.RequestHandler;
|
||||
import org.apache.sqoop.server.common.ServerError;
|
||||
|
||||
public class ConnectorRequestHandler implements RequestHandler {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ConnectorRequestHandler.class);
|
||||
|
||||
private static final String CONNECTORS_PATH = "connectors";
|
||||
|
||||
public ConnectorRequestHandler() {
|
||||
LOG.info("ConnectorRequestHandler initialized");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBean handleEvent(RequestContext ctx) {
|
||||
// connector only support GET requests
|
||||
if (ctx.getMethod() != Method.GET) {
|
||||
throw new SqoopException(ServerError.SERVER_0002, "Unsupported HTTP method for connector:"
|
||||
+ ctx.getMethod());
|
||||
}
|
||||
|
||||
List<MConnector> connectors;
|
||||
Map<Long, ResourceBundle> configParamBundles;
|
||||
Locale locale = ctx.getAcceptLanguageHeader();
|
||||
@ -65,7 +54,7 @@ public JsonBean handleEvent(RequestContext ctx) {
|
||||
|
||||
LOG.info("ConnectorRequestHandler handles cid: " + cIdentifier);
|
||||
|
||||
if (ctx.getPath().contains(CONNECTORS_PATH) || cIdentifier.equals("all")) {
|
||||
if (cIdentifier.equals("all")) {
|
||||
connectors = ConnectorManager.getInstance().getConnectorConfigurables();
|
||||
configParamBundles = ConnectorManager.getInstance().getResourceBundles(locale);
|
||||
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
|
||||
@ -81,7 +70,7 @@ public JsonBean handleEvent(RequestContext ctx) {
|
||||
// NOTE: connectorId is a fallback for older sqoop clients if any, since we want to primarily use unique conenctorNames
|
||||
String cName = HandlerUtils.getConnectorNameFromIdentifier(cIdentifier);
|
||||
|
||||
configParamBundles = new HashMap<Long, ResourceBundle>();
|
||||
configParamBundles = new HashMap<>();
|
||||
|
||||
MConnector connector = ConnectorManager.getInstance().getConnectorConfigurable(cName);
|
||||
configParamBundles.put(connector.getPersistenceId(),
|
||||
|
@ -1,44 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.apache.sqoop.server.v1;
|
||||
|
||||
import org.apache.sqoop.handler.ConnectorRequestHandler;
|
||||
import org.apache.sqoop.json.JsonBean;
|
||||
import org.apache.sqoop.server.RequestContext;
|
||||
import org.apache.sqoop.server.RequestHandler;
|
||||
import org.apache.sqoop.server.SqoopProtocolServlet;
|
||||
|
||||
/**
|
||||
* Displays all connectors registered in sqoop
|
||||
* GET v1/connectors
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ConnectorsServlet extends SqoopProtocolServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private RequestHandler connectorRequestHandler;
|
||||
|
||||
public ConnectorsServlet() {
|
||||
connectorRequestHandler = new ConnectorRequestHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
|
||||
return connectorRequestHandler.handleEvent(ctx);
|
||||
}
|
||||
}
|
@ -74,18 +74,6 @@ limitations under the License.
|
||||
<url-pattern>/v1/connector/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Connectors servlet -->
|
||||
<servlet>
|
||||
<servlet-name>v1.ConnectorsServlet</servlet-name>
|
||||
<servlet-class>org.apache.sqoop.server.v1.ConnectorServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>v1.ConnectorsServlet</servlet-name>
|
||||
<url-pattern>/v1/connectors/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Driver servlet -->
|
||||
<servlet>
|
||||
<servlet-name>v1.DriverServlet</servlet-name>
|
||||
|
Loading…
Reference in New Issue
Block a user