Changeset 5595


Ignore:
Timestamp:
Mar 17, 2011, 1:47:15 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #1592: Unified installation procedure for plug-ins, extensions and more...

Application will check that plugins.dir is set and exists at startup and exists with an error message otherwise.

Removed PluginDefinition.jarPath property and replaced with PluginDefinition.jarFile. No path information is allowed in this property. Update script must copy the filename only from jar_path column in PluginDefinitions to jar_file and then remove the jar_path column.

Removed JobAgentSettings.jarPath property since it no longer makes sense to override this property. The update script should remove the jar_path column from the JobAgentSettings table.

Removed/replaced several methods from the PluginDefinition class that allows overriding the JAR path to a plug-in. External applications or plug-ins no longer has to worry about the path, but they may need to be recompiled to use the new methods.

The DataFileType has not yet been fully fixed and may not work as expected. The idea is to replace the classname+jarpath properties with some kind of extension system (#1593) similar to external file support (#1582).

In the web gui, places that are handling JAR path information has been fixed. For job agents it has been removed completely since it is no longer needed. The auto-installation wizard is probably not working at the moment. The update script should remove references to the jarPath property in context information (list filters, sort order, etc.).

Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/Upload.java

    r5395 r5595  
    203203        {
    204204          PluginDefinition plugin = PluginDefinition.getById(dc, zipFormat);
    205           unpacker = plugin.newInstance(FileUnpacker.class, null, sc, null, null);
     205          unpacker = plugin.newInstance(FileUnpacker.class, sc, null, null);
    206206        }
    207207       
  • trunk/src/core/net/sf/basedb/core/Application.java

    r5582 r5595  
    125125 
    126126  /**
     127    The one and only place where plug-ins can be installed.
     128  */
     129  private static java.io.File pluginsDirectory;
     130 
     131  /**
    127132    Cache for static data.
    128133  */
     
    173178  */
    174179  private static String databaseVersionNumber;
    175  
    176   /**
    177     The directory where non-core plugins are located/installed.
    178   */
    179   private static java.io.File nonCorePluginDirectory;
    180180 
    181181  /**
     
    425425      log.info("permission.timeout = " + permissionTimeout + " minutes");
    426426     
    427       userFilesDirectory = new java.io.File(Config.getString("userfiles"));
     427      userFilesDirectory = new java.io.File(Config.getRequiredString("userfiles", "No setting for 'userfiles' in base.config."));
    428428      log.info("userfiles = " + userFilesDirectory);
     429      if (!userFilesDirectory.exists() || !userFilesDirectory.isDirectory())
     430      {
     431        throw new ConfigurationException("Userfiles directory '" + userFilesDirectory + "' doesn't exists or is not a directory.");
     432      }
     433
     434      pluginsDirectory = new java.io.File(Config.getRequiredString("plugins.dir", "No setting for 'plugins.dir' in base.config"));
     435      log.info("plugins.dir = " + pluginsDirectory);
     436      if (!pluginsDirectory.exists() || !pluginsDirectory.isDirectory())
     437      {
     438        throw new ConfigurationException("Plug-ins directory '" + pluginsDirectory + "' doesn't exists or is not a directory.");
     439      }
    429440     
    430441      log.info("db.dialect = " + Config.getString("db.dialect"));
     
    452463      autoUnloadPlugins = Config.getBoolean("plugins.autounload");
    453464      log.info("plugins.autounload = " + autoUnloadPlugins);
    454      
    455       String pluginsDir = Config.getString("plugins.dir");
    456       nonCorePluginDirectory = pluginsDir != null ? new java.io.File(pluginsDir) : null;
    457       log.info("plugins.dir = " + nonCorePluginDirectory);
    458465     
    459466      noAutoCompression = Config.getBoolean("autocompress.disable");
     
    897904 
    898905  /**
    899     Get the directory where non-core plugins are located and installed
    900     @return java.io.File A directory where the external plugins are located/installed,
    901       or null if not defined.
    902     @since 2.5
    903   */
    904   public static java.io.File getNonCorePluginDirectory()
    905   {
    906     return nonCorePluginDirectory;
     906    Get the directory where plug-ins and extensions must be installed.
     907    @return java.io.File A directory where the external plugins are located/installed
     908    @since 3.0
     909  */
     910  public static java.io.File getPluginsDirectory()
     911  {
     912    return pluginsDirectory;
    907913  }
    908914 
  • trunk/src/core/net/sf/basedb/core/Config.java

    r5570 r5595  
    214214
    215215  /**
     216    Get a required configuration setting. If the setting doesn't exists or
     217    is empty the given message is thrown as a ConfigurationException
     218    @param key The key for the setting
     219    @param message The error message to throw if the setting doesn't exists
     220    @return The value specified by <code>key</code>
     221    @since 3.0
     222  */
     223  public static String getRequiredString(String key, String message)
     224  {
     225    String value = getString(key, null);
     226    if (value == null) throw new ConfigurationException(message);
     227    return value;
     228  }
     229 
     230  /**
    216231    Get the configuration setting specified by <code>key</code> as a String value.
    217232    @param key The key for the setting
  • trunk/src/core/net/sf/basedb/core/DataFileType.java

    r5384 r5595  
    601601  public String getValidatorJarPath()
    602602  {
    603     return PluginDefinition.convertToAbsolute(getData().getValidatorJarPath());
     603    return getData().getValidatorJarPath();
    604604  }
    605605 
     
    615615  {
    616616    checkPermission(Permission.WRITE);
    617     validatorJarPath = PluginDefinition.convertToRelative(validatorJarPath);
    618617    getData().setValidatorJarPath(StringUtil.setNullableString(validatorJarPath,
    619618      "validatorJarPath", MAX_JARPATH_LENGTH));
     
    679678  public String getMetadataReaderJarPath()
    680679  {
    681     return PluginDefinition.convertToAbsolute(getData().getMetadataReaderJarPath());
     680    return getData().getMetadataReaderJarPath();
    682681  }
    683682 
     
    693692  {
    694693    checkPermission(Permission.WRITE);
    695     metadataReaderJarPath = PluginDefinition.convertToRelative(metadataReaderJarPath);
    696694    getData().setMetadataReaderJarPath(StringUtil.setNullableString(metadataReaderJarPath,
    697695      "metadataReaderJarPath", MAX_JARPATH_LENGTH));
  • trunk/src/core/net/sf/basedb/core/Job.java

    r5590 r5595  
    12151215    PluginDefinition pd = getPluginDefinition();
    12161216    PluginConfiguration config = getPluginConfiguration();
    1217     Plugin plugin = pd.newInstance(settings == null ? null : settings.getJarPath());
     1217    Plugin plugin = pd.newInstance();
    12181218    JobAgent agent = settings == null ? null : settings.getJobAgent();
    12191219    SessionControl sc = getSessionControl();
  • trunk/src/core/net/sf/basedb/core/JobAgentSettings.java

    r4517 r5595  
    195195 
    196196  /**
    197     Get the path to the JAR file that contains the plugin implementation. If null
    198     the jar path returned by the plugin definition should be used.
    199     @return The JAR path or null
    200     @see PluginDefinition#getJarPath()
    201     @see #getEffectiveJarPath()
    202   */
    203   public String getJarPath()
    204   {
    205     return getData().getJarPath();
    206   }
    207  
    208   /**
    209     Get the effective path to the JAR file that contains the plugin implementation.
    210     If these settings hasn't configured a special JAR path, the JAR path from the
    211     plugin definition is returned.
    212     @return The JAR path
    213     @see PluginDefinition#getJarPath()
    214     @see #getJarPath()
    215   */
    216   public String getEffectiveJarPath()
    217   {
    218     JobAgentSettingsData data = getData();
    219     String jarPath = data.getJarPath();
    220     if (jarPath == null)
    221     {
    222       jarPath = PluginDefinition.convertToAbsolute(data.getPluginDefinition().getJarPath());
    223     }
    224     return jarPath;
    225   }
    226  
    227   /**
    228     The maximum length of the jar path that can be stored in the database.
    229     @see #setJarPath(String)
    230   */
    231   public static final int MAX_JARPATH_LENGTH = JobAgentSettingsData.MAX_JARPATH_LENGTH;
    232  
    233   /**
    234     Set the path to the JAR file that contains the plugin implementation.
    235     @param jarPath The JAR path or null to use the JAR path specified by the
    236       plugin definition
    237     @throws PermissionDeniedException If the logged in user doesn't have
    238       write permission
    239     @throws InvalidDataException If the new value is longer than
    240       {@link #MAX_JARPATH_LENGTH}
    241   */
    242   public void setJarPath(String jarPath)
    243     throws PermissionDeniedException, InvalidDataException
    244   {
    245     checkPermission(Permission.WRITE);
    246     getData().setJarPath(StringUtil.setNullableString(jarPath, "jarPath", MAX_JARPATH_LENGTH));
    247   }
    248  
    249   /**
    250197    If the plugin is a trusted plugin or not. If null the trusted flag returned by
    251198    the plugin definition should be used.
  • trunk/src/core/net/sf/basedb/core/PluginConfiguration.java

    r5590 r5595  
    268268  public ItemQuery<AnnotationType> getAnnotationTypes()
    269269  {
    270     Plugin p = getPluginDefinition().newInstance(Plugin.class, null, getSessionControl(), this, null);
     270    Plugin p = getPluginDefinition().newInstance(Plugin.class, getSessionControl(), this, null);
    271271    ItemQuery<AnnotationType> query = null;
    272272    if (p instanceof AnnotationSetterPlugin)
     
    283283  public String getAnnotationMessage()
    284284  {
    285     Plugin p = getPluginDefinition().newInstance(Plugin.class, null, getSessionControl(), this, null);
     285    Plugin p = getPluginDefinition().newInstance(Plugin.class, getSessionControl(), this, null);
    286286    String message = null;
    287287    if (p instanceof AnnotationSetterPlugin)
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r5345 r5595  
    8383    The maximum length of the jar path name that can be stored in the
    8484    database.
    85   */
    86   public static final int MAX_JARPATH_LENGTH = PluginDefinitionData.MAX_JARPATH_LENGTH;
     85    @since 3.0
     86  */
     87  public static final int MAX_JARFILE_LENGTH = PluginDefinitionData.MAX_JARFILE_LENGTH;
    8788
    8889  /**
     
    122123  public static final int MAX_URL_LENGTH = PluginDefinitionData.MAX_URL_LENGTH;
    123124
    124   /**
    125     Convert a plug-in path to a path relative to the <code>plugins.dir</code>
    126     setting in <code>base.config</code>. If no plug-in directory has been
    127     specified or if the path is null nothing is done. If the given path is
    128     a subpath to the <code>plugins.dir</code> path the common path is replaced
    129     with <code>%plugins.dir%</code> and all path separator characters are
    130     converted to '/'. For example:
    131     <pre class="code>"
    132 path          = /usr/local/base/plugins/myplugin.jar
    133 plugins.dir   = /usr/local/base/plugins
    134 relative path = %plugins.dir%/myplugin.jar
    135 
    136 //On windows
    137 path          = c:\base\plugins\mine\myplugin.jar
    138 plugins.dir   = c:\base\plugins
    139 relative path = %plugins.dir%/mine/myplugin.jar
    140 </pre>
    141 
    142     @param path The absolute path
    143     @return The relative path
    144     @since 2.6
    145     @see #convertToAbsolute(String)
    146   */
    147   public static String convertToRelative(String path)
    148   {
    149     if (path == null) return null;
    150     String pluginsDir = Config.getString("plugins.dir");
    151     if (pluginsDir == null) return path;
    152     if (path.startsWith(pluginsDir))
    153     {
    154       path = "%plugins.dir%" + path.substring(pluginsDir.length()).
    155         replace(java.io.File.separatorChar, '/');
    156     }
    157     return path;
    158   }
    159  
    160   /**
    161     Convert a relative plug-in path to an absolute path. This is the
    162     reverse of the {@link #convertToRelative(String)} method.
    163  
    164     @param path The relative path
    165     @return The absolute path
    166     @since 2.6
    167   */
    168   public static String convertToAbsolute(String path)
    169   {
    170     if (path == null) return path;
    171     String pluginsDir = Config.getString("plugins.dir");
    172     if (pluginsDir == null) return path;
    173     if (path.startsWith("%plugins.dir%"))
    174     {
    175       path = pluginsDir + path.substring("%plugins.dir%".length()).
    176         replace('/', java.io.File.separatorChar);
    177     }
    178     return path;
    179   }
    180  
    181125  /**
    182126    Create a new <code>PluginDefinition</code> item.
     
    568512  public ItemQuery<AnnotationType> getAnnotationTypes()
    569513  {
    570     Plugin p = newInstance(Plugin.class, null, getSessionControl(), null, null);
     514    Plugin p = newInstance(Plugin.class, getSessionControl(), null, null);
    571515    ItemQuery<AnnotationType> query = null;
    572516    if (p instanceof AnnotationSetterPlugin)
     
    583527  public String getAnnotationMessage()
    584528  {
    585     Plugin p = newInstance(Plugin.class, null, getSessionControl(), null, null);
     529    Plugin p = newInstance(Plugin.class, getSessionControl(), null, null);
    586530    String message = null;
    587531    if (p instanceof AnnotationSetterPlugin)
     
    618562  public String getJarPath()
    619563  {
    620     return convertToAbsolute(getData().getJarPath());
     564    String file = getJarFile();
     565    if (file == null) return null;
     566    return new java.io.File(Application.getPluginsDirectory(), file).getAbsolutePath();
    621567  }
    622568  /**
    623569    The jar path cannot be changed. Used internally only.
    624570  */
    625   private void setJarPath(String jarPath)
     571  private void setJarFile(String jarFile)
    626572    throws InvalidDataException
    627573  {
    628     getData().setJarPath(StringUtil.setNullableString(convertToRelative(jarPath),
    629         "jarPath", MAX_JARPATH_LENGTH));
     574    getData().setJarFile(StringUtil.setNullableString(jarFile, "jarFile", MAX_JARFILE_LENGTH));
     575  }
     576 
     577  /**
     578    Get the name of the JAR file that contains this plug-in.
     579    If this value is null, the plug-in must be on the classpath
     580    (eg. in WEB-INF/lib).
     581    @since 3.0
     582  */
     583  public String getJarFile()
     584  {
     585    return getData().getJarFile();
    630586  }
    631587 
     
    11291085  }
    11301086
     1087  /*
    11311088  Plugin newInstance(String jarPath)
    11321089    throws PermissionDeniedException, BaseException
     
    11351092    return newInstance(jarPath == null ? getJarPath() : jarPath, getClassName(), false);
    11361093  }
     1094  */
    11371095 
    11381096  /**
     
    11401098    @param <P> The kind of returned object that extends Plugin.
    11411099    @param clazz The class of the plugin which must be a subclass of <code>Plugin</code>
    1142     @param jarPath Overrides the default JAR path for a plugin, null to use the default
    1143       JAR path
    11441100    @return An uninitialised plugin instance
    11451101    @throws PermissionDeniedException
    11461102    @throws BaseException
    11471103   */
    1148   public <P extends Plugin> P newInstance(Class<P> clazz, String jarPath)
     1104  public <P extends Plugin> P newInstance(Class<P> clazz)
    11491105    throws PermissionDeniedException, BaseException
    11501106  {
    1151     Plugin p = newInstance(jarPath);
     1107    Plugin p = newInstance();
    11521108    if (!clazz.isInstance(p))
    11531109    {
    1154       throw new InvalidDataException("Plugin does not implement "+clazz.getName()+": "+toString());
     1110      throw new ClassCastException("Class '" + p.getClass().getName() + "' doesn't implement '" + clazz.getName() + "'");
    11551111    }
    11561112    return clazz.cast(p);
     
    11621118    @param <P> The kind of returned object that extends Plugin.
    11631119    @param clazz The class of the plugin which must be a subclass of <code>Plugin</code>
    1164     @param jarPath Overrides the default JAR path for a plugin, null to use the default
    1165       JAR path
    11661120    @param sc The session control to initialise the plugin with
    11671121    @param configuration The configuration parameters to initialise the plugin with,
     
    11721126    @throws PermissionDeniedException
    11731127    @throws BaseException
    1174    */
    1175   public <P extends Plugin> P newInstance(Class<P> clazz, String jarPath, SessionControl sc, PluginConfiguration configuration, Job job)
     1128  */
     1129  public <P extends Plugin> P newInstance(Class<P> clazz, SessionControl sc, PluginConfiguration configuration, Job job)
    11761130    throws PermissionDeniedException, BaseException
    11771131  {
    1178     P p = newInstance(clazz, jarPath);
     1132    P p = newInstance(clazz);
    11791133    if (sc == null) sc = getSessionControl();
    11801134    p.init(sc.getPluginSessionControl(this, job),
     
    11881142    Create a new object instance of the given class.
    11891143
    1190     @param jarPath The path to the JAR file
     1144    @param jarPath The full path to the JAR file
    11911145    @param className The class to create
    11921146    @param unloadBefore If the class definition should be unloaded before the new
     
    13171271    Load a plugin and copy all information, ie. plugin.about(),
    13181272    to the internal data structure.
    1319     @param jarPath Path to the jar-file in which the plugin is located.
    1320       Null is allowed if plugin is located in the web server's classpath.
     1273    @param jarFile File name of the jar file containing the plug-in. The
     1274      JAR file must be located in the directory spercified by 'plugins.dir' setting
     1275      in base.config. Null is allowed if plugin is located in the classpath (eg. WEB-INF/lib).
    13211276    @param className Full class name of the plugin's main class.
    13221277    @param useRequstedPermissions TRUE if plugin should use the permissions it requests.
     
    13261281    @throws BaseException If something else fails.
    13271282  */
    1328   public void loadPluginInformation(String jarPath, String className, boolean useRequstedPermissions)
     1283  public void loadPluginInformation(String jarFile, String className, boolean useRequstedPermissions)
    13291284    throws PermissionDeniedException, InvalidDataException, BaseException
    13301285  {
    13311286    checkPermission(Permission.WRITE);
     1287    if (jarFile != null)
     1288    {
     1289      if (!Path.isValidName(jarFile))
     1290      {
     1291        throw new InvalidDataException("JAR file name is not a valid name: " + jarFile);
     1292      }
     1293    }
     1294   
     1295    String jarPath = jarFile == null ?
     1296        null : new java.io.File(Application.getPluginsDirectory(), jarFile).getAbsolutePath();
    13321297    Plugin plugin = newInstance(jarPath, className, true);
    13331298
     
    13411306    // The class name and jar path
    13421307    setClassName(className);
    1343     setJarPath(jarPath);
     1308    setJarFile(jarFile);
    13441309   
    13451310    // Everything returned by the getAbout() method...
  • trunk/src/core/net/sf/basedb/core/data/JobAgentSettingsData.java

    r4517 r5595  
    6868  }
    6969 
    70  
    71   public static final int MAX_JARPATH_LENGTH = PluginDefinitionData.MAX_JARPATH_LENGTH;
    72   private String jarPath;
    73   /**
    74     Get the path to the JAR file where the plugin class is located. If the
    75     value is null the path that is specified by the plugin definition should
    76     be used.
    77     @see PluginDefinitionData#getJarPath()
    78     @return The path to the JAR file with the plugin, or null if the plugin definition
    79       JAR path should be used
    80     @hibernate.property column="`jar_path`" type="text" not-null="false"
    81   */
    82   public String getJarPath()
    83   {
    84     return jarPath;
    85   }
    86   public void setJarPath(String jarPath)
    87   {
    88     this.jarPath = jarPath;
    89   }
    90  
    9170  private Boolean trusted;
    9271  /**
  • trunk/src/core/net/sf/basedb/core/data/PluginDefinitionData.java

    r4889 r5595  
    4141*/
    4242public class PluginDefinitionData
    43   extends SharedData
     43  extends CommonData
    4444  implements RemovableData, AnnotatableData, RegisteredData
    4545{
     
    113113  }
    114114
    115 
    116   public static final int MAX_JARPATH_LENGTH = 65535;
    117   private String jarPath;
    118   /**
    119     Get the path to the JAR file where the plugin class is located. If the
    120     value is null the plugin must be in the classpath.
     115  public static final int MAX_JARFILE_LENGTH = 255;
     116  private String jarFile;
     117  /**
     118    Get the file name of the JAR file where the plugin class is located.
     119    The JAR file must be located in the 'plugins.dir' folder specified
     120    in base.config. If the value is null the plugin must be in the
     121    classpath (eg. WEB-INF/lib).
    121122    @return The class name for this plugin
    122     @hibernate.property column="`jar_path`" type="text" not-null="false"
    123   */
    124   public String getJarPath()
    125   {
    126     return jarPath;
    127   }
    128   public void setJarPath(String jarPath)
    129   {
    130     this.jarPath = jarPath;
     123    @hibernate.property column="`jar_file`" type="string" length="255" not-null="false"
     124    @since 3.0
     125  */
     126  public String getJarFile()
     127  {
     128    return jarFile;
     129  }
     130  public void setJarFile(String jarFile)
     131  {
     132    this.jarFile = jarFile;
    131133  }
    132134 
  • trunk/src/core/net/sf/basedb/util/AutoDetectFileFormat.java

    r5590 r5595  
    148148    try
    149149    {
    150       importer = plugin.newInstance(AutoDetectingImporter.class, null, sc, config, null);
     150      importer = plugin.newInstance(AutoDetectingImporter.class, sc, config, null);
    151151      boolean isInContext = true;
    152152      if (plugin.isInteractive() && context != null)
  • trunk/src/core/net/sf/basedb/util/ContextUtil.java

    r4594 r5595  
    149149      try
    150150      {
    151         ip = plugin.newInstance(InteractivePlugin.class, null, sc, config, null);
     151        ip = plugin.newInstance(InteractivePlugin.class, sc, config, null);
    152152        contextMessage = ip.isInContext(context, currentItem);
    153153      }
  • trunk/src/plugins/core/net/sf/basedb/plugins/executor/ExternalProgramExecutor.java

    r5574 r5595  
    3232import net.sf.basedb.core.ItemQuery;
    3333import net.sf.basedb.core.Job;
    34 import net.sf.basedb.core.JobAgent;
    35 import net.sf.basedb.core.JobAgentSettings;
    3634import net.sf.basedb.core.ParameterException;
    3735import net.sf.basedb.core.PermissionDeniedException;
     
    880878    SessionControl scWrapper = sc.getPluginSessionControl(plugin, currentJob);
    881879   
    882     String jarPath = null;
    883     if (runtime && currentJob != null)
    884     {
    885       try
    886       {
    887         JobAgent agent = currentJob.getJobAgent();
    888         if (agent != null)
    889         {
    890           JobAgentSettings settings = agent.getSettings(plugin, false);
    891           if (settings != null)
    892           {
    893             jarPath = settings.getJarPath();
    894           }
    895         }
    896       }
    897       catch (RuntimeException ex)
    898       {}
    899     }
    900     IOSupport ioSupport = plugin.newInstance(IOSupport.class, jarPath);
     880    IOSupport ioSupport = plugin.newInstance(IOSupport.class);
    901881    ioSupport.init(scWrapper, configWrapper, jobWrapper, this);
    902882    return ioSupport;   
     
    950930        {
    951931          Plugin.MainType pluginType = plugin.getMainType();
    952           IOSupport ioSupport = plugin.newInstance(IOSupport.class, null);
     932          IOSupport ioSupport = plugin.newInstance(IOSupport.class);
    953933          if (pluginType == Plugin.MainType.EXPORT)
    954934          {
  • trunk/src/test/TestJobAgent.java

    r5446 r5595  
    249249    if (!TestUtil.getSilent())
    250250    {
    251       System.out.println(i+":\t"+j.getId()+"\t"+j.getPluginDefinition()+"\t"+j.getJarPath()+"\t"+j.isTrusted()+"\t"+
     251      System.out.println(i+":\t"+j.getId()+"\t"+j.getPluginDefinition()+"\t"+j.isTrusted()+"\t"+
    252252          j.getMaxMemory()+"\t"+j.getPriorityBoost());
    253253    }
  • trunk/src/test/TestUtil.java

    r5362 r5595  
    151151    try
    152152    {
     153      Config.setProperty("plugins.dir", System.getProperty("user.dir"));
    153154      showDbInfo();
    154155      Application.start(false);
  • trunk/www/admin/jobagents/edit_agent.jsp

    r5508 r5595  
    138138          if (settings)
    139139          {
    140             if (!settings.useDefaultJarPath)
    141             {
    142               Forms.createHidden(frm, 'jarPath.'+pluginId, settings.jarPath);
    143             }
    144140            if (!settings.useDefaultMaxMemory)
    145141            {
     
    191187        {
    192188          // Default settings
    193           String defaultJarPath = plugin.getJarPath();
    194189          boolean defaultTrusted = plugin.isTrusted();
    195190          Long defaultMaxMemory = plugin.getMaxMemory();
     
    197192          // Specific settings
    198193          JobAgentSettings settings = agent == null ? null : agent.getSettings(plugin, false);
    199           String jarPath = null;
    200194          Boolean trusted = null;
    201195          Long maxMemory = null;
     
    203197          if (settings != null)
    204198          {
    205             jarPath = settings.getJarPath();
    206199            trusted = settings.isTrusted();
    207200            maxMemory = settings.getMaxMemory();
     
    212205          }
    213206          %>
    214           new PluginSetting(<%=plugin.getId()%>, '<%=HTML.javaScriptEncode(jarPath)%>', '<%=HTML.javaScriptEncode(defaultJarPath)%>', '<%=trusted == null ? "" : trusted ? "1" : "0"%>', '<%=defaultTrusted ? "1" : "0"%>', '<%=Values.formatBytes(maxMemory)%>', '<%=Values.formatBytes(defaultMaxMemory)%>', '<%=priorityBoost%>');
     207          new PluginSetting(<%=plugin.getId()%>, '<%=trusted == null ? "" : trusted ? "1" : "0"%>', '<%=defaultTrusted ? "1" : "0"%>', '<%=Values.formatBytes(maxMemory)%>', '<%=Values.formatBytes(defaultMaxMemory)%>', '<%=priorityBoost%>');
    215208          <%
    216209        }
     
    266259        Main.show('pluginsettings');
    267260        selectedPluginId = pluginId;
    268         // Set JAR path
    269         frm.useDefaultJarPath.checked = settings.useDefaultJarPath;
    270         useDefaultJarPathOnClick();
    271         var defaultJarPath = document.getElementById("defaultJarPath");
    272         var html = settings.defaultJarPath;
    273         if (html.length > 50)
    274         {
    275           html = '<span title="'+html+'">'+Main.cutString(html, 50)+'</span>'; 
    276         }
    277         defaultJarPath.innerHTML = html;
    278        
    279261        // Set max memory
    280262        frm.useDefaultMaxMemory.checked = settings.useDefaultMaxMemory;
     
    314296    }
    315297   
    316     function useDefaultJarPathOnClick()
    317     {
    318       var frm = document.forms['agent'];
    319       var settings = getPluginSettings(selectedPluginId);
    320       if (settings)
    321       {
    322         var useDefault = frm.useDefaultJarPath.checked;
    323         settings.useDefaultJarPath = useDefault;
    324         frm.jarPath.disabled = useDefault;
    325         if (!useDefault)
    326         {
    327           frm.jarPath.focus();
    328           frm.jarPath.value = settings.jarPath;
    329         }
    330       }
    331     }
    332    
    333     function jarPathOnBlur()
    334     {
    335       var frm = document.forms['agent'];
    336       var settings = getPluginSettings(selectedPluginId);
    337       if (settings)
    338       {
    339         settings.jarPath = frm.jarPath.value;
    340       }
    341     }
    342    
    343298    function useDefaultMaxMemoryOnClick()
    344299    {
     
    390345   
    391346    var allPluginSettings = new Array();
    392     function PluginSetting(pluginId, jarPath, defaultJarPath, trusted, defaultTrusted,
    393       maxMemory, defaultMaxMemory, priorityBoost)
     347    function PluginSetting(pluginId, trusted, defaultTrusted, maxMemory, defaultMaxMemory, priorityBoost)
    394348    {
    395349      this.pluginId = pluginId;
    396       this.jarPath = jarPath;
    397       this.defaultJarPath = defaultJarPath == '' ? 'internal' : defaultJarPath;
    398       this.useDefaultJarPath = (jarPath == '');
    399350      this.trusted = trusted;
    400351      this.defaultTrusted = defaultTrusted;
     
    492443        <table border="0" cellspacing="0" class="form">
    493444        <tr>
    494           <td class="prompt">Jar path</td>
    495           <td>
    496             <input type="text" name="jarPath" class="text" size="50"
    497               maxlength="<%=JobAgentSettings.MAX_JARPATH_LENGTH%>"
    498               onblur="jarPathOnBlur()">
    499           </td>
    500         </tr>
    501         <tr>
    502           <td style="padding-left: 10px;">-use default</td>
    503           <td>
    504             <input type="checkbox" name="useDefaultJarPath"
    505               onclick="useDefaultJarPathOnClick()">
    506             (<span id="defaultJarPath"></span>)
    507           </td>
    508         </tr>
    509         <tr>
    510445          <td class="prompt">Max memory</td>
    511446          <td>
  • trunk/www/admin/jobagents/index.jsp

    r5590 r5595  
    188188            dc.reattachItem(settings, false);
    189189          }
    190           settings.setJarPath(Values.getStringOrNull(request.getParameter("jarPath."+pluginId)));
     190          //settings.setJarPath(Values.getStringOrNull(request.getParameter("jarPath."+pluginId)));
    191191          settings.setMaxMemory(Values.parseBytes(request.getParameter("maxMemory."+pluginId), null));
    192192          settings.setPriorityBoost(Values.getInt(request.getParameter("priorityBoost."+pluginId)));
  • trunk/www/admin/jobagents/view_agent.jsp

    r5509 r5595  
    351351          />
    352352          <tbl:columndef
    353             id="jarPath"
    354             title="JAR path"
    355           />
    356           <tbl:columndef
    357353            id="trusted"
    358354            title="Trusted"
     
    390386              }
    391387              Long maxMemory = settings.getEffectiveMaxMemory();
    392               String jarPath = settings.getEffectiveJarPath();
    393388              %>
    394389              <tbl:row>
     
    398393                    visible="<%=plugin != null && plugin.isRemoved()%>"
    399394                  /><%=Base.getLinkedName(ID, nameableProxy, !readPlugin, true)%></tbl:cell>
    400                 <tbl:cell column="jarPath"><%=jarPath == null ? "<i>- internal -</i>" : HTML.encodeTags(jarPath)%></tbl:cell>
    401395                <tbl:cell column="trusted"><%=settings.isEffectivelyTrusted()%></tbl:cell>
    402396                <tbl:cell column="maxMemory"><%=maxMemory == null ? "<i>- not specified -</i>" : Values.formatBytes(maxMemory)%></tbl:cell>
  • trunk/www/admin/plugindefinitions/auto_install.jsp

    r5426 r5595  
    280280  boolean usePermissions = up == null ? false : Values.getBoolean(up);
    281281  Boolean allowImmediateExecution = aie == null ? null : Values.getBoolean(aie);
    282   boolean scanPluginDir = Values.getBoolean(request.getParameter("plugindir"));
    283   boolean scanExtensionsDir = Values.getBoolean(request.getParameter("extensionsdir"));
    284282 
    285   java.io.File pluginDir = Application.getNonCorePluginDirectory();
    286   java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
     283  java.io.File pluginDir = Application.getPluginsDirectory();
    287284  Tree<Object> plugins = new Tree<Object>(null);
    288   if (scanPluginDir) addDirectory(dc, plugins, pluginDir);
    289   if (scanExtensionsDir) addDirectory(dc, plugins, extensionsDir);
     285  addDirectory(dc, plugins, pluginDir);
    290286  %>
    291287  <base:page type="popup" title="<%=title%>">
     
    457453    <input type="hidden" name="ID" value="<%=ID%>">
    458454    <input type="hidden" name="cmd" value="LoadPlugins">
    459     <input type="hidden" name="plugindir" value="<%=scanPluginDir ? "1" : "0"%>">
    460     <input type="hidden" name="extensionsdir" value="<%=scanExtensionsDir ? "1" : "0"%>">
    461455   
    462456    <h3 class="docked"><%=title%> <base:help tabcontrol="plugins" /></h3>
  • trunk/www/admin/plugindefinitions/edit_plugin.jsp

    r5508 r5595  
    163163    try
    164164    {
    165       Plugin thePlugin = plugin.newInstance(Plugin.class, null, sc, null, null);
     165      Plugin thePlugin = plugin.newInstance(Plugin.class, sc, null, null);
    166166      requestedPermissions = thePlugin.getPermissions();
    167167    }
     
    314314          // Agent specific settings
    315315          JobAgentSettings settings = agent.getSettings(plugin, false);
    316           String jarPath = null;
    317316          Boolean trusted = null;
    318317          Long maxMemory = null;
     
    320319          if (settings != null)
    321320          {
    322             jarPath = settings.getJarPath();
    323321            trusted = settings.isTrusted();
    324322            maxMemory = settings.getMaxMemory();
     
    329327          }
    330328          %>
    331           new AgentSetting(<%=agent.getId()%>, '<%=HTML.javaScriptEncode(jarPath)%>', '<%=trusted == null ? "" : trusted ? "1" : "0"%>', '<%=Values.formatBytes(maxMemory)%>', '<%=priorityBoost%>');
     329          new AgentSetting(<%=agent.getId()%>, '<%=trusted == null ? "" : trusted ? "1" : "0"%>', '<%=Values.formatBytes(maxMemory)%>', '<%=priorityBoost%>');
    332330          <%
    333331        }
     
    355353    }
    356354    var allAgentSettings = new Array();
    357     function AgentSetting(agentId, jarPath, trusted, maxMemory, priorityBoost)
     355    function AgentSetting(agentId, trusted, maxMemory, priorityBoost)
    358356    {
    359357      this.agentId = agentId;
    360       this.jarPath = jarPath;
    361       this.useDefaultJarPath = (jarPath == '');
    362358      this.trusted = trusted;
    363359      this.useDefaultTrusted = trusted != null;
     
    378374        Main.show('agentsettings');
    379375        selectedAgentId = agentId;
    380         // Set JAR path
    381         frm.useDefaultJarPath.checked = settings.useDefaultJarPath;
    382         useDefaultJarPathOnClick();
    383         var defaultJarPath = document.getElementById("defaultJarPath");
    384         var html = frm.jarPath.value;
    385         if (html.length > 50)
    386         {
    387           html = '<span title="'+html+'">'+Main.cutString(html, 50)+'</span>'; 
    388         }
    389         if (html == '') html = 'internal';
    390         defaultJarPath.innerHTML = html;
    391376       
    392377        // Set max memory
     
    407392      {
    408393        Main.hide('agentsettings');
    409       }
    410     }
    411    
    412     function useDefaultJarPathOnClick()
    413     {
    414       var frm = document.forms['plugin'];
    415       var settings = getAgentSettings(selectedAgentId);
    416       if (settings)
    417       {
    418         var useDefault = frm.useDefaultJarPath.checked;
    419         settings.useDefaultJarPath = useDefault;
    420         frm.agentJarPath.disabled = useDefault;
    421         if (!useDefault)
    422         {
    423           frm.agentJarPath.focus();
    424           frm.agentJarPath.value = settings.jarPath;
    425         }
    426       }
    427     }
    428    
    429     function jarPathOnBlur()
    430     {
    431       var frm = document.forms['plugin'];
    432       var settings = getAgentSettings(selectedAgentId);
    433       if (settings)
    434       {
    435         settings.jarPath = frm.agentJarPath.value;
    436394      }
    437395    }
     
    763721     
    764722      <tr>
    765         <td class="prompt">Path</td>
    766         <td><input <%=clazz%> type="text" name="jarPath"
    767           value="<%=HTML.encodeTags(plugin == null ? cc.getPropertyValue("jarPath") : plugin.getJarPath())%>"
    768           size="50" maxlength="<%=PluginDefinition.MAX_JARPATH_LENGTH%>">
     723        <td class="prompt">JAR file</td>
     724        <td><input <%=clazz%> type="text" name="jarFile"
     725          value="<%=HTML.encodeTags(plugin == null ? cc.getPropertyValue("jarFile") : plugin.getJarFile())%>"
     726          size="50" maxlength="<%=PluginDefinition.MAX_JARFILE_LENGTH%>">
    769727        </td>
    770728      </tr>
     
    977935        <b>Settings for the selected job agent</b>
    978936        <table border="0" cellspacing="0" class="form">
    979         <tr>
    980           <td class="prompt">Jar path</td>
    981           <td>
    982             <input type="text" name="agentJarPath" class="text" size="50"
    983               maxlength="<%=JobAgentSettings.MAX_JARPATH_LENGTH%>"
    984               onblur="jarPathOnBlur()">
    985           </td>
    986         </tr>
    987         <tr>
    988           <td style="padding-left: 10px;">-use default</td>
    989           <td>
    990             <input type="checkbox" name="useDefaultJarPath"
    991               onclick="useDefaultJarPathOnClick()">
    992             (<span id="defaultJarPath"></span>)
    993           </td>
    994         </tr>
    995937        <tr>
    996938          <td class="prompt">Max memory</td>
  • trunk/www/admin/plugindefinitions/index.jsp

    r5590 r5595  
    187187    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
    188188    dc = sc.newDbControl();
    189     java.io.File pluginDir = Application.getNonCorePluginDirectory();
    190     java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
     189    java.io.File pluginDir = Application.getPluginsDirectory();
    191190    FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
    192191    List<java.io.File> jarFiles = new LinkedList<java.io.File>();
    193     if (Values.getBoolean(request.getParameter("plugindir")))
    194     {
    195       jarFiles.addAll(FileUtil.findFiles(pluginDir, jarFilter));
    196     }
    197     if (Values.getBoolean(request.getParameter("extensionsdir")))
    198     {
    199       jarFiles.addAll(FileUtil.findFiles(extensionsDir, jarFilter));
    200     }
    201    
     192    jarFiles.addAll(FileUtil.findFiles(pluginDir, jarFilter));
     193       
    202194    List<PluginInfo> pluginInfos = new LinkedList<PluginInfo>();
    203195    Map<PluginInfo, Throwable> installationResult = new LinkedHashMap<PluginInfo, Throwable>();
     
    311303    PluginDefinition plugin = (PluginDefinition)cc.getObject("item");
    312304    String className = Values.getStringOrNull(request.getParameter("className"));
    313     String jarPath = Values.getStringOrNull(request.getParameter("jarPath"));
     305    String jarFile = Values.getStringOrNull(request.getParameter("jarFile"));
    314306    int usePermissions = Values.getInt(request.getParameter("use_permissions"));
    315307    if (plugin == null)
    316308    {
    317       plugin = PluginDefinition.getNew(dc, className, jarPath, usePermissions == 2);
     309      plugin = PluginDefinition.getNew(dc, className, jarFile, usePermissions == 2);
    318310      message = "Plugin created";
    319311      dc.saveItem(plugin);
     
    322314    {
    323315      dc.reattachItem(plugin, false);
    324       plugin.loadPluginInformation(jarPath, className, usePermissions == 2);
     316      plugin.loadPluginInformation(jarFile, className, usePermissions == 2);
    325317      message = "Plugin updated";
    326318    }
     
    378370            dc.reattachItem(settings, false);
    379371          }
    380           settings.setJarPath(Values.getStringOrNull(request.getParameter("jarPath."+agentId)));
     372          //settings.setJarPath(Values.getStringOrNull(request.getParameter("jarPath."+agentId)));
    381373          settings.setMaxMemory(Values.parseBytes(request.getParameter("maxMemory."+agentId), null));
    382374          settings.setPriorityBoost(Values.getInt(request.getParameter("priorityBoost."+agentId)));
  • trunk/www/admin/plugindefinitions/list_plugins.jsp

    r5426 r5595  
    311311      />
    312312      <tbl:columndef
    313         id="jarPath"
    314         property="jarPath"
    315         datatype="string"
    316         title="Path"
     313        id="jarFile"
     314        property="jarFile"
     315        datatype="string"
     316        title="JAR file"
    317317        sortable="true"
    318318        filterable="true"
     
    663663                <tbl:cell column="pluginType"><%=item.getMainType()%></tbl:cell>
    664664                <tbl:cell column="className"><%=item.getClassName()%></tbl:cell>
    665                 <tbl:cell column="jarPath"><%=Values.getString(item.getJarPath(), "<i>-&nbsp;internal&nbsp;-</i>")%></tbl:cell>
     665                <tbl:cell column="jarFile"><%=Values.getString(item.getJarFile(), "<i>-&nbsp;internal&nbsp;-</i>")%></tbl:cell>
    666666                <tbl:cell column="version"><%=HTML.encodeTags(item.getVersionString())%></tbl:cell>
    667667                <tbl:cell column="configurations">
  • trunk/www/admin/plugindefinitions/select_installation_type.jsp

    r5426 r5595  
    4444
    4545String title = "Installation type";
    46 java.io.File pluginDir = Application.getNonCorePluginDirectory();
    47 boolean pluginDirEnabled = pluginDir != null && pluginDir.exists();
    48 
    49 java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
    50 boolean extensionsDirEnabled = extensionsDir != null && extensionsDir.exists();
     46java.io.File pluginDir = Application.getPluginsDirectory();
    5147
    5248try
     
    124120        <td class="prompt">Directories</td>
    125121        <td>
    126           <input type="checkbox" name="plugindir" checked value="1"
    127             <%=pluginDirEnabled ? "" : "disabled" %>
    128             >Dedicated plug-ins directory (<%=pluginDir%>)<br>
    129           <input type="checkbox" name="extensionsdir" checked value="1"
    130             <%=extensionsDirEnabled ? "" : "disabled" %>
    131             >Extensions directory (<%=extensionsDir%>)
     122          <input type="checkbox" name="plugindir" checked value="1">Dedicated plug-ins directory (<%=pluginDir%>)<br>
     123         
    132124        </td>
    133125      </tr>       
  • trunk/www/admin/plugindefinitions/view_plugin.jsp

    r5509 r5595  
    109109  String warning = null;
    110110  PluginDefinition plugin = PluginDefinition.getById(dc, itemId);
    111   final boolean internal = plugin.getJarPath() == null;
     111  final boolean internal = plugin.getJarFile() == null;
    112112  final boolean loaded = internal || JarClassLoader.exists(plugin.getJarPath());
    113113  final boolean usePermissions = plugin.getUsePermissions();
     
    127127  try
    128128  {
    129     Plugin thePlugin = plugin.newInstance(Plugin.class, null, sc, null, null);
     129    Plugin thePlugin = plugin.newInstance(Plugin.class, sc, null, null);
    130130  }
    131   catch (BaseException ex)
     131  catch (RuntimeException ex)
    132132  {
    133133    warning = ex.getMessage();
     
    335335      </tr>
    336336      <tr>
    337         <td class="prompt">Jar path</td>
    338         <td><%=plugin.getJarPath() == null ? "<i>- internal -</i>" : plugin.getJarPath()%></td>
     337        <td class="prompt">JAR file</td>
     338        <td><%=internal ? "<i>- internal -</i>" : plugin.getJarFile()%></td>
    339339      </tr>
    340340      <tr>
     
    509509          />
    510510          <tbl:columndef
    511             id="jarPath"
    512             title="JAR path"
    513           />
    514           <tbl:columndef
    515511            id="maxMemory"
    516512            title="Max memory"
     
    539535              JobAgentSettings settings = agent.getSettings(plugin, false);
    540536              Long maxMemory = settings.getEffectiveMaxMemory();
    541               String jarPath = settings.getEffectiveJarPath();
    542537              %>
    543538              <tbl:row>
     
    553548                  Used memory: <%=agent.getUsedMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(agent.getUsedMemory()) %>
    554549                </tbl:cell>
    555                 <tbl:cell column="jarPath"><%=jarPath == null ? "<i>- internal -</i>" : HTML.encodeTags(jarPath)%></tbl:cell>
    556550                <tbl:cell column="maxMemory"><%=maxMemory == null ? "<i>- not specified -</i>" : Values.formatBytes(maxMemory)%></tbl:cell>
    557551                <tbl:cell column="trusted"><%=settings.isEffectivelyTrusted()%></tbl:cell>
  • trunk/www/filemanager/upload/select.jsp

    r5570 r5595  
    279279      for (PluginDefinition plugin : plugins)
    280280      {
    281         FileUnpacker unpacker = plugin.newInstance(FileUnpacker.class, null, sc, null, null);
     281        FileUnpacker unpacker = plugin.newInstance(FileUnpacker.class, sc, null, null);
    282282        %>
    283283          var extensions = [ '<%=Values.getString(unpacker.getExtensions(), "','", true)%>' ];
Note: See TracChangeset for help on using the changeset viewer.