-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract filters for protocol features used for specific file attribut…
…es in file transfers.
- Loading branch information
Showing
26 changed files
with
1,573 additions
and
573 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
core/src/main/java/ch/cyberduck/core/transfer/ChainedFeatureFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package ch.cyberduck.core.transfer; | ||
|
||
/* | ||
* Copyright (c) 2002-2024 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import ch.cyberduck.core.Local; | ||
import ch.cyberduck.core.Path; | ||
import ch.cyberduck.core.ProgressListener; | ||
import ch.cyberduck.core.exception.BackgroundException; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Optional; | ||
|
||
public class ChainedFeatureFilter implements FeatureFilter { | ||
private static final Logger log = LogManager.getLogger(ChainedFeatureFilter.class); | ||
|
||
private final FeatureFilter[] filters; | ||
|
||
public ChainedFeatureFilter(final FeatureFilter... filters) { | ||
this.filters = filters; | ||
} | ||
|
||
@Override | ||
public TransferStatus prepare(final Path file, final Optional<Local> local, final TransferStatus status, final ProgressListener progress) throws BackgroundException { | ||
for(final FeatureFilter filter : filters) { | ||
log.debug("Prepare {} with {}", file, filter); | ||
filter.prepare(file, local, status, progress); | ||
} | ||
return status; | ||
} | ||
|
||
@Override | ||
public void complete(final Path file, final Optional<Local> local, final TransferStatus status, final ProgressListener progress) throws BackgroundException { | ||
for(final FeatureFilter filter : filters) { | ||
log.debug("Complete {} with {}", file, filter); | ||
filter.complete(file, local, status, progress); | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
core/src/main/java/ch/cyberduck/core/transfer/FeatureFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ch.cyberduck.core.transfer; | ||
|
||
/* | ||
* Copyright (c) 2002-2024 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import ch.cyberduck.core.Local; | ||
import ch.cyberduck.core.Path; | ||
import ch.cyberduck.core.ProgressListener; | ||
import ch.cyberduck.core.exception.BackgroundException; | ||
|
||
import java.util.Optional; | ||
|
||
public interface FeatureFilter { | ||
default TransferStatus prepare(final Path file, final Optional<Local> local, final TransferStatus status, final ProgressListener progress) throws BackgroundException { | ||
// No-op | ||
return status; | ||
} | ||
|
||
default void apply(final Path file, final TransferStatus status, final ProgressListener progress) throws BackgroundException { | ||
// No-op | ||
} | ||
|
||
default void complete(final Path file, final Optional<Local> local, final TransferStatus status, final ProgressListener progress) throws BackgroundException { | ||
// No-op | ||
} | ||
|
||
FeatureFilter noop = new FeatureFilter() { | ||
@Override | ||
public TransferStatus prepare(final Path file, final Optional<Local> local, final TransferStatus status, final ProgressListener progress) { | ||
// No-op | ||
return status; | ||
} | ||
}; | ||
} |
Oops, something went wrong.