use of org.syncany.operations.plugin.PluginOperationResult in project syncany by syncany.
the class PluginManagementRequestHandler method handleRequest.
@Override
public Response handleRequest(final ManagementRequest request) {
final PluginManagementRequest concreteRequest = (PluginManagementRequest) request;
logger.log(Level.SEVERE, "Executing PluginOperation for action " + concreteRequest.getOptions().getAction() + " ...");
Thread pluginThread = new Thread(new Runnable() {
@Override
public void run() {
try {
PluginOperation pluginOperation = new PluginOperation(null, concreteRequest.getOptions());
PluginOperationResult operationResult = pluginOperation.execute();
switch(operationResult.getResultCode()) {
case OK:
eventBus.post(new PluginManagementResponse(PluginManagementResponse.OK, operationResult, request.getId()));
break;
case NOK:
eventBus.post(new PluginManagementResponse(PluginManagementResponse.NOK_FAILED_UNKNOWN, operationResult, request.getId()));
break;
}
} catch (Exception e) {
logger.log(Level.WARNING, "Error executing plugin management request.", e);
eventBus.post(new PluginManagementResponse(PluginManagementResponse.NOK_OPERATION_FAILED, new PluginOperationResult(), request.getId()));
}
}
}, "PlugRq/" + concreteRequest.getOptions().getAction());
pluginThread.start();
return null;
}
use of org.syncany.operations.plugin.PluginOperationResult in project syncany by syncany.
the class PluginOperationTest method testPluginInstall.
@Test
public void testPluginInstall() throws Exception {
if (EnvironmentUtil.isWindows()) {
// Test is Unix-specific.
return;
}
File configDir = setupCleanConfigDir();
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.INSTALL);
pluginOptions.setPluginId("ftp");
PluginOperationResult pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Only one file should be in here: the jar for ftp.
assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);
// Tear down
client.deleteTestData();
TestFileUtil.deleteDirectory(configDir);
System.setProperty("user.home", "/tmp");
}
use of org.syncany.operations.plugin.PluginOperationResult in project syncany by syncany.
the class PluginOperationTest method testPluginListRemoteOnlyIncludingSnapshots.
@Test
public void testPluginListRemoteOnlyIncludingSnapshots() throws Exception {
// Tests which plugin snapshots are available. This is difficult because
// that will change. So we can only test the bare minimum.
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.LIST);
pluginOptions.setListMode(PluginListMode.REMOTE);
pluginOptions.setSnapshots(true);
PluginOperationResult pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Tear down
client.deleteTestData();
}
use of org.syncany.operations.plugin.PluginOperationResult in project syncany by syncany.
the class PluginOperationTest method testPluginInstallUrl.
@Test
public void testPluginInstallUrl() throws Exception {
if (EnvironmentUtil.isWindows()) {
// Test is Unix-specific.
return;
}
File configDir = setupCleanConfigDir();
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.LIST);
pluginOptions.setListMode(PluginListMode.REMOTE);
pluginOptions.setSnapshots(false);
PluginOperationResult pluginResult = client.plugin(pluginOptions);
String pluginDownloadUrl = null;
for (ExtendedPluginInfo pluginInfo : pluginResult.getPluginList()) {
if (pluginInfo.getRemotePluginInfo().getPluginId().equals("ftp")) {
pluginDownloadUrl = pluginInfo.getRemotePluginInfo().getDownloadUrl();
}
}
pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.INSTALL);
pluginOptions.setPluginId(pluginDownloadUrl);
pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Only one file should be in here: the jar for ftp.
assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);
// Tear down
client.deleteTestData();
TestFileUtil.deleteDirectory(configDir);
System.setProperty("user.home", "/tmp");
}
use of org.syncany.operations.plugin.PluginOperationResult in project syncany by syncany.
the class PluginCommand method execute.
@Override
public int execute(String[] operationArgs) throws Exception {
PluginOperationOptions operationOptions = parseOptions(operationArgs);
PluginOperationResult operationResult = new PluginOperation(config, operationOptions).execute();
printResults(operationResult);
return 0;
}
Aggregations