external: Support custom plugin json files for raw repositories
This commit is contained in:
@@ -186,9 +186,21 @@ public class OPRSExternalPluginManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean testRepository(URL url)
|
public static boolean testRepository(URL url)
|
||||||
|
{
|
||||||
|
return testRepository(url, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean testRepository(URL url, String pluginsJson)
|
||||||
{
|
{
|
||||||
final List<UpdateRepository> repositories = new ArrayList<>();
|
final List<UpdateRepository> repositories = new ArrayList<>();
|
||||||
repositories.add(new DefaultUpdateRepository("repository-testing", url));
|
if (pluginsJson != null)
|
||||||
|
{
|
||||||
|
repositories.add(new DefaultUpdateRepository("repository-testing", url, pluginsJson));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
repositories.add(new DefaultUpdateRepository("repository-testing", url));
|
||||||
|
}
|
||||||
DefaultPluginManager testPluginManager = new DefaultPluginManager(EXTERNALPLUGIN_DIR.toPath());
|
DefaultPluginManager testPluginManager = new DefaultPluginManager(EXTERNALPLUGIN_DIR.toPath());
|
||||||
UpdateManager updateManager = new UpdateManager(testPluginManager, repositories);
|
UpdateManager updateManager = new UpdateManager(testPluginManager, repositories);
|
||||||
|
|
||||||
@@ -285,7 +297,26 @@ public class OPRSExternalPluginManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories.add(new DefaultUpdateRepository(id, new URL(url)));
|
log.info("url: {}", url);
|
||||||
|
String pluginJson = null;
|
||||||
|
if (url.contains(".json"))
|
||||||
|
{
|
||||||
|
url = url.replace(".json/", ".json");
|
||||||
|
|
||||||
|
URL urlObj = new URL(url);
|
||||||
|
String urlPath = urlObj.getPath();
|
||||||
|
|
||||||
|
pluginJson = urlPath.substring(urlPath.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pluginJson == null)
|
||||||
|
{
|
||||||
|
repositories.add(new DefaultUpdateRepository(id, new URL(url)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
repositories.add(new DefaultUpdateRepository(id, new URL(url), pluginJson));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArrayIndexOutOfBoundsException | MalformedURLException e)
|
catch (ArrayIndexOutOfBoundsException | MalformedURLException e)
|
||||||
@@ -342,7 +373,22 @@ public class OPRSExternalPluginManager
|
|||||||
|
|
||||||
public void addRepository(String key, URL url)
|
public void addRepository(String key, URL url)
|
||||||
{
|
{
|
||||||
DefaultUpdateRepository respository = new DefaultUpdateRepository(key, url);
|
addRepository(key, url, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRepository(String key, URL url, String pluginsJson)
|
||||||
|
{
|
||||||
|
DefaultUpdateRepository respository;
|
||||||
|
|
||||||
|
if (pluginsJson != null)
|
||||||
|
{
|
||||||
|
respository = new DefaultUpdateRepository(key, url, pluginsJson);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respository = new DefaultUpdateRepository(key, url);
|
||||||
|
}
|
||||||
|
|
||||||
updateManager.addRepository(respository);
|
updateManager.addRepository(respository);
|
||||||
eventBus.post(new OPRSRepositoryChanged(key, true));
|
eventBus.post(new OPRSRepositoryChanged(key, true));
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|||||||
@@ -208,9 +208,22 @@ public class ExternalPluginManagerPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
URL urlActual;
|
URL urlActual;
|
||||||
|
String pluginJson = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
urlActual = new URL(url.getText());
|
String urlText = url.getText();
|
||||||
|
|
||||||
|
if (urlText.contains(".json"))
|
||||||
|
{
|
||||||
|
urlText = urlText.replace(".json/", ".json");
|
||||||
|
|
||||||
|
URL urlObj = new URL(urlText);
|
||||||
|
String urlPath = urlObj.getPath();
|
||||||
|
|
||||||
|
pluginJson = urlPath.substring(urlPath.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
urlActual = new URL(urlText);
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e)
|
catch (MalformedURLException e)
|
||||||
{
|
{
|
||||||
@@ -219,14 +232,21 @@ public class ExternalPluginManagerPanel extends PluginPanel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OPRSExternalPluginManager.testRepository(urlActual))
|
if ((pluginJson == null && OPRSExternalPluginManager.testRepository(urlActual)) || (pluginJson != null && OPRSExternalPluginManager.testRepository(urlActual, pluginJson)))
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog(ClientUI.getFrame(), "This doesn't appear to be a valid repository.", "Error!",
|
JOptionPane.showMessageDialog(ClientUI.getFrame(), "This doesn't appear to be a valid repository.", "Error!",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
externalPluginManager.addRepository(id.getText(), urlActual);
|
if (pluginJson == null)
|
||||||
|
{
|
||||||
|
externalPluginManager.addRepository(id.getText(), urlActual);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
externalPluginManager.addRepository(id.getText(), urlActual, pluginJson);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user