mirror of
https://github.com/Rogiel/httpchannel
synced 2025-12-05 23:22:51 +00:00
Adds -SNAPSHOT to Maven version parameter and few modifications to API
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>httpchannel</artifactId>
|
||||
<groupId>com.rogiel.httpchannel</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>httpchannel-channelcopy</artifactId>
|
||||
@@ -14,18 +14,19 @@
|
||||
<dependency>
|
||||
<groupId>com.rogiel.httpchannel</groupId>
|
||||
<artifactId>httpchannel-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rogiel.httpchannel.services</groupId>
|
||||
<artifactId>httpchannel-service-megaupload</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rogiel.httpchannel.services</groupId>
|
||||
<artifactId>httpchannel-service-multiupload</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.rogiel.httpchannel.copy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
@@ -41,7 +41,7 @@ import com.rogiel.httpchannel.service.helper.Services;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ChannelCopy implements Callable<List<URL>> {
|
||||
public class ChannelCopy implements Callable<List<URI>> {
|
||||
/**
|
||||
* The input channel
|
||||
*/
|
||||
@@ -101,12 +101,12 @@ public class ChannelCopy implements Callable<List<URL>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes with an {@link URL}. First tries to open an
|
||||
* Initializes with an {@link URI}. First tries to open an
|
||||
* {@link DownloadChannel}, if no service is found,
|
||||
* {@link NoServiceFoundException} is thrown.
|
||||
*
|
||||
* @param url
|
||||
* the source {@link URL}
|
||||
* @param uri
|
||||
* the source {@link URI}
|
||||
* @throws DownloadLinkNotFoundException
|
||||
* if the download link could not be found
|
||||
* @throws DownloadLimitExceededException
|
||||
@@ -114,17 +114,17 @@ public class ChannelCopy implements Callable<List<URL>> {
|
||||
* @throws DownloadNotAuthorizedException
|
||||
* if the download was not authorized by the service
|
||||
* @throws NoServiceFoundException
|
||||
* if no service could be found for the {@link URL}
|
||||
* if no service could be found for the {@link URI}
|
||||
* @throws IOException
|
||||
* if any IO error occur
|
||||
*/
|
||||
public ChannelCopy(URL url) throws DownloadLinkNotFoundException,
|
||||
public ChannelCopy(URI uri) throws DownloadLinkNotFoundException,
|
||||
DownloadLimitExceededException, DownloadNotAuthorizedException,
|
||||
IOException {
|
||||
final DownloadService<?> service = Services.matchURL(url);
|
||||
final DownloadService<?> service = Services.matchURI(uri);
|
||||
if (service == null)
|
||||
throw new NoServiceFoundException(url.toString());
|
||||
final DownloadChannel downloadChannel = service.getDownloader(url)
|
||||
throw new NoServiceFoundException(uri.toString());
|
||||
final DownloadChannel downloadChannel = service.getDownloader(uri)
|
||||
.openChannel();
|
||||
|
||||
this.downloadChannel = downloadChannel;
|
||||
@@ -173,7 +173,7 @@ public class ChannelCopy implements Callable<List<URL>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> call() throws IOException {
|
||||
public List<URI> call() throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(16 * 1024);
|
||||
try {
|
||||
while (downloadChannel.read(buffer) >= 0) {
|
||||
@@ -196,11 +196,11 @@ public class ChannelCopy implements Callable<List<URL>> {
|
||||
}
|
||||
}
|
||||
|
||||
final List<URL> urls = new ArrayList<>();
|
||||
final List<URI> uris = new ArrayList<>();
|
||||
for (final UploadChannel channel : uploadChannels) {
|
||||
urls.add(channel.getDownloadLink());
|
||||
uris.add(channel.getDownloadLink());
|
||||
}
|
||||
|
||||
return urls;
|
||||
return uris;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user