Difference between revisions of "Home Library CLI"

From Gcube Wiki
Jump to: navigation, search
(Remove files or directories)
(Save a file)
 
(45 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
= Introduction =
 
= Introduction =
  
The Home Library CLI is a Java library providing command line interface to Home Library WebApp.
+
Home Library CLI is a Java library providing command line interface to Home Library WebApp.
  
 
This CLI library has following features:
 
This CLI library has following features:
* '''Create Folder''': to create a folder in the root or in a subfolder.
+
* '''Create Directory''': to create a directory in the root or in a subfolder.
* '''List Folder''': to list the content of a specific folder.
+
* '''List Directory''': to list the content of a directory.
* '''Upload a file''': to upload a file in given folder.
+
* '''Upload file''': to upload a file in a directory.
* '''Remove files and folders''': to remove a file or a folder (including subforders).
+
* '''Remove files and folders''': to remove a file or a directory (including subdirectories).
 
* '''Test''': a simple test to check the correct behavior of the features above.
 
* '''Test''': a simple test to check the correct behavior of the features above.
  
 
The following sections will discuss each of these commands in turn, and discuss how to use them with Home Library CLI.
 
The following sections will discuss each of these commands in turn, and discuss how to use them with Home Library CLI.
 +
 +
= Configuration File =
 +
 +
Home Library CLI is equipped with a simple configuration file to set the parameters and initial settings.
 +
 +
The fields are:
 +
* '''URL_REPOSITORY''': the URL of Home Library WebApp.
 +
* '''USERNAME''': username to connect to Home Library WebApp.
 +
* '''PASSWORD''': password to connect to Home Library WebApp.
 +
* '''LOGIN''': the portal login of the user who is using the library.
 +
* '''ROOT_PATH ''': the ROOT of the VRE folder where the files and directory will be created.
 +
 +
The Configuration File cannot be modified by the final user, but it allows to use the CLI in different context.
  
 
= Usage =
 
= Usage =
 
== Prerequisites ==
 
== Prerequisites ==
Home Library CLI is a jar-with-depencencies, you only need a Java 7 JDK. Download the latest release from the here or by clicking this link: xxx
+
Home Library CLI is a jar-with-depencencies, you only need a Java 7 JDK.  
 +
 
 +
Download the latest release from here:  
 +
 
 +
http://maven.research-infrastructures.eu:8081/nexus/content/repositories/gcube-snapshots/org/gcube/common/home-library-cli/.
  
 
== Start ==
 
== Start ==
Line 24: Line 41:
  
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar
+
java -jar home-library-cli-<$version>-jar-with-dependencies.jar
 
</source>
 
</source>
NOTE: Replace <$version> with the current version.
+
'''NOTE''': Replace '''<$version>''' with the last version available.
  
 
This starts the library and writes some help lines:
 
This starts the library and writes some help lines:
  
 
<source lang="bash">
 
<source lang="bash">
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar
  
Usage: java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar <command>
+
Usage: java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar <command>
 
Where <command> is:
 
Where <command> is:
 
mkdir
 
mkdir
Line 42: Line 59:
 
</source>
 
</source>
  
== Run the Test ==
+
== Run the test ==
To check the correct behavior of all the features:
+
To check the correct behavior of all features:
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar test
+
java -jar home-library-cli-<$version>-jar-with-dependencies.jar test
 
</source>
 
</source>
  
Example:
+
=== Example ===
 
<source lang="bash">
 
<source lang="bash">
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar test
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar test
  
 
param N.0: test
 
param N.0: test
Line 77: Line 94:
 
To create a directory, if it does not already exist.
 
To create a directory, if it does not already exist.
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar mkdir foldername [destinationFolder] [description]
+
java -jar home-library-cli-<$version>-jar-with-dependencies.jar mkdir name [path] [description]
 
</source>
 
</source>
  
 
Mandatory arguments:
 
Mandatory arguments:
* '''foldername''': the folder name to create.
+
* '''name''': the name of the new folder.
  
 
Optional arguments:
 
Optional arguments:
* '''destinationFolder''': the API interface.
+
* '''path''': the path where the directory will be created (by default the directory will be created in the '''ROOT_PATH''').
* '''description''': the API interface.
+
* '''description''': the description of the new folder.
  
 
+
=== Example ===
Output example:
+
 
<source lang="bash">
 
<source lang="bash">
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar mkdir myFolder
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar mkdir myFolder
  
 
param N.0: mkdir
 
param N.0: mkdir
Line 96: Line 112:
 
Create Folder myFolder
 
Create Folder myFolder
 
Response Code : 200
 
Response Code : 200
myFolder has been created.
+
myFolder created.
 
</source>
 
</source>
  
== Save a file ==
+
== Upload a file ==
 +
To upload a file, if it does not already exist.
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar put /home/user/Downloads/image.jpg myFolder
+
java -jar home-library-cli-<$version>-jar-with-dependencies.jar put fileURL [destinationPath] [name]
 
</source>
 
</source>
  
Output example:
+
Mandatory arguments:
 +
* '''fileURL''': the URL of the file to save.
 +
 
 +
Optional arguments:
 +
* '''destinationPath''': the path of an existing directory where the file will be uploaded (by default the file will be saved in the '''ROOT_PATH''').
 +
* '''name''': the description of the new folder (by default the original name will be preserved)
 +
 
 +
=== Example ===
 
<source lang="bash">
 
<source lang="bash">
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar put /home/user/Downloads/image.jpg myFolder
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar put /home/user/Downloads/image.jpg myFolder
  
 
param N.0: put
 
param N.0: put
 
param N.1: /home/user/Downloads/image.jpg
 
param N.1: /home/user/Downloads/image.jpg
 
param N.2: myFolder
 
param N.2: myFolder
/myFolder/image.jpg has been saved.
+
/myFolder/image.jpg saved.
 
</source>
 
</source>
  
== List a Folder ==
+
== List a directory ==
 +
To list the content of a directory.
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar ls myFolder
+
java -jar home-library-cli-<$version>-jar-with-dependencies.jar ls [directory]
 
</source>
 
</source>
  
Output example:
+
Optional arguments:
 +
* '''directory''': the absolute path of the directory to list (by default the content of the '''ROOT_PATH''' will be shown).
 +
 
 +
=== Example ===
 
<source lang="bash">
 
<source lang="bash">
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar ls myFolder
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar ls myFolder
  
 
param N.0: ls
 
param N.0: ls
Line 133: Line 161:
 
To remove files or directories:
 
To remove files or directories:
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar rm name
+
java -jar home-library-cli-<$version>-jar-with-dependencies.jar rm fileOrDirectory
 
</source>
 
</source>
=== Remove a file ===
 
  
<source lang="bash">
+
Mandatory arguments:
java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar rm myFolder/image.jpg
+
* '''fileOrDirectory''': the absolute path of the directory or file to remove.
</source>
+
 
 +
=== Example ===
  
Example:
+
Remove a file:
 
<source lang="bash">
 
<source lang="bash">
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar rm myFolder/image.jpg
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar rm myFolder/image.jpg
  
 
param N.0: rm
 
param N.0: rm
Line 151: Line 179:
 
</source>
 
</source>
  
=== Remove a directory ===
+
Remove a directory:
 
<source lang="bash">
 
<source lang="bash">
java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar rm myFolder
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar rm myFolder
</source>
+
 
+
Example:
+
<source lang="bash">
+
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar rm myFolder
+
  
 
param N.0: rm
 
param N.0: rm
Line 165: Line 188:
 
myFolder deleted.
 
myFolder deleted.
 
</source>
 
</source>
 
= Release =
 

Latest revision as of 17:58, 31 March 2016

Introduction

Home Library CLI is a Java library providing command line interface to Home Library WebApp.

This CLI library has following features:

  • Create Directory: to create a directory in the root or in a subfolder.
  • List Directory: to list the content of a directory.
  • Upload file: to upload a file in a directory.
  • Remove files and folders: to remove a file or a directory (including subdirectories).
  • Test: a simple test to check the correct behavior of the features above.

The following sections will discuss each of these commands in turn, and discuss how to use them with Home Library CLI.

Configuration File

Home Library CLI is equipped with a simple configuration file to set the parameters and initial settings.

The fields are:

  • URL_REPOSITORY: the URL of Home Library WebApp.
  • USERNAME: username to connect to Home Library WebApp.
  • PASSWORD: password to connect to Home Library WebApp.
  • LOGIN: the portal login of the user who is using the library.
  • ROOT_PATH : the ROOT of the VRE folder where the files and directory will be created.

The Configuration File cannot be modified by the final user, but it allows to use the CLI in different context.

Usage

Prerequisites

Home Library CLI is a jar-with-depencencies, you only need a Java 7 JDK.

Download the latest release from here:

http://maven.research-infrastructures.eu:8081/nexus/content/repositories/gcube-snapshots/org/gcube/common/home-library-cli/.

Start

After downloading the Home Library CLI jar just start it as follows:

java -jar home-library-cli-<$version>-jar-with-dependencies.jar

NOTE: Replace <$version> with the last version available.

This starts the library and writes some help lines:

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar
 
Usage: java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar <command>
Where <command> is:
	mkdir
	ls
	rm
	put
	test

Run the test

To check the correct behavior of all features:

java -jar home-library-cli-<$version>-jar-with-dependencies.jar test

Example

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar test
 
param N.0: test
List Folder /
Response Code : 200
0 elements found 
 
Create Folder myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2
Response Code : 200
myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2 created in / 
 
Save images in myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2
 
List Folder /
Response Code : 200
0 elements found 
 
Response Code : 200
myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2 deleted.
 
HL CLI test successfully completed.

Create a directory

To create a directory, if it does not already exist.

java -jar home-library-cli-<$version>-jar-with-dependencies.jar mkdir name [path] [description]

Mandatory arguments:

  • name: the name of the new folder.

Optional arguments:

  • path: the path where the directory will be created (by default the directory will be created in the ROOT_PATH).
  • description: the description of the new folder.

Example

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar mkdir myFolder
 
param N.0: mkdir
param N.1: myFolder
Create Folder myFolder
Response Code : 200
myFolder created.

Upload a file

To upload a file, if it does not already exist.

java -jar home-library-cli-<$version>-jar-with-dependencies.jar put fileURL [destinationPath] [name]

Mandatory arguments:

  • fileURL: the URL of the file to save.

Optional arguments:

  • destinationPath: the path of an existing directory where the file will be uploaded (by default the file will be saved in the ROOT_PATH).
  • name: the description of the new folder (by default the original name will be preserved)

Example

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar put /home/user/Downloads/image.jpg myFolder
 
param N.0: put
param N.1: /home/user/Downloads/image.jpg
param N.2: myFolder
/myFolder/image.jpg saved.

List a directory

To list the content of a directory.

java -jar home-library-cli-<$version>-jar-with-dependencies.jar ls [directory]

Optional arguments:

  • directory: the absolute path of the directory to list (by default the content of the ROOT_PATH will be shown).

Example

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar ls myFolder
 
param N.0: ls
param N.1: myFolder
Response Code : 200
1 items found.
myFolder/image.jpg

Remove files or directories

To remove files or directories:

java -jar home-library-cli-<$version>-jar-with-dependencies.jar rm fileOrDirectory

Mandatory arguments:

  • fileOrDirectory: the absolute path of the directory or file to remove.

Example

Remove a file:

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar rm myFolder/image.jpg
 
param N.0: rm
param N.1: myFolder/image.jpg
Response Code : 200
/myFolder/image.jpg deleted.

Remove a directory:

user@my-pc:~$ java -jar home-library-cli-1.0.0-20160324.155028-1-jar-with-dependencies.jar rm myFolder
 
param N.0: rm
param N.1: myFolder
Response Code : 200
myFolder deleted.