{"action":"created","comment":{"url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/comments/73422124","id":73422124,"diff_hunk":"@@ -0,0 +1,118 @@\n+/*\n+ * Copyright © 2016 Cask Data, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+package co.cask.hydrator.plugin.batch.action;\n+\n+import co.cask.cdap.api.annotation.Description;\n+import co.cask.cdap.api.annotation.Name;\n+import co.cask.cdap.api.annotation.Plugin;\n+import co.cask.cdap.api.plugin.PluginConfig;\n+import co.cask.cdap.etl.api.PipelineConfigurer;\n+import co.cask.cdap.etl.api.action.Action;\n+import co.cask.cdap.etl.api.action.ActionContext;\n+import org.apache.commons.io.filefilter.WildcardFileFilter;\n+import org.apache.hadoop.conf.Configuration;\n+import org.apache.hadoop.fs.FileSystem;\n+import org.apache.hadoop.fs.Path;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.io.File;\n+import java.io.FileFilter;\n+import java.io.IOException;\n+import javax.annotation.Nullable;\n+\n+/**\n+ * Move file(s) within HDFS.\n+ * A user must specify file/directory path and destination file/directory path\n+ * Optionals include fileRegex\n+ */\n+@Plugin(type = Action.PLUGIN_TYPE)\n+@Name(\"HDFSAction\")\n+@Description(\"Action to move files within HDFS\")\n+public class HDFSAction extends Action {\n+  private static final Logger LOG = LoggerFactory.getLogger(HDFSAction.class);\n+\n+  private HDFSActionConfig config;\n+\n+  public HDFSAction(HDFSActionConfig config) {\n+    this.config = config;\n+  }\n+\n+  @Override\n+  public void run(ActionContext context) throws Exception {\n+    FileSystem hdfs = new Path(config.sourcePath).getFileSystem(new Configuration());\n+\n+    if (new File(config.sourcePath).isFile()) {//moving single file\n+      Path source = new Path(config.sourcePath);\n+      Path dest = new Path(config.destPath);\n+      try {\n+        hdfs.rename(source, dest);\n+      } catch (IOException e) {\n+        LOG.error(\"Failed to move file {} to {} for reason: {}\", source.toString(), dest.toString(), e);\n+      }\n+      return;\n+    }\n+\n+    //moving contents of directory\n+    File folder = new File(config.sourcePath);","path":"core-plugins/src/main/java/co/cask/hydrator/plugin/batch/action/HDFSAction.java","position":71,"original_position":71,"commit_id":"dcad919059ef759df974f7af4bb0f5a57185dd34","original_commit_id":"dcad919059ef759df974f7af4bb0f5a57185dd34","user":{"login":"chtyim","id":885032,"avatar_url":"https://avatars.githubusercontent.com/u/885032?v=3","gravatar_id":"","url":"https://api.github.com/users/chtyim","html_url":"https://github.com/chtyim","followers_url":"https://api.github.com/users/chtyim/followers","following_url":"https://api.github.com/users/chtyim/following{/other_user}","gists_url":"https://api.github.com/users/chtyim/gists{/gist_id}","starred_url":"https://api.github.com/users/chtyim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chtyim/subscriptions","organizations_url":"https://api.github.com/users/chtyim/orgs","repos_url":"https://api.github.com/users/chtyim/repos","events_url":"https://api.github.com/users/chtyim/events{/privacy}","received_events_url":"https://api.github.com/users/chtyim/received_events","type":"User","site_admin":false},"body":"Again, shouldn't use `File`.","created_at":"2016-08-03T21:13:19Z","updated_at":"2016-08-03T21:13:19Z","html_url":"https://github.com/caskdata/hydrator-plugins/pull/357#discussion_r73422124","pull_request_url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357","_links":{"self":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/comments/73422124"},"html":{"href":"https://github.com/caskdata/hydrator-plugins/pull/357#discussion_r73422124"},"pull_request":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357"}}},"pull_request":{"url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357","id":79965371,"html_url":"https://github.com/caskdata/hydrator-plugins/pull/357","diff_url":"https://github.com/caskdata/hydrator-plugins/pull/357.diff","patch_url":"https://github.com/caskdata/hydrator-plugins/pull/357.patch","issue_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/357","number":357,"state":"open","locked":false,"title":"HDFS Action Plugin","user":{"login":"thegreenfrog","id":5599901,"avatar_url":"https://avatars.githubusercontent.com/u/5599901?v=3","gravatar_id":"","url":"https://api.github.com/users/thegreenfrog","html_url":"https://github.com/thegreenfrog","followers_url":"https://api.github.com/users/thegreenfrog/followers","following_url":"https://api.github.com/users/thegreenfrog/following{/other_user}","gists_url":"https://api.github.com/users/thegreenfrog/gists{/gist_id}","starred_url":"https://api.github.com/users/thegreenfrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thegreenfrog/subscriptions","organizations_url":"https://api.github.com/users/thegreenfrog/orgs","repos_url":"https://api.github.com/users/thegreenfrog/repos","events_url":"https://api.github.com/users/thegreenfrog/events{/privacy}","received_events_url":"https://api.github.com/users/thegreenfrog/received_events","type":"User","site_admin":false},"body":"Implements Plugin that allows to moving files in HDFS.\r\n\r\nTesting ongoing.","created_at":"2016-08-03T19:36:45Z","updated_at":"2016-08-03T21:13:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4b3f1192776c2bcb60e30c1799b3f18c6cea27e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357/commits","review_comments_url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357/comments","review_comment_url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/357/comments","statuses_url":"https://api.github.com/repos/caskdata/hydrator-plugins/statuses/dcad919059ef759df974f7af4bb0f5a57185dd34","head":{"label":"caskdata:hdfs-move-action","ref":"hdfs-move-action","sha":"dcad919059ef759df974f7af4bb0f5a57185dd34","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":39922362,"name":"hydrator-plugins","full_name":"caskdata/hydrator-plugins","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/hydrator-plugins","description":"Cask Hydrator Plugins Repository","fork":false,"url":"https://api.github.com/repos/caskdata/hydrator-plugins","forks_url":"https://api.github.com/repos/caskdata/hydrator-plugins/forks","keys_url":"https://api.github.com/repos/caskdata/hydrator-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/hydrator-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/hydrator-plugins/teams","hooks_url":"https://api.github.com/repos/caskdata/hydrator-plugins/hooks","issue_events_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/hydrator-plugins/events","assignees_url":"https://api.github.com/repos/caskdata/hydrator-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/hydrator-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/hydrator-plugins/tags","blobs_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/hydrator-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/hydrator-plugins/languages","stargazers_url":"https://api.github.com/repos/caskdata/hydrator-plugins/stargazers","contributors_url":"https://api.github.com/repos/caskdata/hydrator-plugins/contributors","subscribers_url":"https://api.github.com/repos/caskdata/hydrator-plugins/subscribers","subscription_url":"https://api.github.com/repos/caskdata/hydrator-plugins/subscription","commits_url":"https://api.github.com/repos/caskdata/hydrator-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/hydrator-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/hydrator-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/hydrator-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/hydrator-plugins/merges","archive_url":"https://api.github.com/repos/caskdata/hydrator-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/hydrator-plugins/downloads","issues_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/hydrator-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/hydrator-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/hydrator-plugins/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/hydrator-plugins/releases{/id}","deployments_url":"https://api.github.com/repos/caskdata/hydrator-plugins/deployments","created_at":"2015-07-30T00:14:48Z","updated_at":"2016-07-29T12:20:02Z","pushed_at":"2016-08-03T20:56:56Z","git_url":"git://github.com/caskdata/hydrator-plugins.git","ssh_url":"git@github.com:caskdata/hydrator-plugins.git","clone_url":"https://github.com/caskdata/hydrator-plugins.git","svn_url":"https://github.com/caskdata/hydrator-plugins","homepage":"","size":3383,"stargazers_count":20,"watchers_count":20,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":10,"forks":15,"open_issues":10,"watchers":20,"default_branch":"release/1.4"}},"base":{"label":"caskdata:release/1.4","ref":"release/1.4","sha":"f27046e332b941d0549d5d02f7a1747d858c13b7","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":39922362,"name":"hydrator-plugins","full_name":"caskdata/hydrator-plugins","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/hydrator-plugins","description":"Cask Hydrator Plugins Repository","fork":false,"url":"https://api.github.com/repos/caskdata/hydrator-plugins","forks_url":"https://api.github.com/repos/caskdata/hydrator-plugins/forks","keys_url":"https://api.github.com/repos/caskdata/hydrator-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/hydrator-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/hydrator-plugins/teams","hooks_url":"https://api.github.com/repos/caskdata/hydrator-plugins/hooks","issue_events_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/hydrator-plugins/events","assignees_url":"https://api.github.com/repos/caskdata/hydrator-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/hydrator-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/hydrator-plugins/tags","blobs_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/hydrator-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/hydrator-plugins/languages","stargazers_url":"https://api.github.com/repos/caskdata/hydrator-plugins/stargazers","contributors_url":"https://api.github.com/repos/caskdata/hydrator-plugins/contributors","subscribers_url":"https://api.github.com/repos/caskdata/hydrator-plugins/subscribers","subscription_url":"https://api.github.com/repos/caskdata/hydrator-plugins/subscription","commits_url":"https://api.github.com/repos/caskdata/hydrator-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/hydrator-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/hydrator-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/hydrator-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/hydrator-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/hydrator-plugins/merges","archive_url":"https://api.github.com/repos/caskdata/hydrator-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/hydrator-plugins/downloads","issues_url":"https://api.github.com/repos/caskdata/hydrator-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/hydrator-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/hydrator-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/hydrator-plugins/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/hydrator-plugins/releases{/id}","deployments_url":"https://api.github.com/repos/caskdata/hydrator-plugins/deployments","created_at":"2015-07-30T00:14:48Z","updated_at":"2016-07-29T12:20:02Z","pushed_at":"2016-08-03T20:56:56Z","git_url":"git://github.com/caskdata/hydrator-plugins.git","ssh_url":"git@github.com:caskdata/hydrator-plugins.git","clone_url":"https://github.com/caskdata/hydrator-plugins.git","svn_url":"https://github.com/caskdata/hydrator-plugins","homepage":"","size":3383,"stargazers_count":20,"watchers_count":20,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":10,"forks":15,"open_issues":10,"watchers":20,"default_branch":"release/1.4"}},"_links":{"self":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357"},"html":{"href":"https://github.com/caskdata/hydrator-plugins/pull/357"},"issue":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/357"},"comments":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/issues/357/comments"},"review_comments":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357/comments"},"review_comment":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/pulls/357/commits"},"statuses":{"href":"https://api.github.com/repos/caskdata/hydrator-plugins/statuses/dcad919059ef759df974f7af4bb0f5a57185dd34"}}}}
{"actor":{"display_login":"chtyim"}}