org.hd.d.pg2k.svrCore.uploader
Class UploadInfoBean

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
      extended by org.hd.d.pg2k.svrCore.uploader.UploadInfoBean
All Implemented Interfaces:
java.io.Serializable

public final class UploadInfoBean
extends ExhibitHandlerBeanBase

Bean that collects information about an exhibit to upload. Backs upload.jsp and, unusally, is stored in the session as the author provides data about the exhibit.

This validates information its is presented with as far as possible, syntactically and semantically. For example, it tries to ensure that a correct and unique exhibit name is created, and warns if new (possibly-misspelt) words have been introduced.

This holds the filename and optional description, location, etc data, and output can be dumped as a new-style properties file.

This is thread-safe, all methods being synchronized where necessary.

In general, our upload process should observe the following:

See Also:
Serialized Form

Field Summary
private  java.lang.String description
          Description text or "" if none; never null.
private  java.lang.String mainWords
          Main body words; valid string of hyphen-separated words where; can be "" but never null.
private  int number
          The number in the current series; never negative.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
private  AllExhibitImmutableData uploadAeid
          Aeid for upload area; should be set.
 
Fields inherited from class org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
onlyAllowExtant, SETTER_ALL
 
Constructor Summary
UploadInfoBean()
          Create a new instance.
 
Method Summary
 boolean canMakeValidName()
          Returns true if we can construct a valid name.
 boolean enoughInfo()
          When enough exhibit information has been collected, this returns true.
 boolean enoughValidUniqueInfo()
          Returns true when we have enough, valid, unique info to save an exhibit.
 java.lang.String getDescription()
          Get description text or "" if none; never null.
 java.lang.String getFullName()
          Assemble complete name.
 java.lang.String getMainWords()
          Set main body words; valid string of hyphen-separated words where; can be "" but never null.
 java.lang.String getName(boolean fullName)
          Assemble complete name.
 java.lang.String getNewMainWords()
          Get main words that would be new to the Gallery: return the empty string "" if none.
 int getNumber()
          Gets number in series of exhibit; never negative.
 int incNumberIfNonZero()
          Increment number-in-series value iff already positive and returns new value; never negative.
private static java.lang.String makeValidWordString(java.lang.String in)
          Forces string to a superficially valid word string.
 boolean nameUniqueInAuxDatabase()
          Check if the name is unique against the upload data set.
 boolean nameUniqueInMainDatabase()
          Check if the name is unique against the production data set.
 void setDescription(java.lang.String description)
          Set description text or "" or "-" if none; never null.
 void setFullName(java.lang.String name)
          Set all parameters from a supplied full name.
 void setMainWords(java.lang.String mainWords)
          Set main body words; valid string of hyphen-separated words where; can be "" but never null.
 void setNumber(int number)
          Sets number in series for exhibit; if negative the value is ignored.
 void setNumber(java.lang.String number)
          Sets number in series for exhibit; if null or "" or unparsable or negative the value is ignored.
 void setUploadAeid(AllExhibitImmutableData uploadAeid)
           
 void tryToSanitise()
          Tries to reparse as the system will see the name.
 
Methods inherited from class org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
dedupAttrs, getAep, getAllAuthors, getAllCategories, getAllSuffixes, getAttributeWords, getAttributeWordsAsList, getAuthor, getCategory, getInUseAttrWordListAsString, getLegalAttrWordListAsString, getSuffix, makeAttributeSelectBody, makeAttributeSelectBody, makeAuthorSelectBody, makeCategorySelectBody, makeCategorySelectBody, makeSuffixSelectBody, setAep, setAttributeWords, setAttributeWords, setAttributeWords, setAuthor, setCategory, setCommonValuesForUnsetFields, setSuffix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uploadAeid

private AllExhibitImmutableData uploadAeid
Aeid for upload area; should be set.


number

private int number
The number in the current series; never negative. If zero, it will not be inserted into the filename (ie is the default).


mainWords

private java.lang.String mainWords
Main body words; valid string of hyphen-separated words where; can be "" but never null. Trailing words may not be attribute words and the final one may not be a number.


description

private java.lang.String description
Description text or "" if none; never null. Pure ASCII text, possibly with HTML mark-up.


serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

UploadInfoBean

public UploadInfoBean()
Create a new instance. We allow some values to be selected beyond extant values in the production database.

Method Detail

setUploadAeid

public void setUploadAeid(AllExhibitImmutableData uploadAeid)

getNumber

public int getNumber()
Gets number in series of exhibit; never negative.


setNumber

public void setNumber(java.lang.String number)
Sets number in series for exhibit; if null or "" or unparsable or negative the value is ignored. This is a convenience method to make setting from a JSP/form more robust.


setNumber

public void setNumber(int number)
Sets number in series for exhibit; if negative the value is ignored.


incNumberIfNonZero

public int incNumberIfNonZero()
Increment number-in-series value iff already positive and returns new value; never negative.


makeValidWordString

private static java.lang.String makeValidWordString(java.lang.String in)
Forces string to a superficially valid word string. Replaces all non-word chars with the word separator, replaces all sequences of two or more separators with one, and trims all leading and trailing separators.

The input must not be null.

This does not of itself make the string valid to use as a main or attribute word string (it does not check the contents of the words).

This limits the length of the value.

This returns the original string if valid.


getMainWords

public java.lang.String getMainWords()
Set main body words; valid string of hyphen-separated words where; can be "" but never null. Trailing words may not be attribute words and the final one may not be a number.


setMainWords

public void setMainWords(java.lang.String mainWords)
Set main body words; valid string of hyphen-separated words where; can be "" but never null. Use null or "" or "-" to clear this field.

Trailing words may not be attribute words and the final one may not be a number.

Any non-valid word characters (eg including spaces) will be converted to hyphens.

This tries very hard to keep as much of its input as possible.


getNewMainWords

public java.lang.String getNewMainWords()
Get main words that would be new to the Gallery: return the empty string "" if none. This checks all the putative exhibit name main words against all main words of all extant exhibits (in the main database), returning a space-separated list of those new words that might have incorrect spelling or capitalisation. This can be used to warn the User that they should possibly check their spelling, etc.


getDescription

public java.lang.String getDescription()
Get description text or "" if none; never null. Pure ASCII text, possibly with HTML mark-up.


setDescription

public void setDescription(java.lang.String description)
Set description text or "" or "-" if none; never null. Pure ASCII text, possibly with HTML mark-up.

This tries hard to preserve any input given to it, replacing illegal characters with spaces, and truncating to maximum length.

If the input string is OK it should be stored intact.


enoughInfo

public boolean enoughInfo()
When enough exhibit information has been collected, this returns true. This returns true when there is enough information to unambiguously store the exhibit under a complete and unique name.

Optional information need not be present for this to return true.


tryToSanitise

public void tryToSanitise()
Tries to reparse as the system will see the name. Call after all available bean attributes from the user have been set.

If enoughInfo() is true, this will assemble the complete name and the reset the component parts by reparsing it with ExhibitName.

This should make clear any ambiguities in, for example, putting attribute words at the end of the main words section.

We only reset the parts about which there may be ambiguity, ie main words, attribute words, and number-in-series.

If enoughInfo() is not true, this does nothing.


getName

public java.lang.String getName(boolean fullName)
Assemble complete name. The result is undefined if enoughInfo() is false, but this will do the best it can/

This may not be valid because it may be too long.

The name starts with the category directory and the final name.


getFullName

public java.lang.String getFullName()
Assemble complete name. The result is undefined if enoughInfo() is false, but this will do the best it can/

This may not be valid because it may be too long.

The name starts with the category directory and the final name.


setFullName

public void setFullName(java.lang.String name)
Set all parameters from a supplied full name. The result is undefined if the name is not valid, but this will do the best that it can.


canMakeValidName

public boolean canMakeValidName()
Returns true if we can construct a valid name. We explicitly make sure that we have enough information and that when we construct a name it is acceptable.

We should make sure that we can insert a ``_moreXXXX/_moreYY/'' section and not get an overlong-name.


nameUniqueInMainDatabase

public boolean nameUniqueInMainDatabase()
Check if the name is unique against the production data set. The result is undefined if enoughInfo() is false.

We just check the short name.


nameUniqueInAuxDatabase

public boolean nameUniqueInAuxDatabase()
Check if the name is unique against the upload data set. This returns false if the aux database data has not been set.

We just check the short name.


enoughValidUniqueInfo

public boolean enoughValidUniqueInfo()
Returns true when we have enough, valid, unique info to save an exhibit. The name must be unique in our production and temporary databases.

This is the "master" test of acceptability.


DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.