Changeset 3781
- Timestamp:
- Sep 25, 2007, 1:47:16 PM (15 years ago)
- 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 997 997 throws InvalidDataException, PermissionDeniedException, BaseException 998 998 { 999 checkPermission(Permission.WRITE); 1000 if (name == null) throw new InvalidUseOfNullException("name"); 999 1001 if (getStatus() == Status.EXECUTING) 1000 1002 { … … 1002 1004 } 1003 1005 getData().setStatus(Status.WAITING.getValue()); 1004 setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value) );1006 setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value), true); 1005 1007 } 1006 1008 … … 1046 1048 throws InvalidDataException, PermissionDeniedException, BaseException 1047 1049 { 1050 checkPermission(Permission.WRITE); 1051 if (name == null) throw new InvalidUseOfNullException("name"); 1048 1052 if (getStatus() == Status.EXECUTING) 1049 1053 { … … 1051 1055 } 1052 1056 getData().setStatus(Status.WAITING.getValue()); 1053 setParameterValuesInternal(name, label, description, parameterType, values );1057 setParameterValuesInternal(name, label, description, parameterType, values, true); 1054 1058 } 1055 1059 … … 1111 1115 @param values A list containing the new values, null or empty to remove the 1112 1116 configuration values 1117 @param validate If validation by {@link ParameterType#validate(String, List)} 1118 is needed or not 1113 1119 @throws PermissionDeniedException If the logged in user doesn't have 1114 1120 write permission … … 1117 1123 @throws BaseException If there is another error 1118 1124 */ 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) 1120 1127 throws InvalidDataException, PermissionDeniedException, BaseException 1121 1128 { 1122 checkPermission(Permission.WRITE);1123 if (name == null) throw new InvalidUseOfNullException("name");1124 1129 ParameterValueData old = null; 1125 1130 if (values == null || values.size() == 0) … … 1130 1135 { 1131 1136 if (parameterType == null) throw new InvalidUseOfNullException("parameterType"); 1132 parameterType.validate(name, values);1137 if (validate) parameterType.validate(name, values); 1133 1138 ParameterValueData<?> parameterValue = parameterType.newParameterValueData(); 1134 1139 parameterValue.setLabel(label); -
branches/2.4-stable/src/core/net/sf/basedb/core/ParameterValuesImpl.java
r3679 r3781 161 161 if (writeProtected) 162 162 { 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 + "]"); 165 167 if (value == null && type.getNotNull()) value = type.getDefaultValue(); 168 type.validate(name, value); 166 169 List<T> l = new ArrayList<T>(1); 167 170 l.add(value); … … 176 179 if (writeProtected) 177 180 { 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 + "]"); 180 185 if ((values == null || values.size() == 0) && type.getNotNull() && type.getDefaultValue() != null) 181 186 { 182 187 values = Arrays.asList(type.getDefaultValue()); 183 188 } 189 type.validate(name, values); 184 190 parameters.put(name, values); 185 191 parameterTypes.put(name, type); … … 203 209 if (pp == null) 204 210 { 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); 206 213 } 207 214 else 208 215 { 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); 210 218 } 211 219 } … … 223 231 if (pp == null) 224 232 { 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); 226 235 } 227 236 else 228 237 { 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); 230 240 } 231 241 } -
branches/2.4-stable/src/core/net/sf/basedb/core/PluginConfiguration.java
r3745 r3781 428 428 checkPermission(Permission.WRITE); 429 429 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 431 454 VersionedParameter param = new VersionedParameter(name, getNewParameterVersion()); 432 433 455 if (values == null || values.size() == 0) 434 456 { … … 438 460 { 439 461 if (parameterType == null) throw new InvalidUseOfNullException("parameterType"); 440 parameterType.validate(name, values);462 if (validate) parameterType.validate(name, values); 441 463 ParameterValueData<?> parameterValue = parameterType.newParameterValueData(); 442 464 parameterValue.setLabel(label); … … 446 468 } 447 469 } 448 470 449 471 /** 450 472 Copy all parameter values from another plugin configuration. This method
Note: See TracChangeset
for help on using the changeset viewer.