Changeset 6988


Ignore:
Timestamp:
Oct 30, 2015, 10:31:37 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1959: Add support for password-type parameters to plug-ins

This information is now stored in the database using the ParameterValueData class. The masked flag can be checked by calling Job.getParameterInfo() and then use ParameterInfo.getValuesOrMask() when the parameter values are used for display.

The changes do no affect any other methods so even masked values should be available as before in places which use the values for other things than display purposes.

Location:
trunk
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Install.java

    r6941 r6988  
    118118    method.
    119119  */
    120   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(126).intValue();
     120  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(127).intValue();
    121121 
    122122  public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress,
  • trunk/src/core/net/sf/basedb/core/Job.java

    r6898 r6988  
    16591659      parameterValue.setLabel(label);
    16601660      parameterValue.setDescription(description);
     1661      parameterValue.setMasked(parameterType.isMasked());
    16611662      parameterValue.replaceValues(Values.getDataValues(values));
    16621663      old = getData().getParameters().put(name, parameterValue);
  • trunk/src/core/net/sf/basedb/core/ParameterInfo.java

    r6875 r6988  
    3939  private final String label;
    4040  private final String description;
     41  private final boolean masked;
    4142  private final List<?> values;
    4243  private final Type valueType;
     
    4647    this.label = parameter.getLabel();
    4748    this.description = parameter.getDescription();
     49    this.masked = parameter.isMasked();
    4850    this.valueType = parameter.getValueType() == 0 ? null : Type.fromValue(parameter.getValueType());
    4951    this.values = Collections.unmodifiableList(Values.getItemValues(dc, parameter.getValues()));
     
    5860  {
    5961    return description;
     62  }
     63 
     64  /**
     65    Should this parameter be masked in the GUI?
     66    @since 3.7
     67  */
     68  public boolean isMasked()
     69  {
     70    return masked;
    6071  }
    6172 
     
    7788  }
    7889 
     90  /**
     91    Utility method for getting the values or a mask (*****)
     92    if the {@link #isMasked()} flag is set.
     93    @since 3.7
     94  */
     95  public List<?> getValuesOrMask()
     96  {
     97    return getValuesOrMask("********");
     98  }
     99 
     100  /**
     101    Utility method for getting the values or a mask
     102    if the {@link #isMasked()} flag is set.
     103    @since 3.7
     104  */
     105  public List<?> getValuesOrMask(String mask)
     106  {
     107    return isMasked() ? Collections.singletonList(mask) : getValues();
     108  }
     109 
    79110}
  • trunk/src/core/net/sf/basedb/core/Update.java

    r6981 r6988  
    5454import net.sf.basedb.core.data.JobData;
    5555import net.sf.basedb.core.data.MeasuredBioMaterialData;
     56import net.sf.basedb.core.data.ParameterValueData;
    5657import net.sf.basedb.core.data.PropertyFilterData;
    5758import net.sf.basedb.core.data.QuantityData;
     
    277278    </td>
    278279  </tr>
     280  <tr>
     281    <td>127</td>
     282    <td>
     283      Added {@link ParameterValueData#isMasked()}. All existing parameters
     284      are set to false.
     285    </td>
     286  </tr>
    279287  </table>
    280288
     
    451459        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 126...");
    452460        schemaVersion = updateToSchemaVersion126(session);
     461        progress_current += progress_step;
     462      }
     463     
     464      if (schemaVersion < 127)
     465      {
     466        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 127...");
     467        // Schemaversion 127 only updates the version number
     468        schemaVersion = setSchemaVersionInTransaction(session, 127);
    453469        progress_current += progress_step;
    454470      }
  • trunk/src/core/net/sf/basedb/core/data/ParameterValueData.java

    r6913 r6988  
    9494  }
    9595 
     96  private boolean masked;
     97  /**
     98    A flag indicating if the value should be masked when
     99    displayed in client applications (eg. since it may be a password)
     100   
     101    NOTE! This property is mapped in hibernate-properties-ParameterValueData.xml since
     102    'default' is not supported by XDoclet
     103    //hibernate.property type="boolean"
     104    //hibernate.column name="`masked`" type="boolean" not-null="true" default="false"
     105
     106    @since 3.7
     107  */
     108  public boolean isMasked()
     109  {
     110    return masked;
     111  }
     112  public void setMasked(boolean masked)
     113  {
     114    this.masked = masked;
     115  }
     116 
    96117  /**
    97118    Get the type of parameter values that are store in this parameter.
  • trunk/src/test/TestJob.java

    r6875 r6988  
    342342      {
    343343        ParameterInfo pi = job.getParameterInfo(name);
    344         System.out.println((pi.getLabel() == null ? name : pi.getLabel()) + "=" + pi.getValues());
     344        System.out.println((pi.getLabel() == null ? name : pi.getLabel()) + "=" + pi.getValuesOrMask());
    345345      }
    346346    }
  • trunk/src/test/TestPluginConfiguration.java

    r5340 r6988  
    279279      {
    280280        ParameterInfo pi = pc.getParameterInfo(name);
    281         System.out.println((pi.getLabel() == null ? name : pi.getLabel()) + "=" + pi.getValues());
     281        System.out.println((pi.getLabel() == null ? name : pi.getLabel()) + "=" + pi.getValuesOrMask());
    282282      }
    283283    }
  • trunk/www/admin/pluginconfigurations/view_configuration.jsp

    r6605 r6988  
    318318                  if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    319319                  description = HTML.encodeTags(pi.getDescription());
    320                   List<?> values = pi.getValues();
     320                  List<?> values = pi.getValuesOrMask();
    321321                  int i = 0;
    322322                  for (Object value : values)
  • trunk/www/views/derivedbioassays/view_bioassay.jsp

    r6605 r6988  
    380380              if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    381381              description = HTML.encodeTags(pi.getDescription());
    382               List<?> values = pi.getValues();
     382              List<?> values = pi.getValuesOrMask();
    383383              int i = 0;
    384384              for (Object value : values)
  • trunk/www/views/experiments/bioassaysets/view_bioassayset.jsp

    r6612 r6988  
    390390              if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    391391              description = HTML.encodeTags(pi.getDescription());
    392               List<?> values = pi.getValues();
     392              List<?> values = pi.getValuesOrMask();
    393393              int i = 0;
    394394              for (Object value : values)
  • trunk/www/views/experiments/extravalues/view_extravalue.jsp

    r6605 r6988  
    328328              if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    329329              description = HTML.encodeTags(pi.getDescription());
    330               List<?> values = pi.getValues();
     330              List<?> values = pi.getValuesOrMask();
    331331              int i = 0;
    332332              for (Object value : values)
  • trunk/www/views/experiments/transformations/view_transformation.jsp

    r6605 r6988  
    324324              if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    325325              description = HTML.encodeTags(pi.getDescription());
    326               List<?> values = pi.getValues();
     326              List<?> values = pi.getValuesOrMask();
    327327              int i = 0;
    328328              for (Object value : values)
  • trunk/www/views/jobs/view_job.jsp

    r6954 r6988  
    422422            if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    423423            description = HTML.encodeTags(pi.getDescription());
    424             List<?> values = pi.getValues();
     424            List<?> values = pi.getValuesOrMask();
    425425            int i = 0;
    426426            for (Object value : values)
     
    505505              if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
    506506              description = HTML.encodeTags(pi.getDescription());
    507               List<?> values = pi.getValues();
     507              List<?> values = pi.getValuesOrMask();
    508508              int i = 0;
    509509              for (Object value : values)
Note: See TracChangeset for help on using the changeset viewer.