-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract the Http specific parts out of the Repository Transport
Fix #1887
- Loading branch information
Showing
12 changed files
with
215 additions
and
97 deletions.
There are no files selected for viewing
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
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
39 changes: 39 additions & 0 deletions
39
...lugin/src/main/java/org/eclipse/tycho/p2maven/transport/FileTransportProtocolHandler.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,39 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
|
||
import org.codehaus.plexus.component.annotations.Component; | ||
|
||
@Component(role = TransportProtocolHandler.class, hint = "file") | ||
public class FileTransportProtocolHandler implements TransportProtocolHandler { | ||
|
||
@Override | ||
public long getLastModified(URI uri) throws IOException { | ||
return getFile(uri).lastModified(); | ||
} | ||
|
||
|
||
@Override | ||
public File getFile(URI remoteFile) throws IOException { | ||
try { | ||
return new File(remoteFile); | ||
} catch (IllegalArgumentException e) { | ||
throw new IOException("Not a valid file URI: " + remoteFile); | ||
} | ||
} | ||
|
||
} |
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
53 changes: 53 additions & 0 deletions
53
...lugin/src/main/java/org/eclipse/tycho/p2maven/transport/HttpTransportProtocolHandler.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 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.codehaus.plexus.component.annotations.Requirement; | ||
import org.codehaus.plexus.logging.Logger; | ||
|
||
@Component(role = TransportProtocolHandler.class, hint = "http") | ||
public class HttpTransportProtocolHandler implements TransportProtocolHandler { | ||
|
||
static final String TRANSPORT_TYPE = System.getProperty("tycho.p2.httptransport.type", | ||
Java11HttpTransportFactory.HINT); | ||
|
||
@Requirement | ||
Map<String, HttpTransportFactory> transportFactoryMap; | ||
@Requirement | ||
HttpCache httpCache; | ||
|
||
@Requirement | ||
Logger logger; | ||
|
||
private HttpTransportFactory getTransportFactory() { | ||
return Objects.requireNonNull(transportFactoryMap.get(TRANSPORT_TYPE), "Invalid transport configuration"); | ||
} | ||
|
||
@Override | ||
public long getLastModified(URI uri) throws IOException { | ||
return httpCache.getCacheEntry(uri, logger).getLastModified(getTransportFactory()); | ||
} | ||
|
||
@Override | ||
public File getFile(URI remoteFile) throws IOException { | ||
return httpCache.getCacheEntry(remoteFile, logger).getCacheFile(getTransportFactory()); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...ugin/src/main/java/org/eclipse/tycho/p2maven/transport/HttpsTransportProtocolHandler.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,20 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import org.codehaus.plexus.component.annotations.Component; | ||
|
||
@Component(role = TransportProtocolHandler.class, hint = "https") | ||
public class HttpsTransportProtocolHandler extends HttpTransportProtocolHandler { | ||
|
||
} |
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
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
13 changes: 13 additions & 0 deletions
13
...en-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TransportProtocolHandler.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,13 @@ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
|
||
public interface TransportProtocolHandler { | ||
|
||
long getLastModified(URI uri) throws IOException; | ||
|
||
File getFile(URI remoteFile) throws IOException; | ||
|
||
} |
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
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
Oops, something went wrong.