Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #4

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IDRSolutions Java Client

Copyright 2021 - 2023 IDRsolutions
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ Got questions? You can contact us [here](https://idrsolutions.atlassian.net/serv

-----

Copyright 2021 IDRsolutions

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
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.idrsolutions</groupId>
<artifactId>idrsolutions-java-client</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<version>2.0.0</version>
<name>IDRsolutions Java Client</name>
<dependencies>
<dependency>
Expand All @@ -29,4 +29,4 @@
</build>


</project>
</project>
16 changes: 16 additions & 0 deletions src/main/java/idrsolutions/ClientException.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
*
* 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.
*
**/
package idrsolutions;

public class ClientException extends Exception {
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/idrsolutions/ExampleUsage.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
*
* 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.
*
**/
package idrsolutions;


Expand Down Expand Up @@ -37,6 +53,7 @@ public static void main(final String[] args) {
IDRCloudClient.downloadResults(results, "path/to/outputDir", "example");
} catch (final ClientException | InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
}
50 changes: 26 additions & 24 deletions src/main/java/idrsolutions/IDRCloudClient.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
*
* 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.
*
* Used to interact with IDRsolutions' Microservice examples
* For detailed usage instructions, see the GitHub repository:
* https://github.com/idrsolutions/idrsolutions-java-client
*
**/
package idrsolutions;

import com.google.gson.Gson;
Expand All @@ -14,24 +34,6 @@
import java.util.Iterator;
import java.util.Map;

/**
* Copyright 2021 IDRsolutions
* 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.
* Main class used to interact with IDRsolutions' Microservice examples
* For detailed usage instructions, see the GitHub repository:
* https://github.com/idrsolutions/idrsolutions-java-client
*
* Used to interact with IDRsolutions' Microservice examples
*
**/
public class IDRCloudClient {
public static final String DOWNLOAD = "download";
public static final String UPLOAD = "upload";
Expand All @@ -46,20 +48,20 @@ public class IDRCloudClient {
/**
* Constructor, setup the converter details
*
* @param url
* @param url The URL of Microservice to connect to.
*/
public IDRCloudClient(final String url) {
endPoint = url;
requestTimeout = 60000;
conversionTimeout = 30;
conversionTimeout = -1;
}

/**
* Constructor with timeout, setup the converter details
*
* @param url
* @param requestTimeout
* @param conversionTimeout
* @param url The URL of Microservice to connect to.
* @param requestTimeout The time to wait (in milliseconds) before timing out each request. Set to 60000ms (60s) by default.
* @param conversionTimeout The time to wait (in seconds) before timing out the conversion. If value <= 0 then the conversion does not time out. Set to -1 by default.
*/
public IDRCloudClient(final String url, final int requestTimeout, final int conversionTimeout) {
endPoint = url;
Expand Down Expand Up @@ -107,7 +109,7 @@ public Map<String, String> convert(final Map<String, String> parameters) throws
break;
}

if (i >= conversionTimeout) {
if (conversionTimeout > 0 && i >= conversionTimeout) {
throw new ClientException("Failed: File took longer than " + conversionTimeout + " seconds to convert.");
}

Expand Down