Remove Gradle from source repo. Update docs & build to reflect change.
[arvados.git] / doc / sdk / java-v2 / index.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Java SDK v2
5 title: "Installation"
6 ...
7 {% comment %}
8 Copyright (C) The Arvados Authors. All rights reserved.
9
10 SPDX-License-Identifier: CC-BY-SA-3.0
11 {% endcomment %}
12
13 The Arvados Java SDK v2 provides a high level API for working with Arvados resources. It is packaged as a single JAR named
14 arvados-java-<version>.jar, e.g. arvados-java-2.0.0.jar
15 which can be included in your project using Gradle, Maven, or by hand.
16
17 h2. Using the SDK
18
19 FIXME - Add intro text here
20
21 h3. Logging
22
23 The SDK uses the SLF4J facade library for logging. A concrete logging "binding":https://www.slf4j.org/manual.html#swapping (and configuration, if required) must be provided by a client. For small applications, you can use the Simple implementation by adding slf4j-simple-1.8.0-beta4.jar to your classpath.
24
25 h3. Configuration
26
27 "TypeSafe Configuration":https://github.com/lightbend/config is used for configuring this library.
28
29 Please review src/main/resources/reference.conf for default values provided with this library.
30
31 * **keepweb-host** - host of your Keep-Web server (default: localhost)
32 * **keepweb-port** - port of your Keep-Web server (default: 8000)
33 * **host** - host of your Arvados API server
34 * **port** - port of your Arvados API server
35 * **token** - Arvados token to authenticate registered user, one must provide "token obtained from Arvados Workbench":https://doc.arvados.org/user/reference/api-tokens.html
36 * **protocol** - don't change to unless really needed (default: https)
37 * **host-insecure** - ignores SSL certificate verification if true (default: false Don't change to *true* unless really needed)
38 * **split-size** - size of chunk files in megabytes (default: 64)
39 * **temp-dir** - temporary chunk files storage
40 * **copies** - amount of chunk files duplicates per Keep server
41 * **retries** - UNIMPLEMENTED
42
43 In order to override default settings one can create an application.conf file in an application.  Example: src/test/resources/application.conf.
44
45 Alternatively @ExternalConfigProvider@ class can be used to pass configuration via code.  @ExternalConfigProvider@ comes with a builder and all of the above values must be provided in order for it to work properly.
46
47 @ArvadosFacade@ has two constructors, one without arguments that uses values from application.conf and second one taking @ExternalConfigProvider@ as an argument.
48
49 h3. API clients
50
51 All API clients inherit from @BaseStandardApiClient@. This class contains implementation of all common methods as described in "Arvados Common Resource Methods":http://doc.arvados.org/api/methods.html.
52
53 Parameters provided to common or specific methods are String UUID or fields wrapped in Java objects. For example:
54
55 {% codeblock as java %}
56 String uuid = "ardev-4zz18-rxcql7qwyakg1r1";
57
58 Collection actual = client.get(uuid);
59 {% endcodeblock %}
60
61 {% codeblock as java %}
62 ListArgument listArgument = ListArgument.builder()
63         .filters(Arrays.asList(
64                 Filter.of("owner_uuid", Operator.LIKE, "ardev%"),
65                 Filter.of("name", Operator.LIKE, "Super%"),
66                 Filter.of("portable_data_hash", Operator.IN, Lists.newArrayList("54f6d9f59065d3c009d4306660989379+65")
67             )))
68         .build();
69
70 CollectionList actual = client.list(listArgument);
71 {% endcodeblock %}
72
73 Non-standard API clients must inherit from BaseApiClient. For example: KeepServerApiClient communicates directly with Keep servers using exclusively non-common methods.
74
75 h3. Business logic
76
77 More advanced API data handling could be implemented as *Facade* classes. In current version functionalities provided by SDK are handled by @ArvadosFacade@. They include:
78
79 * **downloading single file from collection** - using Keep-Web
80 * **downloading whole collection** - using Keep-Web or Keep Server API
81 * **listing file info from certain collection** - information is returned as list of *FileTokens* providing file details
82 * **uploading single file** - to either new or existing collection
83 * **uploading list of files** - to either new or existing collection
84 * **creating an empty collection**
85 * **getting current user info**
86 * **listing current user's collections**
87 * **creating new project**
88 * **deleting certain collection**
89
90 h3. Note regarding Keep-Web
91
92 The Java SDK requires Keep Web (which is part of the standard configuration) as well as the API server and Keep server(s).
93
94 h3. Integration tests
95
96 In order to run the integration tests, all fields within following configuration file must be provided: @src/test/resources/integration-test-appliation.conf@
97
98
99 The parameter @integration-tests.project-uuid@ should contain UUID of one project available to user who's token was provided within configuration file.
100
101 Integration tests require connection to a real Arvados server.
102
103 h3. Note regarding file naming
104
105 When uploading via the current implementation of the Java SDK all uploaded files within single collection must have different names. This applies also to uploading files to already existing collection. Renaming files with duplicate names is not currently implemented.
106
107 h3. Javadoc
108
109 See "Javadoc":javadoc.html
110
111 h2. Building the Arvados SDK
112
113 Dependencies:
114 * JDK for Java 8 or later https://www.oracle.com/technetwork/java/javase/downloads/index.html
115 * Gradle https://gradle.org/install/
116
117
118 <notextile>
119 <pre>
120 $ <code class="userinput">git clone https://github.com/curoverse/arvados.git</code>
121 $ <code class="userinput">cd arvados/sdk/java-v2</code>
122 $ <code class="userinput">gradle test</code>
123 $ <code class="userinput">gradle jar</code>
124 </pre>
125 This will build the SDK and run all unit tests, then generate an Arvados Java sdk jar file in build/libs/arvados-java-2.0.0.jar
126 </notextile>
127