Changeset 3781


Ignore:
Timestamp:
Sep 25, 2007, 1:47:16 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #780: ParameterValuesImpl? doesn't implement ParameterValues? as specified

Location:
branches/2.4-stable/src/core/net/sf/basedb/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4-stable/src/core/net/sf/basedb/core/Job.java

    r3679 r3781  
    997997    throws InvalidDataException, PermissionDeniedException, BaseException
    998998  {
     999    checkPermission(Permission.WRITE);
     1000    if (name == null) throw new InvalidUseOfNullException("name");
    9991001    if (getStatus() == Status.EXECUTING)
    10001002    {
     
    10021004    }
    10031005    getData().setStatus(Status.WAITING.getValue());
    1004     setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value));
     1006    setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value), true);
    10051007  }
    10061008 
     
    10461048    throws InvalidDataException, PermissionDeniedException, BaseException
    10471049  {
     1050    checkPermission(Permission.WRITE);
     1051    if (name == null) throw new InvalidUseOfNullException("name");
    10481052    if (getStatus() == Status.EXECUTING)
    10491053    {
     
    10511055    }
    10521056    getData().setStatus(Status.WAITING.getValue());
    1053     setParameterValuesInternal(name, label, description, parameterType, values);
     1057    setParameterValuesInternal(name, label, description, parameterType, values, true);
    10541058  }
    10551059 
     
    11111115    @param values A list containing the new values, null or empty to remove the
    11121116      configuration values
     1117    @param validate If validation by {@link ParameterType#validate(String, List)}
     1118      is needed or not
    11131119    @throws PermissionDeniedException If the logged in user doesn't have
    11141120      write permission
     
    11171123    @throws BaseException If there is another error
    11181124  */
    1119   void setParameterValuesInternal(String name, String label, String description, ParameterType<?> parameterType, List<?> values)
     1125  void setParameterValuesInternal(String name, String label, String description,
     1126    ParameterType<?> parameterType, List<?> values, boolean validate)
    11201127    throws InvalidDataException, PermissionDeniedException, BaseException
    11211128  {
    1122     checkPermission(Permission.WRITE);
    1123     if (name == null) throw new InvalidUseOfNullException("name");
    11241129    ParameterValueData old = null;
    11251130    if (values == null || values.size() == 0)
     
    11301135    {
    11311136      if (parameterType == null) throw new InvalidUseOfNullException("parameterType");
    1132       parameterType.validate(name, values);
     1137      if (validate) parameterType.validate(name, values);
    11331138      ParameterValueData<?> parameterValue = parameterType.newParameterValueData();
    11341139      parameterValue.setLabel(label);
  • branches/2.4-stable/src/core/net/sf/basedb/core/ParameterValuesImpl.java

    r3679 r3781  
    161161    if (writeProtected)
    162162    {
    163       throw new PermissionDeniedException(Permission.WRITE, "Job parameter: "+name);
    164     }
     163      throw new PermissionDeniedException(Permission.WRITE, "Parameter: "+name);
     164    }
     165    if (name == null) throw new InvalidUseOfNullException("name");
     166    if (type == null) throw new InvalidUseOfNullException("type[name=" + name + "]");
    165167    if (value == null && type.getNotNull()) value = type.getDefaultValue();
     168    type.validate(name, value);
    166169    List<T> l = new ArrayList<T>(1);
    167170    l.add(value);
     
    176179    if (writeProtected)
    177180    {
    178       throw new PermissionDeniedException(Permission.WRITE, "Job parameter: "+name);
    179     }
     181      throw new PermissionDeniedException(Permission.WRITE, "Parameter: "+name);
     182    }
     183    if (name == null) throw new InvalidUseOfNullException("name");
     184    if (type == null) throw new InvalidUseOfNullException("type[name=" + name + "]");
    180185    if ((values == null || values.size() == 0) && type.getNotNull() && type.getDefaultValue() != null)
    181186    {
    182187      values = Arrays.asList(type.getDefaultValue());
    183188    }
     189    type.validate(name, values);
    184190    parameters.put(name, values);
    185191    parameterTypes.put(name, type);
     
    203209      if (pp == null)
    204210      {
    205         job.setParameterValuesInternal(name, null, null, parameterTypes.get(name), parameters.get(name));
     211        job.setParameterValuesInternal(name, null, null,
     212          parameterTypes.get(name), parameters.get(name), false);
    206213      }
    207214      else
    208215      {
    209         job.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(), parameterTypes.get(name), parameters.get(name));
     216        job.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(),
     217          parameterTypes.get(name), parameters.get(name), false);
    210218      }
    211219    }
     
    223231      if (pp == null)
    224232      {
    225         config.setParameterValues(name, null, null, parameterTypes.get(name), parameters.get(name));
     233        config.setParameterValuesInternal(name, null, null,
     234          parameterTypes.get(name), parameters.get(name), false);
    226235      }
    227236      else
    228237      {
    229         config.setParameterValues(name, pp.getLabel(), pp.getDescription(), parameterTypes.get(name), parameters.get(name));
     238        config.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(),
     239          parameterTypes.get(name), parameters.get(name), false);
    230240      }
    231241    }
  • branches/2.4-stable/src/core/net/sf/basedb/core/PluginConfiguration.java

    r3745 r3781  
    428428    checkPermission(Permission.WRITE);
    429429    if (name == null) throw new InvalidUseOfNullException("name");
    430    
     430    setParameterValuesInternal(name, label, description, parameterType, values, true);
     431  }
     432
     433  /**
     434    Set the values of a configuration parameter.
     435    @param name The name of the configuration parameter
     436    @param label The label of the parameter (optional)
     437    @param description A description of the parameter (optional)
     438    @param parameterType The type of the parameter
     439    @param values A list containing the new values, null or empty to remove the
     440      configuration values
     441    @param validate If validation by {@link ParameterType#validate(String, List)}
     442      is needed or not
     443    @throws PermissionDeniedException If the logged in user doesn't have
     444      write permission
     445    @throws InvalidDataException If name is null or the new value doesn't
     446      validate against the parameter type
     447    @throws BaseException If there is another error
     448  */
     449  void setParameterValuesInternal(String name, String label, String description,
     450    ParameterType<?> parameterType, List<?> values, boolean validate)
     451    throws InvalidDataException, PermissionDeniedException, BaseException
     452  {
     453
    431454    VersionedParameter param = new VersionedParameter(name, getNewParameterVersion());
    432    
    433455    if (values == null || values.size() == 0)
    434456    {
     
    438460    {
    439461      if (parameterType == null) throw new InvalidUseOfNullException("parameterType");
    440       parameterType.validate(name, values);
     462      if (validate) parameterType.validate(name, values);
    441463      ParameterValueData<?> parameterValue = parameterType.newParameterValueData();
    442464      parameterValue.setLabel(label);
     
    446468    }
    447469  }
    448 
     470 
    449471  /**
    450472    Copy all parameter values from another plugin configuration. This method
Note: See TracChangeset for help on using the changeset viewer.