commit b71b4caccdea3895ac9e50b89ca5ee978ffb01b1
Author: Daniel Shahaf
Date: Wed Mar 28 00:04:41 2012 +0000
move sqoop to TLP
git-svn-id: https://svn.apache.org/repos/asf/sqoop/branches/sqoop2@1306066 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..beef00d0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
diff --git a/DISCLAIMER.txt b/DISCLAIMER.txt
new file mode 100644
index 00000000..460e6652
--- /dev/null
+++ b/DISCLAIMER.txt
@@ -0,0 +1,16 @@
+Apache Sqoop is an effort undergoing incubation at the Apache Software
+Foundation (ASF), sponsored by the Apache Incubator Project Management
+Committee.
+
+Incubation is required for all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decisions making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+For more information about the incubation status of the Sqoop project you can
+go to the following page:
+
+http://incubator.apache.org/projects/sqoop.html
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/NOTICE.txt b/NOTICE.txt
new file mode 100644
index 00000000..cb22834f
--- /dev/null
+++ b/NOTICE.txt
@@ -0,0 +1,8 @@
+Apache Sqoop (incubating)
+Copyright 2011-2012 The Apache Software Foundation
+
+This product includes softare developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Portions of this software were developed at
+Cloudera, Inc. (http://www.cloudera.com/).
diff --git a/README.txt b/README.txt
new file mode 100644
index 00000000..80d421ec
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,13 @@
+----
+The sqoop2 branch is an experimental branch for the development of the
+next major release of Sqoop.
+
+For more details please see the following JIRA issue:
+https://issues.apache.org/jira/browse/SQOOP-365
+----
+
+Welcome to Sqoop!
+
+This document outlines how to build the source code.
+
+TODO: add details
diff --git a/client/pom.xml b/client/pom.xml
new file mode 100644
index 00000000..fb7e11c6
--- /dev/null
+++ b/client/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache
+ sqoop
+ 2.0.0-SNAPSHOT
+
+
+ org.apache.sqoop
+ sqoop-client
+ Sqoop Client
+
+
+
+ org.apache.sqoop
+ sqoop-core
+ 2.0.0-SNAPSHOT
+
+
+ org.apache.sqoop
+ sqoop-common
+ 2.0.0-SNAPSHOT
+
+
+
diff --git a/common/pom.xml b/common/pom.xml
new file mode 100644
index 00000000..2ab9073c
--- /dev/null
+++ b/common/pom.xml
@@ -0,0 +1,101 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache
+ sqoop
+ 2.0.0-SNAPSHOT
+
+
+ org.apache.sqoop
+ sqoop-common
+ Sqoop Common
+
+
+
+ com.googlecode.json-simple
+ json-simple
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ save-version
+ generate-sources
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ ${project.build.directory}/generated-sources/java
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
+
diff --git a/common/src/main/java/org/apache/sqoop/common/ErrorCode.java b/common/src/main/java/org/apache/sqoop/common/ErrorCode.java
new file mode 100644
index 00000000..f53d9729
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/ErrorCode.java
@@ -0,0 +1,37 @@
+/**
+ * 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.common;
+
+/**
+ * Defines an error-code contract. Sqoop exceptions use the error code to
+ * communicate error information where possible. Each error code is associated
+ * with default message that identifies the high level information related to
+ * the underlying error condition.
+ */
+public interface ErrorCode {
+
+ /**
+ * @return the string representation of the error code.
+ */
+ public String getCode();
+
+ /**
+ * @return the message associated with error code.
+ */
+ public String getMessage();
+}
diff --git a/common/src/main/java/org/apache/sqoop/common/ExceptionInfo.java b/common/src/main/java/org/apache/sqoop/common/ExceptionInfo.java
new file mode 100644
index 00000000..b55111fe
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/ExceptionInfo.java
@@ -0,0 +1,64 @@
+/**
+ * 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.common;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.sqoop.json.JsonBean;
+import org.json.simple.JSONObject;
+
+public class ExceptionInfo implements JsonBean {
+
+ public static final String ERROR_CODE = "error-code";
+ public static final String ERROR_MESSAGE = "error-message";
+ public static final String STACK_TRACE = "stack-trace";
+
+ private String errorCode;
+ private String errorMessage;
+ private String stackTrace;
+
+ public ExceptionInfo(String code, String message, Exception ex) {
+ errorCode = code;
+ errorMessage = message;
+
+ StringWriter writer = new StringWriter();
+ ex.printStackTrace(new PrintWriter(writer));
+ writer.flush();
+
+ stackTrace = writer.getBuffer().toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public JSONObject extract() {
+ JSONObject result = new JSONObject();
+ result.put(ERROR_CODE, errorCode);
+ result.put(ERROR_MESSAGE, errorMessage);
+ result.put(STACK_TRACE, stackTrace);
+
+ return result;
+ }
+
+ @Override
+ public void restore(JSONObject jsonObject) {
+ errorCode = (String) jsonObject.get(ERROR_CODE);
+ errorMessage = (String) jsonObject.get(ERROR_MESSAGE);
+ stackTrace = (String) jsonObject.get(STACK_TRACE);
+ }
+}
diff --git a/common/src/main/java/org/apache/sqoop/common/SqoopException.java b/common/src/main/java/org/apache/sqoop/common/SqoopException.java
new file mode 100644
index 00000000..6caed13a
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/SqoopException.java
@@ -0,0 +1,55 @@
+/**
+ * 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.common;
+
+
+/**
+ * Base exception for Sqoop framework. This exception requires the specification
+ * of an error code for reference purposes. Where necessary the appropriate
+ * constructor can be used to pass in additional message beyond what is
+ * specified by the error code and/or the causal exception.
+ */
+@SuppressWarnings("serial")
+public class SqoopException extends RuntimeException {
+
+ private final ErrorCode code;
+
+ public SqoopException(ErrorCode code) {
+ super(code.getCode() + ":" + code.getMessage());
+ this.code = code;
+ }
+
+ public SqoopException(ErrorCode code, String extraInfo) {
+ super(code.getCode() + ":" + code.getMessage() + " - " + extraInfo);
+ this.code = code;
+ }
+
+ public SqoopException(ErrorCode code, Throwable cause) {
+ super(code.getCode() + ":" + code.getMessage(), cause);
+ this.code = code;
+ }
+
+ public SqoopException(ErrorCode code, String extraInfo, Throwable cause) {
+ super(code.getCode() + ":" + code.getMessage() + " - " + extraInfo, cause);
+ this.code = code;
+ }
+
+ public ErrorCode getErrorCode() {
+ return code;
+ }
+}
diff --git a/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java b/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java
new file mode 100644
index 00000000..b06e0595
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java
@@ -0,0 +1,38 @@
+/**
+ * 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.common;
+
+public class SqoopProtocolConstants {
+
+ public static final String HEADER_SQOOP_ERROR_CODE = "sqoop-error-code";
+
+ public static final String HEADER_SQOOP_ERROR_MESSAGE = "sqoop-error-message";
+
+ public static final String HEADER_SQOOP_INTERNAL_ERROR_CODE =
+ "sqoop-internal-error-code";
+
+ public static final String HEADER_SQOOP_INTERNAL_ERROR_MESSAGE =
+ "sqoop-internal-error-message";
+
+ public static final String JSON_CONTENT_TYPE =
+ "application/json; charset=\"UTF-8\"";
+
+ private SqoopProtocolConstants() {
+ // Disable explicit object creation
+ }
+}
diff --git a/common/src/main/java/org/apache/sqoop/common/SqoopResponseCode.java b/common/src/main/java/org/apache/sqoop/common/SqoopResponseCode.java
new file mode 100644
index 00000000..93a43f5d
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/SqoopResponseCode.java
@@ -0,0 +1,45 @@
+/**
+ * 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.common;
+
+public enum SqoopResponseCode {
+
+ SQOOP_1000("1000", "OK"),
+ SQOOP_2000("2000", "ERROR");
+
+ private final String code;
+ private final String message;
+
+ private SqoopResponseCode(String code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public static SqoopResponseCode getFromCode(String code) {
+ return SqoopResponseCode.valueOf("SQOOP_" + code);
+ }
+
+}
diff --git a/common/src/main/java/org/apache/sqoop/common/VersionAnnotation.java b/common/src/main/java/org/apache/sqoop/common/VersionAnnotation.java
new file mode 100644
index 00000000..acd901f1
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/VersionAnnotation.java
@@ -0,0 +1,57 @@
+/*
+ * 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.common;
+
+import java.lang.annotation.*;
+
+/**
+ * A package attribute that captures the version that was compiled.
+ * Copied down from hadoop. All is same except name of interface.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PACKAGE)
+public @interface VersionAnnotation {
+
+ /**
+ * Get the Hadoop version
+ * @return the version string (eg. "2.0.0")
+ */
+ String version();
+
+ /**
+ * Get the username that compiled the code.
+ */
+ String user();
+
+ /**
+ * Get the date when the code was compiled.
+ * @return the date in unix 'date' format
+ */
+ String date();
+
+ /**
+ * Get the url for the subversion repository.
+ */
+ String url();
+
+ /**
+ * Get the subversion revision.
+ * @return the revision number as a string (eg. "451451")
+ */
+ String revision();
+}
diff --git a/common/src/main/java/org/apache/sqoop/common/VersionInfo.java b/common/src/main/java/org/apache/sqoop/common/VersionInfo.java
new file mode 100644
index 00000000..02f8cf3e
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/common/VersionInfo.java
@@ -0,0 +1,74 @@
+/**
+ * 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.common;
+
+public class VersionInfo {
+
+ private static Package myPackage;
+ private static VersionAnnotation annotation;
+
+ static {
+ myPackage = VersionAnnotation.class.getPackage();
+ annotation = myPackage.getAnnotation(VersionAnnotation.class);
+ }
+
+ private VersionInfo() {
+ // Disable explicit object creation
+ }
+
+ /**
+ * Get the version.
+ * @return the version string, eg. "2.0.0"
+ */
+ public static String getVersion() {
+ return annotation != null ? annotation.version() : "Unknown";
+ }
+
+ /**
+ * Get the subversion revision number for the root directory
+ * @return the revision number, eg. "451451"
+ */
+ public static String getRevision() {
+ return annotation != null ? annotation.revision() : "Unknown";
+ }
+
+ /**
+ * The date that the code was compiled.
+ * @return the compilation date in unix date format
+ */
+ public static String getDate() {
+ return annotation != null ? annotation.date() : "Unknown";
+ }
+
+ /**
+ * The user that compiled the code.
+ * @return the username of the user
+ */
+ public static String getUser() {
+ return annotation != null ? annotation.user() : "Unknown";
+ }
+
+ /**
+ * Get the subversion URL for the root directory.
+ * @return the url
+ */
+ public static String getUrl() {
+ return annotation != null ? annotation.url() : "Unknown";
+ }
+
+}
diff --git a/common/src/main/java/org/apache/sqoop/json/JsonBean.java b/common/src/main/java/org/apache/sqoop/json/JsonBean.java
new file mode 100644
index 00000000..aa84935a
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/json/JsonBean.java
@@ -0,0 +1,39 @@
+/**
+ * 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.json;
+
+import org.json.simple.JSONObject;
+
+public interface JsonBean {
+
+ public JSONObject extract();
+
+ public void restore(JSONObject jsonObject);
+
+ public static final JsonBean EMPTY_BEAN = new JsonBean() {
+
+ @Override
+ public JSONObject extract() {
+ return new JSONObject();
+ }
+
+ @Override
+ public void restore(JSONObject jsonObject) {
+ }
+ };
+}
diff --git a/common/src/main/java/org/apache/sqoop/json/VersionBean.java b/common/src/main/java/org/apache/sqoop/json/VersionBean.java
new file mode 100644
index 00000000..03e8c0b8
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/json/VersionBean.java
@@ -0,0 +1,113 @@
+/**
+ * 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.json;
+
+import java.util.Arrays;
+
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+
+public class VersionBean implements JsonBean {
+
+ public static final String VERSION = "version";
+ public static final String REVISION = "revision";
+ public static final String DATE = "date";
+ public static final String USER = "user";
+ public static final String URL = "url";
+ public static final String PROTOCOLS = "protocols";
+
+ private String version;
+ private String revision;
+ private String date;
+ private String user;
+ private String url;
+ private String[] protocols;
+
+ // for "extract"
+ public VersionBean(String version, String revision, String date,
+ String user, String url, String[] protocols) {
+ this.version = version;
+ this.revision = revision;
+ this.date = date;
+ this.user = user;
+ this.url = url;
+ this.protocols = new String[protocols.length];
+ System.arraycopy(protocols, 0, this.protocols, 0, protocols.length);
+ }
+
+ // for "restore"
+ public VersionBean() {
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public JSONObject extract() {
+ JSONObject result = new JSONObject();
+ result.put(VERSION, version);
+ result.put(REVISION, revision);
+ result.put(DATE, date);
+ result.put(USER, user);
+ result.put(URL, url);
+ JSONArray protocolsArray = new JSONArray();
+ for (String protocol : protocols) {
+ protocolsArray.add(protocol);
+ }
+ result.put(PROTOCOLS, protocolsArray);
+ return result;
+ }
+
+ @Override
+ public void restore(JSONObject jsonObject) {
+ this.version = (String)jsonObject.get(VERSION);
+ this.revision = (String)jsonObject.get(REVISION);
+ this.date = (String)jsonObject.get(DATE);
+ this.user = (String)jsonObject.get(USER);
+ this.url = (String)jsonObject.get(URL);
+ JSONArray protocolsArray = (JSONArray) jsonObject.get(PROTOCOLS);
+ int size = protocolsArray.size();
+ this.protocols = new String[size];
+ for (int i = 0; i connectionForms;
+ private final List jobForms;
+
+ public MConnector(String uniqueName, String className,
+ List connectionForms, List jobForms) {
+ if (uniqueName == null || className == null) {
+ throw new NullPointerException();
+ }
+
+ this.uniqueName = uniqueName;
+ this.className = className;
+
+ this.connectionForms = new ArrayList(connectionForms.size());
+ this.connectionForms.addAll(connectionForms);
+
+ this.jobForms = new ArrayList(jobForms.size());
+ this.jobForms.addAll(jobForms);
+ }
+
+ public String getUniqueName() {
+ return uniqueName;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("connector-");
+ sb.append(uniqueName).append(":").append(getPersistenceId()).append(":");
+ sb.append(className).append("; conn-forms:").append(connectionForms);
+ sb.append("; job-forms:").append(jobForms);
+
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MConnector)) {
+ return false;
+ }
+
+ MConnector mc = (MConnector) other;
+ return (uniqueName.equals(mc.uniqueName)
+ && className.equals(mc.className))
+ && connectionForms.equals(mc.connectionForms)
+ && jobForms.equals(mc.jobForms);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 23;
+ result = 31 * result + uniqueName.hashCode();
+ result = 31 * result + className.hashCode();
+ for (MForm cmf : connectionForms) {
+ result = 31 * result + cmf.hashCode();
+ }
+ for (MForm jmf : jobForms) {
+ result = 31 * result + jmf.hashCode();
+ }
+
+ return result;
+ }
+
+ public List getConnectionForms() {
+ return connectionForms;
+ }
+
+ public List getJobForms() {
+ return jobForms;
+ }
+}
diff --git a/common/src/main/java/org/apache/sqoop/model/MForm.java b/common/src/main/java/org/apache/sqoop/model/MForm.java
new file mode 100644
index 00000000..515bf5e0
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MForm.java
@@ -0,0 +1,74 @@
+/**
+ * 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.model;
+
+import java.util.List;
+
+/**
+ * Represents a group of inputs that are processed together. This allows the
+ * input gathering process to be broken down into multiple steps that can be
+ * then paged through by the user interface.
+ */
+public final class MForm extends MNamedElement {
+
+ private final List> inputs;
+
+ public MForm(String name, List> inputs) {
+ super(name);
+
+ this.inputs = inputs;
+ }
+
+ public List> getInputs() {
+ return inputs;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("form-").append(getName());
+ sb.append(":").append(getPersistenceId()).append(":").append(inputs);
+
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MForm)) {
+ return false;
+ }
+
+ MForm mf = (MForm) other;
+ return getName().equals(mf.getName())
+ && inputs.equals(mf.inputs);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + getName().hashCode();
+ for (MInput> mi : inputs) {
+ result = 31 * result + mi.hashCode();
+ }
+
+ return result;
+ }
+}
diff --git a/common/src/main/java/org/apache/sqoop/model/MFormType.java b/common/src/main/java/org/apache/sqoop/model/MFormType.java
new file mode 100644
index 00000000..2f403df3
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MFormType.java
@@ -0,0 +1,34 @@
+/**
+ * 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.model;
+
+/**
+ * Represents the various form types supported by the system.
+ */
+public enum MFormType {
+
+ /** Unknown form type */
+ OTHER,
+
+ /** Connection form type */
+ CONNECTION,
+
+ /** Job form type */
+ JOB;
+
+}
diff --git a/common/src/main/java/org/apache/sqoop/model/MInput.java b/common/src/main/java/org/apache/sqoop/model/MInput.java
new file mode 100644
index 00000000..3171f8ca
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MInput.java
@@ -0,0 +1,102 @@
+/**
+ * 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.model;
+
+/**
+ * Represents a parameter input used by the connector for creating a connection
+ * or a job object.
+ * @param the value type associated with this parameter
+ */
+public abstract class MInput extends MNamedElement {
+ private T value;
+
+ protected MInput(String name) {
+ super(name);
+ }
+
+ /**
+ * @param value the value to be set for this parameter
+ */
+ public void setValue(T value) {
+ this.value = value;
+ }
+
+ /**
+ * @return any previously set value for this parameter
+ */
+ public T getValue() {
+ return value;
+ }
+
+ /**
+ * @return a URL-safe string representation of the value
+ */
+ public abstract String getUrlSafeValueString();
+
+ /**
+ * Overrides the associated value of this input by the value represented by
+ * the provided URL-safe value string.
+ * @param valueString the string representation of the value from which the
+ * value must be restored.
+ */
+ public abstract void restoreFromUrlSafeValueString(String valueString);
+
+ public abstract MInputType getType();
+
+ /**
+ * @return true if this type maintains more state than what is
+ * stored in the MInput base class.
+ */
+ protected abstract boolean hasExtraInfo();
+
+ /**
+ * @return the string representation of state stored in this type if
+ * applicable or an empty string.
+ */
+ protected abstract String getExtraInfoToString();
+
+ /**
+ * All input types must override the equals() method such that the
+ * test for equality is based on static metadata only. As a result any
+ * set value, error message and other dynamic value data is not considered
+ * as part of the equality comparison.
+ */
+ @Override
+ public abstract boolean equals(Object other);
+
+ /**
+ * All input types must override the hashCode() method such that
+ * the hash code computation is solely based on static metadata. As a result
+ * any set value, error message and other dynamic value data is not
+ * considered as part of the hash code computation.
+ */
+ @Override
+ public abstract int hashCode();
+
+ @Override
+ public final String toString() {
+ StringBuilder sb = new StringBuilder("input-").append(getName());
+ sb.append(":").append(getPersistenceId()).append(":");
+ sb.append(getType());
+ if (hasExtraInfo()) {
+ sb.append(":").append(getExtraInfoToString());
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/common/src/main/java/org/apache/sqoop/model/MInputType.java b/common/src/main/java/org/apache/sqoop/model/MInputType.java
new file mode 100644
index 00000000..7acdbca1
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MInputType.java
@@ -0,0 +1,33 @@
+/**
+ * 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.model;
+
+/**
+ * Represents the various input types supported by the system.
+ */
+public enum MInputType {
+
+ /** Unknown input type */
+ OTHER,
+
+ /** String input type */
+ STRING,
+
+ /** Map input type */
+ MAP;
+}
diff --git a/common/src/main/java/org/apache/sqoop/model/MMapInput.java b/common/src/main/java/org/apache/sqoop/model/MMapInput.java
new file mode 100644
index 00000000..528f6670
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MMapInput.java
@@ -0,0 +1,107 @@
+/**
+ * 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.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sqoop.utils.UrlSafeUtils;
+
+public final class MMapInput extends MInput
+ *
+ */
+public final class DerbySchemaQuery {
+
+ // DDL: Create schema
+ public static final String QUERY_CREATE_SCHEMA_SQOOP =
+ "CREATE SCHEMA " + SCHEMA_SQOOP;
+
+ // DDL: Create table SQ_CONNECTOR
+ public static final String QUERY_CREATE_TABLE_SQ_CONNECTOR =
+ "CREATE TABLE " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID
+ + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) "
+ + "PRIMARY KEY, " + COLUMN_SQC_NAME + " VARCHAR(64), " + COLUMN_SQC_CLASS
+ + " VARCHAR(255))";
+
+ // DDL: Create table SQ_FORM
+ public static final String QUERY_CREATE_TABLE_SQ_FORM =
+ "CREATE TABLE " + TABLE_SQ_FORM + " (" + COLUMN_SQF_ID
+ + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) "
+ + "PRIMARY KEY, " + COLUMN_SQF_CONNECTOR + " BIGINT, "
+ + COLUMN_SQF_NAME + " VARCHAR(64), " + COLUMN_SQF_TYPE + " VARCHAR(32), "
+ + COLUMN_SQF_INDEX + " SMALLINT, " + " FOREIGN KEY ("
+ + COLUMN_SQF_CONNECTOR+ ") REFERENCES " + TABLE_SQ_CONNECTOR + " ("
+ + COLUMN_SQC_ID + "))";
+
+
+ // DDL: Create table SQ_INPUT
+ public static final String QUERY_CREATE_TABLE_SQ_INPUT =
+ "CREATE TABLE " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_ID
+ + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) "
+ + "PRIMARY KEY, " + COLUMN_SQI_NAME + " VARCHAR(64), "
+ + COLUMN_SQI_FORM + " BIGINT, " + COLUMN_SQI_INDEX + " SMALLINT, "
+ + COLUMN_SQI_TYPE + " VARCHAR(32), " + COLUMN_SQI_STRMASK + " BOOLEAN, "
+ + COLUMN_SQI_STRLENGTH + " SMALLINT, FOREIGN KEY (" + COLUMN_SQI_FORM
+ + ") REFERENCES " + TABLE_SQ_FORM + " (" + COLUMN_SQF_ID + "))";
+
+ // DML: Fetch connector Given Name
+ public static final String STMT_FETCH_BASE_CONNECTOR =
+ "SELECT " + COLUMN_SQC_ID + ", " + COLUMN_SQC_NAME + ", "
+ + COLUMN_SQC_CLASS + " FROM " + TABLE_SQ_CONNECTOR + " WHERE "
+ + COLUMN_SQC_NAME + " = ?";
+
+
+ // DML: Fetch all forms for a given connector
+ public static final String STMT_FETCH_FORM =
+ "SELECT " + COLUMN_SQF_ID + ", " + COLUMN_SQF_CONNECTOR + ", "
+ + COLUMN_SQF_NAME + ", " + COLUMN_SQF_TYPE + ", " + COLUMN_SQF_INDEX
+ + " FROM " + TABLE_SQ_FORM + " WHERE " + COLUMN_SQF_CONNECTOR
+ + " = ? ORDER BY " + COLUMN_SQF_INDEX;
+
+ // DML: Fetch inputs for a given form
+ public static final String STMT_FETCH_INPUT =
+ "SELECT " + COLUMN_SQI_ID + ", " + COLUMN_SQI_NAME + ", "
+ + COLUMN_SQI_FORM + ", " + COLUMN_SQI_INDEX + ", " + COLUMN_SQI_TYPE
+ + ", " + COLUMN_SQI_STRMASK + ", " + COLUMN_SQI_STRLENGTH + " FROM "
+ + TABLE_SQ_INPUT + " WHERE " + COLUMN_SQI_FORM + " = ? ORDER BY "
+ + COLUMN_SQI_INDEX;
+
+ // DML: Insert connector base
+ public static final String STMT_INSERT_CONNECTOR_BASE =
+ "INSERT INTO " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_NAME
+ + ", " + COLUMN_SQC_CLASS + ") VALUES ( ?, ?)";
+
+ // DML: Insert form base
+ public static final String STMT_INSERT_FORM_BASE =
+ "INSERT INTO " + TABLE_SQ_FORM + " (" + COLUMN_SQF_CONNECTOR
+ + ", " + COLUMN_SQF_NAME + ", " + COLUMN_SQF_TYPE + ", "
+ + COLUMN_SQF_INDEX + ") VALUES ( ?, ?, ?, ?)";
+
+ // DML: Insert form input
+ public static final String STMT_INSERT_INPUT_BASE =
+ "INSERT INTO " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_NAME + ", "
+ + COLUMN_SQI_FORM + ", " + COLUMN_SQI_INDEX + ", " + COLUMN_SQI_TYPE
+ + ", " + COLUMN_SQI_STRMASK + ", " + COLUMN_SQI_STRLENGTH + ") "
+ + "VALUES (?, ?, ?, ?, ?, ?)";
+
+ private DerbySchemaQuery() {
+ // Disable explicit object creation
+ }
+}
diff --git a/server/pom.xml b/server/pom.xml
new file mode 100644
index 00000000..91c37c41
--- /dev/null
+++ b/server/pom.xml
@@ -0,0 +1,82 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache
+ sqoop
+ 2.0.0-SNAPSHOT
+
+
+ org.apache.sqoop
+ sqoop-server
+ Sqoop Server
+ war
+
+
+
+ org.apache.sqoop
+ sqoop-core
+ 2.0.0-SNAPSHOT
+
+
+
+ org.apache.sqoop
+ sqoop-common
+ 2.0.0-SNAPSHOT
+
+
+
+ org.apache.sqoop.repository
+ sqoop-repository-derby
+ 2.0.0-SNAPSHOT
+
+
+
+ org.apache.sqoop.connector
+ sqoop-connector-generic-jdbc
+ 2.0.0-SNAPSHOT
+
+
+
+ org.apache.sqoop.connector
+ sqoop-connector-mysql-jdbc
+ 2.0.0-SNAPSHOT
+
+
+
+ javax.servlet
+ servlet-api
+ provided
+
+
+
+ com.googlecode.json-simple
+ json-simple
+
+
+
+
+ sqoop
+
+
+
diff --git a/server/src/main/java/org/apache/sqoop/handler/VersionRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/VersionRequestHandler.java
new file mode 100644
index 00000000..75c36d81
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/handler/VersionRequestHandler.java
@@ -0,0 +1,53 @@
+/**
+ * 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.handler;
+
+import org.apache.log4j.Logger;
+import org.apache.sqoop.common.VersionInfo;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.json.JsonBean;
+import org.apache.sqoop.json.VersionBean;
+import org.apache.sqoop.server.RequestContext;
+import org.apache.sqoop.server.RequestHandler;
+
+public class VersionRequestHandler implements RequestHandler {
+
+ private static final Logger LOG =
+ Logger.getLogger(VersionRequestHandler.class);
+
+ /** The API version supported by this server */
+ public static final String PROTOCOL_V1 = "1";
+
+
+ private final VersionBean versionBean;
+
+ public VersionRequestHandler() {
+ String[] protocols = { PROTOCOL_V1 };
+ versionBean = new VersionBean(VersionInfo.getVersion(),
+ VersionInfo.getRevision(), VersionInfo.getDate(),
+ VersionInfo.getUser(), VersionInfo.getUrl(), protocols);
+
+ LOG.info("VersionRequestHandler initialized");
+ }
+
+
+ @Override
+ public JsonBean handleEvent(RequestContext ctx) throws SqoopException {
+ return versionBean;
+ }
+}
diff --git a/server/src/main/java/org/apache/sqoop/server/RequestContext.java b/server/src/main/java/org/apache/sqoop/server/RequestContext.java
new file mode 100644
index 00000000..b1ea853b
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/RequestContext.java
@@ -0,0 +1,44 @@
+/**
+ * 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;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class RequestContext {
+
+ private final HttpServletRequest request;
+ private final HttpServletResponse response;
+
+ public RequestContext(HttpServletRequest req, HttpServletResponse resp) {
+ request = req;
+ response = resp;
+ }
+
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+
+ public HttpServletResponse getResponse() {
+ return response;
+ }
+
+ public String getPath() {
+ return request.getRequestURL().toString();
+ }
+}
diff --git a/server/src/main/java/org/apache/sqoop/server/RequestHandler.java b/server/src/main/java/org/apache/sqoop/server/RequestHandler.java
new file mode 100644
index 00000000..43d98c51
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/RequestHandler.java
@@ -0,0 +1,27 @@
+/**
+ * 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;
+
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.json.JsonBean;
+
+public interface RequestHandler {
+
+ public JsonBean handleEvent(RequestContext ctx) throws SqoopException;
+}
diff --git a/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java b/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
new file mode 100644
index 00000000..6519f522
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
@@ -0,0 +1,55 @@
+/**
+ * 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;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.log4j.Logger;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.connector.ConnectorManager;
+import org.apache.sqoop.core.SqoopConfiguration;
+import org.apache.sqoop.repository.RepositoryManager;
+
+
+/**
+ * Initializes the Sqoop server. This listener is also responsible for
+ * cleaning up any resources occupied by the server during the system shutdown.
+ */
+public class ServerInitializer implements ServletContextListener {
+
+ private static final Logger LOG =
+ Logger.getLogger(ServerInitializer.class);
+
+ public void contextDestroyed(ServletContextEvent arg0) {
+ ConnectorManager.destroy();
+ RepositoryManager.destroy();
+ SqoopConfiguration.destroy();
+ }
+
+ public void contextInitialized(ServletContextEvent arg0) {
+ try {
+ SqoopConfiguration.initialize();
+ RepositoryManager.initialize();
+ ConnectorManager.initialize();
+ } catch (RuntimeException ex) {
+ LOG.error("Server startup failure", ex);
+ throw ex;
+ }
+ }
+}
diff --git a/server/src/main/java/org/apache/sqoop/server/SqoopProtocolServlet.java b/server/src/main/java/org/apache/sqoop/server/SqoopProtocolServlet.java
new file mode 100644
index 00000000..f36aa057
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/SqoopProtocolServlet.java
@@ -0,0 +1,143 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.sqoop.common.ErrorCode;
+import org.apache.sqoop.common.ExceptionInfo;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.common.SqoopProtocolConstants;
+import org.apache.sqoop.common.SqoopResponseCode;
+import org.apache.sqoop.core.CoreError;
+import org.apache.sqoop.json.JsonBean;
+
+@SuppressWarnings("serial")
+public class SqoopProtocolServlet extends HttpServlet {
+
+ private static final Logger LOG =
+ Logger.getLogger(SqoopProtocolServlet.class);
+
+ @Override
+ protected final void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ RequestContext rctx = new RequestContext(req, resp);
+
+ try {
+ JsonBean bean = handleGetRequest(rctx);
+ if (bean != null) {
+ sendSuccessResponse(rctx, bean);
+ }
+ } catch (Exception ex) {
+ LOG.error("Exception in GET " + rctx.getPath(), ex);
+ sendErrorResponse(rctx, ex);
+ }
+ }
+
+ @Override
+ protected final void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ RequestContext rctx = new RequestContext(req, resp);
+ try {
+ JsonBean bean = handlePostRequest(rctx);
+ if (bean != null) {
+ sendSuccessResponse(rctx, bean);
+ }
+ } catch (Exception ex) {
+ LOG.error("Exception in POST " + rctx.getPath(), ex);
+ sendErrorResponse(rctx, ex);
+ }
+ }
+
+ private void sendSuccessResponse(RequestContext ctx, JsonBean bean)
+ throws IOException {
+ HttpServletResponse response = ctx.getResponse();
+ response.setStatus(HttpServletResponse.SC_OK);
+ setContentType(response);
+ setHeaders(response, SqoopResponseCode.SQOOP_1000);
+ String responseString = bean.extract().toJSONString();
+ response.getWriter().write(responseString);
+ response.getWriter().flush();
+ }
+
+ private void sendErrorResponse(RequestContext ctx, Exception ex)
+ throws IOException
+ {
+ HttpServletResponse response = ctx.getResponse();
+ setContentType(response);
+ setHeaders(response, SqoopResponseCode.SQOOP_2000);
+
+ if (ex != null) {
+ ErrorCode ec = null;
+ if (ex instanceof SqoopException) {
+ ec = ((SqoopException) ex).getErrorCode();
+ } else {
+ ec = CoreError.CORE_0000;
+ }
+
+ response.setHeader(
+ SqoopProtocolConstants.HEADER_SQOOP_INTERNAL_ERROR_CODE,
+ ec.getCode());
+
+ response.setHeader(
+ SqoopProtocolConstants.HEADER_SQOOP_INTERNAL_ERROR_MESSAGE,
+ ex.getMessage());
+
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ new ExceptionInfo(ec.getCode(),
+ ex.getMessage(), ex).extract().toJSONString());
+ } else {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+
+ }
+
+ private void setContentType(HttpServletResponse response) {
+ response.setContentType(SqoopProtocolConstants.JSON_CONTENT_TYPE);
+ }
+
+ private void setHeaders(HttpServletResponse response, SqoopResponseCode code)
+ {
+ response.setHeader(SqoopProtocolConstants.HEADER_SQOOP_ERROR_CODE,
+ code.getCode());
+ response.setHeader(SqoopProtocolConstants.HEADER_SQOOP_ERROR_MESSAGE,
+ code.getMessage());
+
+
+ }
+
+ protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
+ super.doGet(ctx.getRequest(), ctx.getResponse());
+
+ return null;
+ }
+
+ protected JsonBean handlePostRequest(RequestContext ctx) throws Exception {
+ super.doPost(ctx.getRequest(), ctx.getResponse());
+
+ return null;
+ }
+}
diff --git a/server/src/main/java/org/apache/sqoop/server/VersionServlet.java b/server/src/main/java/org/apache/sqoop/server/VersionServlet.java
new file mode 100644
index 00000000..a62c9ce9
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/VersionServlet.java
@@ -0,0 +1,40 @@
+/**
+ * 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;
+
+import org.apache.sqoop.handler.VersionRequestHandler;
+import org.apache.sqoop.json.JsonBean;
+
+/**
+ * Exposes the supported versions available in the server.
+ *
+ */
+@SuppressWarnings("serial")
+public class VersionServlet extends SqoopProtocolServlet {
+
+ private RequestHandler versionRequestHandler;
+
+ public VersionServlet() {
+ versionRequestHandler = new VersionRequestHandler();
+ }
+
+ @Override
+ protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
+ return versionRequestHandler.handleEvent(ctx);
+ }
+}
diff --git a/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java b/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java
new file mode 100644
index 00000000..07a86ae2
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java
@@ -0,0 +1,36 @@
+/**
+ * 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.json.JsonBean;
+import org.apache.sqoop.server.RequestContext;
+import org.apache.sqoop.server.SqoopProtocolServlet;
+
+/**
+ * Displays the list of connectors that are available in the system via
+ * a GET request.
+ */
+@SuppressWarnings("serial")
+public class ConnectorServlet extends SqoopProtocolServlet {
+
+ @Override
+ protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
+ // TODO Auto-generated method stub
+ return super.handleGetRequest(ctx);
+ }
+}
diff --git a/server/src/main/webapp/WEB-INF/web.xml b/server/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000..17238700
--- /dev/null
+++ b/server/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+
+
+
+
+ Apache Sqoop
+
+
+
+ org.apache.sqoop.server.ServerInitializer
+
+
+
+ VersionServlet
+ org.apache.sqoop.server.VersionServlet
+ 1
+
+
+
+ VersionServlet
+ /version
+
+
+
+
diff --git a/server/src/main/webapp/index.html b/server/src/main/webapp/index.html
new file mode 100644
index 00000000..06513dd4
--- /dev/null
+++ b/server/src/main/webapp/index.html
@@ -0,0 +1,23 @@
+
+
+
+Apache Sqoop
+
+Apache Sqoop
+
+
diff --git a/spi/pom.xml b/spi/pom.xml
new file mode 100644
index 00000000..f71145aa
--- /dev/null
+++ b/spi/pom.xml
@@ -0,0 +1,41 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache
+ sqoop
+ 2.0.0-SNAPSHOT
+
+
+ org.apache.sqoop
+ sqoop-spi
+ Sqoop SPI
+
+
+
+ org.apache.sqoop
+ sqoop-common
+ 2.0.0-SNAPSHOT
+
+
+
diff --git a/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java b/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
new file mode 100644
index 00000000..43d7344a
--- /dev/null
+++ b/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
@@ -0,0 +1,49 @@
+/**
+ * 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.connector.spi;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.sqoop.model.MForm;
+
+/**
+ * Service provider interface for Sqoop Connectors.
+ */
+public interface SqoopConnector {
+
+ /**
+ * @param locale
+ * @return the resource bundle associated with the given locale.
+ */
+ public ResourceBundle getBundle(Locale locale);
+
+ /**
+ * @return a list of MForm that provide metadata about input needed
+ * by Sqoop to create a connection object using this connector.
+ */
+ public List getConnectionForms();
+
+
+ /**
+ * @return a list of MForm that provide metadata about input needed
+ * by Sqoop to create a job object using this connector.
+ */
+ public List getJobForms();
+}