use of com.qcadoo.plugin.internal.PluginException in project qcadoo by qcadoo.
the class PluginManagerInstallTest method shouldFailureWithCorruptedPluginOnInstall.
@Test
public void shouldFailureWithCorruptedPluginOnInstall() throws Exception {
// given
given(pluginDescriptorParser.parse(file)).willThrow(new PluginException(""));
given(pluginFileManager.uploadPlugin(pluginArtifact)).willReturn(file);
given(file.getName()).willReturn("filename");
// when
PluginOperationResult pluginOperationResult = pluginManager.installPlugin(pluginArtifact);
// then
verify(pluginDao, never()).save(Mockito.any(InternalPlugin.class));
verify(pluginAccessor, never()).savePlugin(Mockito.any(InternalPlugin.class));
verify(pluginFileManager).uninstallPlugin("filename");
assertFalse(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.CORRUPTED_PLUGIN, pluginOperationResult.getStatus());
}
use of com.qcadoo.plugin.internal.PluginException in project qcadoo by qcadoo.
the class DefaultPluginDescriptorParser method parse.
@Override
public InternalPlugin parse(final Resource resource) {
try {
LOG.info("Parsing descriptor for:" + resource);
boolean ignoreModules = false;
URL url = ResourceUtils.extractJarFileURL(resource.getURL());
return parse(resource.getInputStream(), ignoreModules, FilenameUtils.getName(url.toString()));
} catch (IOException e) {
throw new PluginException(e.getMessage(), e);
} catch (Exception e) {
throw new PluginException(e.getMessage(), e);
}
}
use of com.qcadoo.plugin.internal.PluginException in project qcadoo by qcadoo.
the class DefaultPluginDescriptorParser method loadPlugins.
@Override
public Set<InternalPlugin> loadPlugins() {
Map<String, InternalPlugin> loadedplugins = new HashMap<String, InternalPlugin>();
Resource[] resources = pluginDescriptorResolver.getDescriptors();
for (Resource resource : resources) {
InternalPlugin plugin = parse(resource);
if (loadedplugins.containsKey(plugin.getIdentifier())) {
throw new PluginException("Duplicated plugin identifier: " + plugin.getIdentifier());
}
loadedplugins.put(plugin.getIdentifier(), plugin);
}
return new HashSet<InternalPlugin>(loadedplugins.values());
}
use of com.qcadoo.plugin.internal.PluginException in project qcadoo by qcadoo.
the class PluginManagerInstallTest method shouldFailureOnUploadingPluginOnInstall.
@Test
public void shouldFailureOnUploadingPluginOnInstall() throws Exception {
// given
given(pluginFileManager.uploadPlugin(pluginArtifact)).willThrow(new PluginException(""));
// when
PluginOperationResult pluginOperationResult = pluginManager.installPlugin(pluginArtifact);
// then
verify(pluginDao, never()).save(Mockito.any(InternalPlugin.class));
verify(pluginAccessor, never()).savePlugin(Mockito.any(InternalPlugin.class));
assertFalse(pluginOperationResult.isSuccess());
assertEquals(PluginOperationStatus.CANNOT_UPLOAD_PLUGIN, pluginOperationResult.getStatus());
}
use of com.qcadoo.plugin.internal.PluginException in project qcadoo by qcadoo.
the class DefaultPluginFileManager method uploadPlugin.
@Override
public File uploadPlugin(final PluginArtifact pluginArtifact) {
InputStream input = pluginArtifact.getInputStream();
File pluginFile = new File(pluginsTmpPath + getProperty(L_FILE_SEPARATOR) + pluginArtifact.getName());
try {
FileUtils.copyInputStreamToFile(input, pluginFile);
} catch (IOException e) {
LOG.error("Problem with upload plugin file - " + e.getMessage());
throw new PluginException(e.getMessage(), e);
}
return pluginFile;
}
Aggregations