mirror of
https://github.com/Rogiel/httpchannel
synced 2025-12-05 23:22:51 +00:00
Implements 4shared.com service
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.rogiel.httpchannel.service.impl;
|
||||
package com.rogiel.httpchannel.service.multiupload;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -55,7 +55,7 @@ import com.rogiel.httpchannel.service.exception.DownloadLimitExceededException;
|
||||
import com.rogiel.httpchannel.service.exception.DownloadLinkNotFoundException;
|
||||
import com.rogiel.httpchannel.service.exception.DownloadNotAuthorizedException;
|
||||
import com.rogiel.httpchannel.service.exception.DownloadNotResumableException;
|
||||
import com.rogiel.httpchannel.service.impl.MultiUploadUploaderConfiguration.MultiUploadMirrorService;
|
||||
import com.rogiel.httpchannel.service.multiupload.MultiUploadUploaderConfiguration.MultiUploadMirrorService;
|
||||
import com.rogiel.httpchannel.util.PatternUtils;
|
||||
import com.rogiel.httpchannel.util.htmlparser.HTMLPage;
|
||||
|
||||
@@ -221,6 +221,12 @@ public class MultiUploadService extends AbstractHttpService implements Service,
|
||||
.uploadServices()) {
|
||||
logger.debug("Adding {} as mirror", mirror.name());
|
||||
request.parameter("service_" + mirror.id, 1);
|
||||
final String[] login = configuration
|
||||
.getAuthenticationForService(mirror);
|
||||
if (login != null && login.length == 2) {
|
||||
request.parameter("username_" + mirror.id, login[0]);
|
||||
request.parameter("password_" + mirror.id, login[1]);
|
||||
}
|
||||
}
|
||||
|
||||
uploadFuture = request.asStringAsync();
|
||||
@@ -16,14 +16,14 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.rogiel.httpchannel.service.impl;
|
||||
package com.rogiel.httpchannel.service.multiupload;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.rogiel.httpchannel.service.AbstractUploaderConfiguration;
|
||||
import com.rogiel.httpchannel.service.Uploader.DescriptionableUploaderConfiguration;
|
||||
import com.rogiel.httpchannel.service.Uploader.UploaderConfiguration;
|
||||
import com.rogiel.httpchannel.service.impl.MultiUploadService.UploaderImpl;
|
||||
import com.rogiel.httpchannel.service.multiupload.MultiUploadService.UploaderImpl;
|
||||
|
||||
/**
|
||||
* Describes an configuration for an {@link UploaderImpl}
|
||||
@@ -42,6 +42,11 @@ public class MultiUploadUploaderConfiguration extends
|
||||
*/
|
||||
private EnumSet<MultiUploadMirrorService> uploadServices = EnumSet
|
||||
.allOf(MultiUploadMirrorService.class);
|
||||
/**
|
||||
* The service authentication
|
||||
*/
|
||||
private final String[][] serviceAuthentication = new String[MultiUploadMirrorService
|
||||
.values().length][];
|
||||
|
||||
/**
|
||||
* An enumeration containing all supported services for Multiupload
|
||||
@@ -82,11 +87,31 @@ public class MultiUploadUploaderConfiguration extends
|
||||
public MultiUploadUploaderConfiguration uploadService(
|
||||
MultiUploadMirrorService... services) {
|
||||
for (final MultiUploadMirrorService service : services) {
|
||||
serviceAuthentication[service.ordinal()] = null;
|
||||
uploadServices.add(service);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this service as an desired mirror
|
||||
*
|
||||
* @param service
|
||||
* the service
|
||||
* @param username
|
||||
* the service username
|
||||
* @param password
|
||||
* the service password
|
||||
*/
|
||||
public MultiUploadUploaderConfiguration uploadService(
|
||||
MultiUploadMirrorService service, String username, String password) {
|
||||
if (username != null && password != null) {
|
||||
serviceAuthentication[service.ordinal()] = new String[] { username,
|
||||
password };
|
||||
}
|
||||
return uploadService(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the service is on the desired mirror list
|
||||
*
|
||||
@@ -127,4 +152,12 @@ public class MultiUploadUploaderConfiguration extends
|
||||
public EnumSet<MultiUploadMirrorService> uploadServices() {
|
||||
return uploadServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the configured authentication for the given service
|
||||
*/
|
||||
protected String[] getAuthenticationForService(
|
||||
MultiUploadMirrorService service) {
|
||||
return serviceAuthentication[service.ordinal()];
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
com.rogiel.httpchannel.service.impl.MultiUploadService
|
||||
com.rogiel.httpchannel.service.multiupload.MultiUploadService
|
||||
@@ -30,6 +30,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.rogiel.httpchannel.service.DownloadService;
|
||||
import com.rogiel.httpchannel.service.multiupload.MultiUploadService;
|
||||
import com.rogiel.httpchannel.util.ChannelUtils;
|
||||
|
||||
public class MultiUploadServiceTest {
|
||||
|
||||
Reference in New Issue
Block a user