Package com.crawljax.web.model

Examples of com.crawljax.web.model.Plugin


  @GET
  @Path("{id}")
  public Response getPlugin(@PathParam("id") String id) {
    Response r;
    Plugin config = plugins.findByID(id);
    if (config != null)
      r = Response.ok(config).build();
    else
      r = Response.serverError().build();
    return r;
View Full Code Here


  @POST
  @Consumes(MediaType.MULTIPART_FORM_DATA)
  public Response addPlugin(@FormDataParam("name") String name,
          @FormDataParam("file") String file,
      @FormDataParam("url") String url) {
    Plugin plugin = null;
    boolean error = false;
    if(file != null) {
      String content = file.substring(file.indexOf(',') + 1);
      BASE64Decoder decoder = new BASE64Decoder();
      try {
View Full Code Here

        pluginIds.add(id);
      }
    }

    for (String id : pluginIds) {
      Plugin p = load(id);
      if(p != null) {
        plugins.put(p.getId(), p);
      }
    }

    return plugins;
  }
View Full Code Here

    return destination;
  }

  public Plugin load(String pluginId) {
    File jar = loadPluginJar(pluginId);
    Plugin plugin = null;
    try {
      PluginDescriptor descriptor = loadPluginDescriptorFromJar(jar);
      if(descriptor == null) {
        throw new Exception("Failed to load plugin descriptor");
      }
      plugin = new Plugin();
      plugin.setId(pluginId);
      plugin.setJarFile(jar);
      plugin.setName(descriptor.getName());
      plugin.setDescription(descriptor.getDescription());
      plugin.setParameters(descriptor.getParameters());
      plugin.setCrawljaxVersions(descriptor.getCrawljaxVersions());
    } catch (Exception e) {
      LOG.error("Could not load plugin {}", jar.getName());
      LOG.debug("Could not load plugin {}. \n{}", jar.getName(), e.getStackTrace());
    }
    return plugin;
View Full Code Here

      LOG.error("Could not save plugin file {}.", pluginJar.getName());
      LOG.debug("Could not save plugin file {}.\n{}", pluginJar.getName(), e.getStackTrace());
      throw new CrawljaxWebException("Could not save plugin file");
    }

    Plugin plugin = load(id);
    if(plugin == null) {
      delete(id);
      throw new CrawljaxWebException("Could not read plugin descriptor");
    }
View Full Code Here

      urlFile.delete();
      LOG.error(e.toString());
      LOG.debug(e.toString());
      throw new CrawljaxWebException("Could not save plugin file");
    }
    Plugin plugin = load(id);
    if(plugin == null) {
      delete(id);
      throw new CrawljaxWebException("Could not read plugin descriptor");
    }
    return plugin;
View Full Code Here

        File outputFolder = new File(record.getOutputFolder() + File.separatorChar + "plugins"
                + File.separatorChar + "0");
        outputFolder.mkdirs();
        builder.addPlugin(new CrawlOverview(new HostInterfaceImpl(outputFolder, new HashMap<String, String>())));
        for (int i = 0, l = config.getPlugins().size(); i < l; i++) {
          Plugin pluginConfig = config.getPlugins().get(i);
          Plugin plugin = plugins.findByID(pluginConfig.getId());
          if (plugin == null) {
            LogWebSocketServlet.sendToAll("Could not find plugin: "
                    + pluginConfig.getId());
            continue;
          }
          if(!plugin.getCrawljaxVersions().contains(Main.getCrawljaxVersion())) {
            LogWebSocketServlet.sendToAll("Plugin "
                + pluginConfig.getId() + " is not compatible with this version of Crawljax (" + Main.getCrawljaxVersion() + ")");
            continue;
          }
          String pluginKey = String.valueOf(i + 1);
          outputFolder = new File(record.getOutputFolder() + File.separatorChar + "plugins"
                  + File.separatorChar + pluginKey);
          outputFolder.mkdirs();
          Map<String, String> parameters = new HashMap<>();
          for (Parameter parameter : plugin.getParameters()) {
            parameters.put(parameter.getId(), "");
            for (Parameter configParam : pluginConfig.getParameters()) {
              if (configParam.getId().equals(parameter.getId()) && configParam.getValue() != null) {
                parameters.put(parameter.getId(), configParam.getValue());
              }
View Full Code Here

TOP

Related Classes of com.crawljax.web.model.Plugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.