This repository was archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
HTTP Interface #495
Open
lukroth
wants to merge
4
commits into
ervandew:master
Choose a base branch
from
lukroth:HTTPInterface
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
HTTP Interface #495
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1113,7 +1113,10 @@ junit = { pluginName -> | |
| compile("${pluginName}/test/junit", "build/test/junit/classes/${pluginName}"){ | ||
| ant.compilerarg(value: '-Xlint:-options') | ||
| ant.include(name: '**/*.java') | ||
| ant.classpath{ant.pathelement(path: '${build.classes}/org.eclim')} | ||
| ant.classpath{ | ||
| ant.pathelement(path: '${build.classes}/org.eclim') | ||
| ant.pathelement(path: '${build.classes}/org.eclim.jdt') | ||
| } | ||
| } | ||
|
|
||
| ant.path(id: 'junit'){ | ||
|
|
@@ -1130,6 +1133,7 @@ junit = { pluginName -> | |
| ant.path(refid: 'junit') | ||
| ant.pathelement(path: "build/test/junit/classes/${pluginName}") | ||
| ant.pathelement(path: '${build.classes}/org.eclim') | ||
| ant.pathelement(path: '${build.classes}/org.eclim.jdt') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, this shouldn't be hardcoded as jdt.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also done in the next commit. |
||
| ant.fileset(dir: 'org.eclim/lib', includes: '*.jar', excludes: 'ant-*.jar') | ||
| } | ||
| ant.formatter(type: 'xml') | ||
|
|
@@ -1141,6 +1145,8 @@ junit = { pluginName -> | |
| ant.sysproperty(key: 'eclipse.home', value: '${eclipse}') | ||
| ant.sysproperty(key: 'eclim.version', value: '${eclim.version}') | ||
| ant.sysproperty(key: 'eclimd.port', value: '${nailgun.server.port}') | ||
| ant.sysproperty(key: 'http.server.port', value: '${http.server.port}') | ||
| ant.sysproperty(key: 'http.server.host', value: '${http.server.host}') | ||
| } | ||
| } | ||
|
|
||
|
|
||
104 changes: 104 additions & 0 deletions
104
org.eclim.core/java/org/eclim/plugin/core/command/file/FileDeleteCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /** | ||
| * Copyright (C) 2005 - 2016 Eric Van Dewoestine | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package org.eclim.plugin.core.command.file; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| import org.eclim.Services; | ||
| import org.eclim.annotation.Command; | ||
| import org.eclim.command.CommandException; | ||
| import org.eclim.command.CommandException.ErrorType; | ||
| import org.eclim.command.CommandLine; | ||
| import org.eclim.command.Options; | ||
| import org.eclim.logging.Logger; | ||
| import org.eclim.plugin.core.command.AbstractCommand; | ||
| import org.eclim.plugin.core.util.PathUtil; | ||
| import org.eclim.plugin.core.util.PathUtilException; | ||
|
|
||
| @Command( | ||
| name = "file_delete", | ||
| options = | ||
| "REQUIRED f relativeFilePath ARG," + | ||
| "REQUIRED p project ARG" | ||
| ) | ||
|
|
||
| /** | ||
| * Command to delete a file. | ||
| * | ||
| * The <code>relativeFilePath</code> specifies the path relative to the | ||
| * <code>project</code> where the file/folder should be deleted. | ||
| * | ||
| * If the file is a directory, also all subdirectories will be deleted. | ||
| * | ||
| * Warning: you might have to update the <code>project</code> after calling this | ||
| * command. | ||
| * | ||
| * | ||
| * @author Lukas Roth | ||
| * | ||
| */ | ||
| public class FileDeleteCommand extends AbstractCommand | ||
| { | ||
| private static final Logger logger = Logger.getLogger(FileDeleteCommand.class); | ||
|
|
||
| @Override | ||
| public Object execute(CommandLine commandLine) | ||
| throws Exception | ||
| { | ||
| String relativeFilePath = commandLine.getValue(Options.FILE_OPTION); | ||
| String projectName = commandLine.getValue(Options.PROJECT_OPTION); | ||
| return fileDelete(relativeFilePath, projectName); | ||
| } | ||
|
|
||
| public Object fileDelete(String relativeFilePath, String projectName) | ||
| { | ||
| try { | ||
| PathUtil.checkPathForEscaping(relativeFilePath); | ||
| } catch (PathUtilException e) { | ||
| return new CommandException(e, ErrorType.CLIENT_ERROR); | ||
| } | ||
| String absoluteFilePath; | ||
| try { | ||
| absoluteFilePath = PathUtil.getAbsolutePath(projectName, relativeFilePath); | ||
| } catch (PathUtilException e) { | ||
| return new CommandException(e, ErrorType.CLIENT_ERROR); | ||
| } | ||
| return deleteFileOnFileSystem(absoluteFilePath, relativeFilePath); | ||
| } | ||
|
|
||
| private Object deleteFileOnFileSystem(String absoluteFilePath, String filePath) | ||
| { | ||
| File file = new File(absoluteFilePath); | ||
| if (!file.exists()) { | ||
| String message = Services.getMessage("file.delete.not.found", filePath); | ||
| logger.error(message); | ||
| return new CommandException(message, ErrorType.CLIENT_ERROR); | ||
| } | ||
| if (file.isDirectory()) { | ||
| org.eclim.util.file.FileUtils.deleteDirectory(file); | ||
| return Services.getMessage("file.delete.directory.deleted", filePath); | ||
| } else { | ||
| if (file.delete()) { | ||
| return Services.getMessage("file.delete.success", filePath); | ||
| } else { | ||
| String message = Services.getMessage("file.delete.error", filePath); | ||
| logger.error(Services.getMessage("file.delete.error", filePath)); | ||
| return new CommandException(message, ErrorType.SYSTEM_ERROR); | ||
| } | ||
| } | ||
| } | ||
| } |
142 changes: 142 additions & 0 deletions
142
org.eclim.core/java/org/eclim/plugin/core/command/file/FileListCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /** | ||
| * Copyright (C) 2005 - 2016 Eric Van Dewoestine | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package org.eclim.plugin.core.command.file; | ||
|
|
||
| import java.io.File; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
|
|
||
| import org.eclim.Services; | ||
| import org.eclim.annotation.Command; | ||
| import org.eclim.command.CommandException; | ||
| import org.eclim.command.CommandLine; | ||
| import org.eclim.command.Options; | ||
| import org.eclim.logging.Logger; | ||
| import org.eclim.plugin.core.command.AbstractCommand; | ||
| import org.eclim.plugin.core.util.PathUtil; | ||
| import org.eclim.plugin.core.util.PathUtilException; | ||
|
|
||
| @Command( | ||
| name = "file_list", | ||
| options = | ||
| "REQUIRED f relativeFilePath ARG," + | ||
| "REQUIRED p project ARG," + | ||
| "OPTIONAL r recursiveFlag ARG" | ||
| ) | ||
|
|
||
| /** | ||
| * Command to get a list of all files and folders in the folder | ||
| * {@code relativeFilePath} which is a relative path to the project | ||
| * {@code project}. | ||
| * | ||
| * Example response: | ||
| * | ||
| * myFolder/ | ||
| * mySecFolder/ | ||
| * myFile.txt | ||
| * | ||
| * | ||
| * If the {@code recursiveFlag} argument is set to true the command traverses | ||
| * all the folders inside the {@code relativeFilePath} recursively and returns | ||
| * all the folders inclusive all subfolders and subfiles. | ||
| * | ||
| * Example response with {@code recursiveFlag} set to true: | ||
| * | ||
| * myFolder/ | ||
| * myFolder/mySubFolder/ | ||
| * myFolder/mySubFolder/mySubFile.txt | ||
| * mySecFolder/ | ||
| * myFile.txt | ||
| * | ||
| * @author Lukas Roth | ||
| * | ||
| */ | ||
| public class FileListCommand extends AbstractCommand | ||
| { | ||
| private static final Logger logger = Logger.getLogger(FileListCommand.class); | ||
| private List<String> result; | ||
|
|
||
| @Override | ||
| public Object execute(CommandLine commandLine) | ||
| throws Exception | ||
| { | ||
| String relativeFilePath = commandLine.getValue(Options.FILE_OPTION); | ||
| String projectName = commandLine.getValue(Options.PROJECT_OPTION); | ||
| String recursiveFlag = commandLine.getValue(Options.RECURSIVE_OPTION); | ||
| boolean recursive = Boolean.parseBoolean(recursiveFlag); | ||
| try { | ||
| return fileList(projectName, relativeFilePath, recursive); | ||
| } catch (FileListCommandException e) { | ||
| return new CommandException(e, CommandException.ErrorType.CLIENT_ERROR); | ||
| } | ||
| } | ||
|
|
||
| public List<String> fileList(String projectName, String relativeFilePath, | ||
| boolean recursive) | ||
| throws FileListCommandException | ||
| { | ||
| validatePath(relativeFilePath); | ||
| File baseFile = getRootPath(projectName, relativeFilePath); | ||
| if (!baseFile.exists()) { | ||
| throw new FileListCommandException( | ||
| Services.getMessage("file.list.no.file", relativeFilePath, projectName)); | ||
| } | ||
| result = new LinkedList<String>(); | ||
| traverseChildNodes(baseFile, null, recursive); | ||
| return result; | ||
| } | ||
|
|
||
| private void validatePath(String path) | ||
| throws FileListCommandException | ||
| { | ||
| try { | ||
| PathUtil.checkPathForEscaping(path); | ||
| } catch (PathUtilException e) { | ||
| throw new FileListCommandException( | ||
| Services.getMessage("file.path.error.illegal.path", path), e); | ||
| } | ||
| } | ||
|
|
||
| private void traverseChildNodes(File baseFile, String path, boolean recursive) | ||
| { | ||
| File[] childNodes = baseFile.listFiles(); | ||
| for (File child : childNodes) { | ||
| String childPath = (path == null) ? child.getName() : | ||
| (path + "/" + child.getName()); | ||
| if (child.isFile()) { | ||
| result.add(childPath); | ||
| } else if (child.isDirectory()) { | ||
| result.add(childPath + "/"); | ||
| if (recursive) { | ||
| traverseChildNodes(child, childPath, recursive); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private File getRootPath(String projectName, String relativeFilePath) | ||
| throws FileListCommandException | ||
| { | ||
| try { | ||
| return new File(PathUtil.getAbsolutePath(projectName, relativeFilePath)); | ||
| } catch (PathUtilException e) { | ||
| throw new FileListCommandException( | ||
| Services.getMessage("file.list.absolute.path.error", projectName), e); | ||
| } | ||
| } | ||
|
|
||
| } |
15 changes: 15 additions & 0 deletions
15
org.eclim.core/java/org/eclim/plugin/core/command/file/FileListCommandException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.eclim.plugin.core.command.file; | ||
|
|
||
| public class FileListCommandException extends Exception | ||
| { | ||
|
|
||
| public FileListCommandException(String message, Exception exception) | ||
| { | ||
| super(message, exception); | ||
| } | ||
|
|
||
| public FileListCommandException(String message) | ||
| { | ||
| super(message); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to to use
${pluginName}rather than hardcoding in jdt, which not all users may be able to compile (they may only be interested in running/testing cdt for example).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, thanks for the comment!
See changes in the next commit.