Class StoreCommands
- java.lang.Object
- 
- edu.uiuc.ncsa.security.util.cli.CommonCommands
- 
- edu.uiuc.ncsa.security.storage.cli.StoreCommands
 
 
- 
- All Implemented Interfaces:
- Logable,- Commands,- Serializable
 - Direct Known Subclasses:
- SASCommands
 
 public abstract class StoreCommands extends CommonCommands This also has the machinery for parsing configurations since the user should be able to load one from the command line.Created by Jeff Gaynor 
 on 5/20/13 at 3:22 PM- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classStoreCommands.ChangeIDRecordstatic classStoreCommands.RSRecord
 - 
Field Summary- 
Fields inherited from class edu.uiuc.ncsa.security.util.cli.CommonCommandsCL_INPUT_FILE_FLAG, CL_OUTPUT_FILE_FLAG, DEFAULT_NULL_VALUE_PLACEHOLDER, defaultIndent, driver, INDENT, logger, placeHolder
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description StoreCommands(AbstractEnvironment environment)StoreCommands(MyLoggingFacade logger)StoreCommands(MyLoggingFacade logger, Store store)protectedStoreCommands(MyLoggingFacade logger, String defaultIndent, Store store)Constructor that sets the indent level for this command processor.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected IdentifiableactualCreate(InputLine inputLine, int magicNumber)does the actual creation and returns the created object.protected voidaddEntry(Identifiable identifiable, String key, String value)protected voidaddEntry(Identifiable identifiable, net.sf.json.JSON jjj)Add to an existing entry.voidarchive(InputLine inputLine)protected StringarchiveFormat(Identifiable id)InputLinebootstrap(InputLine inputLine)voidchange_id(InputLine inputLine)Allows changing the identifier for an object.voidclear_id(InputLine inputLine)voidclear_store(InputLine line)protected voidclearEntries()Clears the list of entries so next call will get it afreshvoidcopy(InputLine inputLine)protected Identifiablecreate(Identifiable identifiable)protected Identifiablecreate(Identifiable c, int magicNumber)voidcreate(InputLine inputLine)Creates a new item.protected IdentifiablecreateEntry(int magicNumber)Wraps the store create method.voiddeserialize(InputLine inputLine)StoreCommands.ChangeIDRecorddoChangeID(Identifiable identifiable, Identifier newID, boolean updatePermissions)Does the work of changing the ID for an object.protected IdentifierdoCopy(Identifiable source, Identifier targetId, boolean useRandomID)Do the copy.voidedit(InputLine inputLine)static InputLineextractIndexKeys(InputLine inputLine)Static utility to take an index argument like --4 and split it into -- 4.protected StringextractRawList(InputLine inputLine, String key)Assumes there is a key and the original line is of the form -key [x, y, ...abstract voidextraUpdates(Identifiable identifiable, int magicNumber)This is a hook for extensions so they don't have to completely rewrite complexupdate(edu.uiuc.ncsa.security.core.Identifiable)methods.protected FoundIdentifiablesfindByIDOrRS(Store store, String name)This will find an object in the given store assuming the name is an identifier.protected FoundIdentifiablesfindItem(Store store, InputLine inputLine, boolean allowResultSets)General case for finding items from a store.protected FoundIdentifiablesfindItem(InputLine inputLine)protected FoundIdentifiablesfindItem(InputLine inputLine, boolean allowResultSets)Resolves the first argument of a command line into either a unique identifier against the ambient store.protected IdentifiablefindSingleton(InputLine inputLine)protected IdentifiablefindSingleton(InputLine inputLine, String errorMessage)Does all the checks for a command that accepts a single store object.protected abstract Stringformat(Identifiable identifiable)In listing operations, take theIdentifiableargument and make a string version that a user can understandprotected StringformatLongLine(String leftSide, String rightSide, int leftColumWidth, boolean isVerbose)Gets a consistent look and feel.protected IdentifiablefromXMLMap(XMLMap map)Take the updated values for the object and return a new, updated object.voidget_id(InputLine inputLine)protected StringgetAndCheckKeyArg(InputLine inputLine)resolves key shorthand of >key_name or -key key_name returns null if no such key OR if it is not valid in the key list.protected List<String>getArgList(InputLine inputLine)Deprecated.EditorEntrygetEditorEntry()AbstractEnvironmentgetEnvironment()List<Identifier>getID()Mutators for sub classesprotected IdentifiergetIdentifierfromIndex(Object x)If there is a list of objects, this will try to ferret out the identifier for the object.protected StringgetKeyArg(InputLine inputLine)protected StringgetKeyArg(InputLine inputLine, boolean removeIt)Just gets the key argument or null if not present.SerializationKeysgetKeys()protected MapConvertergetMapConverter()StringgetPrompt()The prompt displayed to the user.HashMap<String,StoreCommands.RSRecord>getResultSets()protected SerializationKeysgetSerializationKeys()Get the serialization keys for the main store.protected SortablegetSortable()StoregetStore()StoreArchivergetStoreArchiver()protected FilegetTempDir()protected booleanhasEntries()Tell if the user has run the listAll command.protected booleanhasId()booleanhasID()protected booleanhasKey(String key)protected voidinitHelp()protected net.sf.json.JSONObjectinputJSON(net.sf.json.JSONObject oldJSON, String key)Allows for entering a new JSON object.protected booleanisBadID(URI uri)booleanisMonitored()voidlist_keys(InputLine inputLine)protected List<Identifiable>listEntries(List<Identifiable> entries, boolean lineList, boolean verboseList)protected List<Identifiable>loadAllEntries()protected net.sf.json.JSONObjectloadQDLScript(net.sf.json.JSONObject currentConfig)The contract is that this gets the entire current config and updates exactly the bits relating to QDL.protected intlongFormat(Identifiable identifiable)Give a long (multi-line) formatted object.protected intlongFormat(Identifiable identifiable, boolean isVerbose)Long formatting with the switch for verbose or not.protected intlongFormat(Identifiable identifiable, List<String> keySubset, boolean isVerbose)Prints a restricted set of keys from the first argument.voidls(InputLine inputLine)protected StringmultiLineInput(String oldValue, String key)For entering muli-line strings (includes JSON).protected StringmultiLinePropertyInput(String propertyName, String oldValue, String key)protected voidoldls1(InputLine inputLine)protected voidoldrm(InputLine inputLine)protected voidoldUpdate(InputLine inputLine)Older version of update.protected IdentifiablepreCreation(Identifiable identifiable, int magicNumber)How to customize different objects this command processor creates (e.g.protected voidprintIndexHelp(boolean singletonsOnly)booleanprintRS(InputLine inputLine, List<Identifiable> values, List<String> returnedAttributes, List limits)If limits is empty or null, show everything.protected ListprocessList(InputLine inputLine, String key)A placeholder.protected StringrangeHelpSnippet()protected IdentifiableremoveEntries(Identifiable identifiable, List<String> keys)Removes the list of properties from theIdentifiableand returns an altered one.protected voidremoveEntry(Identifiable identifiable, String key)voidrm(InputLine inputLine)protected voidrmCleanup(FoundIdentifiables identifiable)Called if there is additional clean up needed.voidrs(InputLine inputLine)voidsearch(InputLine inputLine)voidserialize(InputLine inputLine)protected voidserialize(InputLine inputLine, Identifiable x)voidset_id(InputLine inputLine)voidsetEnvironment(AbstractEnvironment environment)voidsetID(List<Identifier> id)protected IdentifiablesetIDFromInputLine(Identifiable x, InputLine inputLine)if the user specified the new identifier on the command line, peel it off and use it.voidsetResultSets(HashMap<String,StoreCommands.RSRecord> resultSets)voidsetSortable(Sortable sortable)voidsetStore(Store store)protected voidshowArchiveHelp()protected voidshowCommandLineSwitchesHelp()protected voidshowCreateHelp()protected voidshowDeserializeHelp()protected booleanshowEntry(Identifiable identifiable, String key, boolean isVerbose)Show the value of a single property from an entry.protected voidshowEntrySubset(Identifiable identifiable, List<String> keys, boolean isVerbose)Shows a subset of an entry.protected voidshowKeyShorthandHelp()protected voidshowListKeysHelp(InputLine inputLine)protected voidshowLSHelp()protected voidshowLSHelp3()protected voidshowResultSetHelp()protected voidshowRMHelp()protected voidshowSearchHelp()protected voidshowSearchHelpExamples()protected voidshowSerializeHelp()protected voidshowSizeHelp()protected voidshowUpdateHelp()protected voidshowUpkeepHelp()voidsize(InputLine inputLine)protected XMLMaptoXMLMap(Identifiable identifiable)Once an object is found in the store, convert it to JSON so that the properties may be accessed in a canonical way.booleanupdate(Identifiable identifiable)This is the workhorse method for the object that lets you edit the values.booleanupdate(Identifiable identifiable, boolean doSave, int magicNumber)Update the object.voidupdate(InputLine inputLine)protected ObjectupdateSingleValue(XMLMap map, String key)Update a single value for a key, prompting the user for each value.protected net.sf.json.JSONArrayupdateSingleValue(String key, net.sf.json.JSONArray currentValue)protected abstract intupdateStorePermissions(Identifier newID, Identifier oldID, boolean copy)Override this as needed to update any permissions for this store.voidupkeep(InputLine inputLine)- 
Methods inherited from class edu.uiuc.ncsa.security.util.cli.CommonCommandsclear_env, clearEnvHelp, debug, echo, echoHelp, error, get_env, getBufferedReader, getDriver, getHelpUtil, getInput, getIOInterface, getPlaceHolder, getPropertyHelp, getValue, gracefulExit, indentWidth, info, isDebugOn, isEmpty, isOk, isPrintOuput, isVerbose, logit, print_env, printEnvHelp, printGetEnvHelp, printReadEnvHelp, printSaveEnvHelp, printSetEnvHelp, read_env, readFile, readJSON, readline, readline, save_env, say, say, say2, sayi, sayii, sayv, set_env, set_output_on, set_verbose_on, setBufferedReader, setDebugOn, setDriver, setHelpUtil, setOutputOnHelp, setPlaceHolder, setPrintOuput, setVerbose, setVerboseHelp, showHelp, version, versionHelp, warn
 
- 
 
- 
- 
- 
Field Detail- 
sortableprotected Sortable sortable 
 - 
UPKEEP_FLAG_TESTpublic static String UPKEEP_FLAG_TEST 
 - 
UPKEEP_FLAG_SHOWpublic static String UPKEEP_FLAG_SHOW 
 - 
UPKEEP_FLAG_CFGpublic static String UPKEEP_FLAG_CFG 
 - 
UPKEEP_FLAG_RUNpublic static String UPKEEP_FLAG_RUN 
 - 
UPKEEP_FLAG_ENABLEpublic static String UPKEEP_FLAG_ENABLE 
 - 
NEXT_N_COMMANDprotected final String NEXT_N_COMMAND - See Also:
- Constant Field Values
 
 - 
SEARCH_REGEX_FLAGpublic static final String SEARCH_REGEX_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_SHORT_REGEX_FLAGpublic static final String SEARCH_SHORT_REGEX_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_SIZE_FLAGpublic static final String SEARCH_SIZE_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_DEBUG_FLAGpublic static final String SEARCH_DEBUG_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_VERSIONS_FLAGpublic static final String SEARCH_VERSIONS_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_VERSIONS_ONLY_VALUEpublic static final String SEARCH_VERSIONS_ONLY_VALUE - See Also:
- Constant Field Values
 
 - 
SEARCH_VERSIONS_TRUE_VALUEpublic static final String SEARCH_VERSIONS_TRUE_VALUE - See Also:
- Constant Field Values
 
 - 
SEARCH_VERSIONS_FALSE_VALUEpublic static final String SEARCH_VERSIONS_FALSE_VALUE - See Also:
- Constant Field Values
 
 - 
SEARCH_RETURNED_ATTRIBUTES_FLAGpublic static final String SEARCH_RETURNED_ATTRIBUTES_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_RESULT_SET_NAMEpublic static final String SEARCH_RESULT_SET_NAME - See Also:
- Constant Field Values
 
 - 
RESULT_SET_KEYpublic static final String RESULT_SET_KEY Used as a command line switch to name a result set.- See Also:
- Constant Field Values
 
 - 
SEARCH_BEFORE_TS_FLAGpublic static final String SEARCH_BEFORE_TS_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_AFTER_TS_FLAGpublic static final String SEARCH_AFTER_TS_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_DATE_FLAGpublic static final String SEARCH_DATE_FLAG - See Also:
- Constant Field Values
 
 - 
SEARCH_IS_NULL_FLAGpublic static final String SEARCH_IS_NULL_FLAG - See Also:
- Constant Field Values
 
 - 
resultSetsprotected static HashMap<String,StoreCommands.RSRecord> resultSets 
 - 
allEntriesprotected List<Identifiable> allEntries 
 - 
DEFAULT_MAGIC_NUMBERpublic static final int DEFAULT_MAGIC_NUMBER This is the system default (only one defined, equals zero). use another number so you can specify cases for overrides. This way your commands can work with slightly different types of objects (such as ersatz or service clients) and be able to disambiguate without having some more complex system in the API to do it. Specify any non-zero magic numbers in your commands and use those.- See Also:
- Constant Field Values
 
 - 
LINE_LIST_COMMANDprotected final String LINE_LIST_COMMAND - See Also:
- Constant Field Values
 
 - 
ALL_LIST_COMMANDprotected final String ALL_LIST_COMMAND - See Also:
- Constant Field Values
 
 - 
LOAD_ONLY_COMMANDprotected final String LOAD_ONLY_COMMAND - See Also:
- Constant Field Values
 
 - 
VERBOSE_COMMANDprotected final String VERBOSE_COMMAND - See Also:
- Constant Field Values
 
 - 
SIZE_ALL_FLAGprotected static String SIZE_ALL_FLAG 
 - 
SIZE_VERSIONS_FLAGprotected static String SIZE_VERSIONS_FLAG 
 - 
display_widthprotected int display_width 
 - 
FILE_FLAGpublic static final String FILE_FLAG - See Also:
- Constant Field Values
 
 - 
UPDATE_FLAGpublic static final String UPDATE_FLAG - See Also:
- Constant Field Values
 
 - 
SHORT_UPDATE_FLAGpublic static final String SHORT_UPDATE_FLAG - See Also:
- Constant Field Values
 
 - 
KEY_SHORTHAND_PREFIXpublic static String KEY_SHORTHAND_PREFIX 
 - 
RANDOM_ID_FLAGpublic static String RANDOM_ID_FLAG 
 - 
FORCE_COPY_FLAGpublic static String FORCE_COPY_FLAG 
 - 
SKIP_UPDATE_PERMISSIONS_FLAGpublic static String SKIP_UPDATE_PERMISSIONS_FLAG 
 - 
RS_APPEND_ACTIONpublic static final String RS_APPEND_ACTION - See Also:
- Constant Field Values
 
 - 
RS_CLEAR_ACTIONpublic static final String RS_CLEAR_ACTION - See Also:
- Constant Field Values
 
 - 
RS_DROP_ACTIONpublic static final String RS_DROP_ACTION - See Also:
- Constant Field Values
 
 - 
RS_FIELDS_ACTIONpublic static final String RS_FIELDS_ACTION - See Also:
- Constant Field Values
 
 - 
RS_LIST_ACTIONpublic static final String RS_LIST_ACTION - See Also:
- Constant Field Values
 
 - 
RS_READ_ACTIONpublic static final String RS_READ_ACTION - See Also:
- Constant Field Values
 
 - 
RS_REMOVE_ACTIONpublic static final String RS_REMOVE_ACTION - See Also:
- Constant Field Values
 
 - 
RS_SAVE_ACTIONpublic static final String RS_SAVE_ACTION - See Also:
- Constant Field Values
 
 - 
RS_SHOW_ACTIONpublic static final String RS_SHOW_ACTION - See Also:
- Constant Field Values
 
 - 
RS_SIZE_ACTIONpublic static final String RS_SIZE_ACTION - See Also:
- Constant Field Values
 
 - 
RS_SUBSET_ACTIONpublic static final String RS_SUBSET_ACTION - See Also:
- Constant Field Values
 
 - 
RS_WRITE_ACTIONpublic static final String RS_WRITE_ACTION - See Also:
- Constant Field Values
 
 - 
RS_RANGE_KEYpublic static String RS_RANGE_KEY 
 - 
RS_RANGE_SHORT_KEYpublic static String RS_RANGE_SHORT_KEY 
 - 
RS_FILE_KEYpublic static String RS_FILE_KEY 
 - 
RM_FORCE_FLAGpublic static String RM_FORCE_FLAG 
 - 
LIST_EOL_MARKERpublic static final String LIST_EOL_MARKER - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
StoreCommandspublic StoreCommands(MyLoggingFacade logger) throws Throwable - Throws:
- Throwable
 
 - 
StoreCommandspublic StoreCommands(AbstractEnvironment environment) throws Throwable - Throws:
- Throwable
 
 - 
StoreCommandsprotected StoreCommands(MyLoggingFacade logger, String defaultIndent, Store store) throws Throwable Constructor that sets the indent level for this command processor. Every bit of output will be indented by this amount.- Parameters:
- defaultIndent-
- store-
- Throws:
- Throwable
 
 - 
StoreCommandspublic StoreCommands(MyLoggingFacade logger, Store store) throws Throwable - Throws:
- Throwable
 
 
- 
 - 
Method Detail- 
getEnvironmentpublic AbstractEnvironment getEnvironment() 
 - 
setEnvironmentpublic void setEnvironment(AbstractEnvironment environment) 
 - 
setSortablepublic void setSortable(Sortable sortable) 
 - 
getSortableprotected Sortable getSortable() 
 - 
isMonitoredpublic boolean isMonitored() 
 - 
showUpkeepHelpprotected void showUpkeepHelp() 
 - 
getPromptpublic String getPrompt() Description copied from interface:CommandsThe prompt displayed to the user. This allows it to change based on context.- Returns:
- java.lang.String
 
 - 
getStorepublic Store getStore() 
 - 
setStorepublic void setStore(Store store) 
 - 
showUpdateHelpprotected void showUpdateHelp() 
 - 
showSerializeHelpprotected void showSerializeHelp() 
 - 
showDeserializeHelpprotected void showDeserializeHelp() 
 - 
deserializepublic void deserialize(InputLine inputLine) 
 - 
getResultSetspublic HashMap<String,StoreCommands.RSRecord> getResultSets() 
 - 
setResultSetspublic void setResultSets(HashMap<String,StoreCommands.RSRecord> resultSets) 
 - 
searchpublic void search(InputLine inputLine) 
 - 
printRSpublic boolean printRS(InputLine inputLine, List<Identifiable> values, List<String> returnedAttributes, List limits) If limits is empty or null, show everything. Limits contains the indices to show.- Parameters:
- inputLine-
- values-
- returnedAttributes-
- limits-
- Returns:
 
 - 
getMapConverterprotected MapConverter getMapConverter() 
 - 
oldUpdateprotected void oldUpdate(InputLine inputLine) throws Throwable Older version of update. Not nearly as full-featured but still useful, so keep it and in cases it is needed, just invoke it on behalf of the user.- Parameters:
- inputLine-
- Throws:
- IOException
- Throwable
 
 - 
updatepublic boolean update(Identifiable identifiable) throws IOException This is the workhorse method for the object that lets you edit the values. Generally this should do validation and checking so that updates to the store are not garbage.- Parameters:
- identifiable-
- Returns:
- returns true if the passed object needs to be saved, false otherwise.
- Throws:
- IOException
 
 - 
updatepublic boolean update(Identifiable identifiable, boolean doSave, int magicNumber) throws IOException Update the object. doSave if true means to prompt the user to save it (usually what you want). The magic number is for when you are over-riding this with some specific tweak.- Parameters:
- identifiable-
- doSave-
- magicNumber-
- Returns:
- Throws:
- IOException
 
 - 
extraUpdatespublic abstract void extraUpdates(Identifiable identifiable, int magicNumber) throws IOException This is a hook for extensions so they don't have to completely rewrite complexupdate(edu.uiuc.ncsa.security.core.Identifiable)methods. It will be invoked before update displays the completed item and saves it, allowing any properties not in the base class to be queried and saved.- Parameters:
- identifiable-
- magicNumber-
- Throws:
- IOException
 
 - 
formatprotected abstract String format(Identifiable identifiable) In listing operations, take theIdentifiableargument and make a string version that a user can understand- Parameters:
- identifiable-
 
 - 
longFormatprotected int longFormat(Identifiable identifiable) Give a long (multi-line) formatted object. This should allow users to see everything cleanly. This assumes the long format, not the verbose- Parameters:
- identifiable-
- Returns:
- the width of the left field when formatting (for consistent look and feel in overrides).
 
 - 
longFormatprotected int longFormat(Identifiable identifiable, boolean isVerbose) Long formatting with the switch for verbose or not. If false, that means use the long format- Parameters:
- identifiable-
- isVerbose-
- Returns:
- the width of the left field when formatting (for consistent look and feel in overrides).
 
 - 
hasEntriesprotected boolean hasEntries() Tell if the user has run the listAll command.- Returns:
 
 - 
loadAllEntriesprotected List<Identifiable> loadAllEntries() 
 - 
clearEntriesprotected void clearEntries() Clears the list of entries so next call will get it afresh
 - 
listEntriesprotected List<Identifiable> listEntries(List<Identifiable> entries, boolean lineList, boolean verboseList) 
 - 
showCreateHelpprotected void showCreateHelp() 
 - 
createpublic void create(InputLine inputLine) throws IOException Creates a new item. The optional argument is the new identifier.- Parameters:
- inputLine-
- Throws:
- IOException
 
 - 
createEntryprotected Identifiable createEntry(int magicNumber) Wraps the store create method. This can be overridden in certain cases (e.g. creating users) where special handling is needed.- Returns:
 
 - 
getSerializationKeysprotected SerializationKeys getSerializationKeys() Get the serialization keys for the main store.- Returns:
 
 - 
actualCreateprotected Identifiable actualCreate(InputLine inputLine, int magicNumber) throws IOException does the actual creation and returns the created object. If you overridecreate(InputLine), this is what does the actual work.- Parameters:
- inputLine-
- magicNumber-
- Returns:
- Throws:
- IOException
 
 - 
setIDFromInputLineprotected Identifiable setIDFromInputLine(Identifiable x, InputLine inputLine) if the user specified the new identifier on the command line, peel it off and use it.- Parameters:
- x-
- inputLine-
- Returns:
 
 - 
preCreationprotected Identifiable preCreation(Identifiable identifiable, int magicNumber) How to customize different objects this command processor creates (e.g. creating ersatz clients as a special case with a flag). These are invoked right after creation, but before the object is saved, so you can just set properties or prompt the user for specific properties. Note that if the user elects toupdate(Identifiable)the properties, then in the course of thatextraUpdates(Identifiable, int)will be invoked, so that is another location for the user to get prompted for properties.- Parameters:
- identifiable-
- magicNumber-
- Returns:
 
 - 
createprotected Identifiable create(Identifiable identifiable) throws IOException - Throws:
- IOException
 
 - 
createprotected Identifiable create(Identifiable c, int magicNumber) throws IOException - Throws:
- IOException
 
 - 
hasIDpublic boolean hasID() 
 - 
getIDpublic List<Identifier> getID() Mutators for sub classes- Returns:
 
 - 
setIDpublic void setID(List<Identifier> id) 
 - 
clear_idpublic void clear_id(InputLine inputLine) 
 - 
getIdentifierfromIndexprotected Identifier getIdentifierfromIndex(Object x) If there is a list of objects, this will try to ferret out the identifier for the object.- Parameters:
- x-
- Returns:
 
 - 
get_idpublic void get_id(InputLine inputLine) 
 - 
findByIDOrRSprotected FoundIdentifiables findByIDOrRS(Store store, String name) This will find an object in the given store assuming the name is an identifier. Failing that, it tries to find a result set with that name. If there is no such element, a null is returned, rather than raising an error, so you can, e.g. prompt the user or some such.This is used for positional argument, like link_clients my_rs foo:/bar/bazwhich allows the command to get the result set my_rs and iterate over it, applying the operation with the other argument.- Parameters:
- name-
- Returns:
 
 - 
findItemprotected FoundIdentifiables findItem(InputLine inputLine) throws Throwable SeefindItem(InputLine, boolean). This calls that with a default of true.- Parameters:
- inputLine-
- Returns:
- Throws:
- Throwable
 
 - 
findItemprotected FoundIdentifiables findItem(InputLine inputLine, boolean allowResultSets) throws Throwable Resolves the first argument of a command line into either a unique identifier against the ambient store. The contract is that IF there is an ID set (withset_id(InputLine)) then use that. Otherwise, take the last argument of the input line and try to find that.Note: If there is no such item, such as an empty set, this will return a null. Therefore, either the result is a null or has at least one element. This removes the arguments for this from the InputLinesince that might mess up parsing it later. Properly, if this is needed for a command, it should be called as early as practical.- Parameters:
- inputLine-
- Returns:
- Throws:
- Throwable
 
 - 
findItemprotected FoundIdentifiables findItem(Store store, InputLine inputLine, boolean allowResultSets) throws Throwable General case for finding items from a store. Pass in the store.- Parameters:
- store-
- inputLine-
- allowResultSets-
- Returns:
- Throws:
- Throwable
 
 - 
extractIndexKeyspublic static InputLine extractIndexKeys(InputLine inputLine) Static utility to take an index argument like --4 and split it into -- 4. This typo happens a lot (it's an idiom in Unix several command line tools) so since everyone keeps doing it, we'll make it an official idiom for indices.- Parameters:
- inputLine-
- Returns:
 
 - 
showLSHelpprotected void showLSHelp() 
 - 
hasIdprotected boolean hasId() 
 - 
showSizeHelpprotected void showSizeHelp() 
 - 
sizepublic void size(InputLine inputLine) 
 - 
formatLongLineprotected String formatLongLine(String leftSide, String rightSide, int leftColumWidth, boolean isVerbose) Gets a consistent look and feel. If you have to overridelongFormat(Identifiable)and add your own entries, use this.- Parameters:
- leftSide-
- rightSide-
- leftColumWidth-
- Returns:
 
 - 
longFormatprotected int longFormat(Identifiable identifiable, List<String> keySubset, boolean isVerbose) Prints a restricted set of keys from the first argument. Note that a missing or empty subset means print everything. The output is key values in a readable format usingStringUtils.formatMap(Map, List, boolean, boolean, int, int, boolean)- Parameters:
- identifiable- object to print
- keySubset- list of keys to restrict to
- isVerbose- multi-line output, otherwise only a single line, possibly truncated, per property is shown
- Returns:
 
 - 
serializeprotected void serialize(InputLine inputLine, Identifiable x) 
 - 
showSearchHelpprotected void showSearchHelp() 
 - 
showSearchHelpExamplesprotected void showSearchHelpExamples() 
 - 
getAndCheckKeyArgprotected String getAndCheckKeyArg(InputLine inputLine) resolves key shorthand of >key_name or -key key_name returns null if no such key OR if it is not valid in the key list. Does not remove the argument from the inputLine!- Parameters:
- inputLine-
- Returns:
 
 - 
getKeyArgprotected String getKeyArg(InputLine inputLine, boolean removeIt) Just gets the key argument or null if not present. This does no checking if the key that is found is valid for the store.- Parameters:
- inputLine-
- removeIt-
- Returns:
 
 - 
showCommandLineSwitchesHelpprotected void showCommandLineSwitchesHelp() 
 - 
showKeyShorthandHelpprotected void showKeyShorthandHelp() 
 - 
updateStorePermissionsprotected abstract int updateStorePermissions(Identifier newID, Identifier oldID, boolean copy) Override this as needed to update any permissions for this store. This is used inchange_id(edu.uiuc.ncsa.security.util.cli.InputLine)andcopy(edu.uiuc.ncsa.security.util.cli.InputLine).- Parameters:
- newID-
- oldID-
- copy- - if true copy the permissions with the new ID. If false, create new ones
- Returns:
 
 - 
doCopyprotected Identifier doCopy(Identifiable source, Identifier targetId, boolean useRandomID) Do the copy. Note that if useRandomID is true, targetID is ignored,- Parameters:
- source-
- targetId-
- useRandomID-
 
 - 
processListprotected List processList(InputLine inputLine, String key) throws Exception A placeholder. StoreCommands2 in OA4MP does this with QDL, but that dependency here would create a compilation circularity.This looks for key [...] and returns a list for what's between the []. If there is no such list, a null is returned. (E.g. the key is missing) Contract is that the input line will have this entry removed and will be reparsed. This is to prevent bad parsing later. - Parameters:
- inputLine-
- key-
- Returns:
- Throws:
- Exception
 
 - 
rangeHelpSnippetprotected String rangeHelpSnippet() 
 - 
showResultSetHelpprotected void showResultSetHelp() 
 - 
showEntrySubsetprotected void showEntrySubset(Identifiable identifiable, List<String> keys, boolean isVerbose) Shows a subset of an entry.- Parameters:
- identifiable-
- keys-
- isVerbose-
 
 - 
showEntryprotected boolean showEntry(Identifiable identifiable, String key, boolean isVerbose) Show the value of a single property from an entry.- Parameters:
- identifiable-
- key-
- isVerbose-
 
 - 
hasKeyprotected boolean hasKey(String key) 
 - 
toXMLMapprotected XMLMap toXMLMap(Identifiable identifiable) Once an object is found in the store, convert it to JSON so that the properties may be accessed in a canonical way. This lets us take any identifiable object and manipulate its properties without knowing anything else about it.- Parameters:
- identifiable-
- Returns:
 
 - 
fromXMLMapprotected Identifiable fromXMLMap(XMLMap map) Take the updated values for the object and return a new, updated object. This does not store it, so you have to do that if you want to keep the changes.- Parameters:
- map-
 
 - 
inputJSONprotected net.sf.json.JSONObject inputJSON(net.sf.json.JSONObject oldJSON, String key) throws IOExceptionAllows for entering a new JSON object. This permits multi-line entry so formatted JSON can be cut and pasted into the command line (as long as there are no blank lines). This will validate the JSON, print out a message and check that you want to keep the new JSON. Note that you cannot overwrite the value of a configuration at this point mostly as a safety feature. So hitting return or /exit will have the same effect of keeping the current value.- Parameters:
- oldJSON-
- Returns:
- null if the input is terminated (so retain the old object)
- Throws:
- IOException
 
 - 
multiLinePropertyInputprotected String multiLinePropertyInput(String propertyName, String oldValue, String key) throws IOException - Throws:
- IOException
 
 - 
multiLineInputprotected String multiLineInput(String oldValue, String key) throws IOException For entering muli-line strings (includes JSON).- Parameters:
- oldValue- may be null if a new value
- key- used for constructing prompts.
- Returns:
- Throws:
- IOException
 
 - 
addEntryprotected void addEntry(Identifiable identifiable, net.sf.json.JSON jjj) Add to an existing entry.- Parameters:
- identifiable-
- jjj-
 
 - 
addEntryprotected void addEntry(Identifiable identifiable, String key, String value) 
 - 
removeEntriesprotected Identifiable removeEntries(Identifiable identifiable, List<String> keys) Removes the list of properties from theIdentifiableand returns an altered one.- Parameters:
- identifiable-
- keys-
- Returns:
 
 - 
removeEntryprotected void removeEntry(Identifiable identifiable, String key) 
 - 
updateSingleValueprotected Object updateSingleValue(XMLMap map, String key) throws IOException Update a single value for a key, prompting the user for each value. This returns the value the user supplied- Parameters:
- map-
- key-
- Returns:
- Throws:
- IOException
 
 - 
updateSingleValueprotected net.sf.json.JSONArray updateSingleValue(String key, net.sf.json.JSONArray currentValue) throws IOException - Throws:
- IOException
 
 - 
getArgListprotected List<String> getArgList(InputLine inputLine) Deprecated.Slightly special case. This will look on the input line and extract a list of the form[a,b,c,...]So to avoid having a lot of parsing (and the fact that there is pretty much at most one array per line) this will take everything between [ ] and try to turn it in to a list. The alternative would be make the list syntax have to conform toInputLine's fairly primitive system of checking for flags.- Parameters:
- inputLine-
- Returns:
 
 - 
getEditorEntrypublic EditorEntry getEditorEntry() 
 - 
getTempDirprotected File getTempDir() 
 - 
showArchiveHelpprotected void showArchiveHelp() 
 - 
archiveFormatprotected String archiveFormat(Identifiable id) 
 - 
getStoreArchiverpublic StoreArchiver getStoreArchiver() 
 - 
getKeyspublic SerializationKeys getKeys() 
 - 
loadQDLScriptprotected net.sf.json.JSONObject loadQDLScript(net.sf.json.JSONObject currentConfig) throws IOExceptionThe contract is that this gets the entire current config and updates exactly the bits relating to QDL. This is then saved elsewhere.- Parameters:
- currentConfig-
- Returns:
- Throws:
- IOException
 
 - 
showListKeysHelpprotected void showListKeysHelp(InputLine inputLine) 
 - 
showLSHelp3protected void showLSHelp3() 
 - 
showRMHelpprotected void showRMHelp() 
 - 
rmCleanupprotected void rmCleanup(FoundIdentifiables identifiable) Called if there is additional clean up needed. For instance, removing a client requires removing its approval record. The contract states that this is called after the objects have been removed from the main store.- Parameters:
- identifiable-
 
 - 
bootstrappublic InputLine bootstrap(InputLine inputLine) throws Throwable - Specified by:
- bootstrapin interface- Commands
- Overrides:
- bootstrapin class- CommonCommands
- Throws:
- Throwable
 
 - 
initHelpprotected void initHelp() throws Throwable- Overrides:
- initHelpin class- CommonCommands
- Throws:
- Throwable
 
 - 
doChangeIDpublic StoreCommands.ChangeIDRecord doChangeID(Identifiable identifiable, Identifier newID, boolean updatePermissions) Does the work of changing the ID for an object. This returns the state object from basic changes (so the object and it runs theupdateStorePermissions(Identifier, Identifier, boolean)method, which you should override as needed. A typical use would be to change the ID's for a client, then use the returned record to change the approval record.Note:This is invoked after the changes to the base store items have been saved. - Parameters:
- identifiable-
- newID-
- updatePermissions-
- Returns:
 
 - 
change_idpublic void change_id(InputLine inputLine) throws Throwable Allows changing the identifier for an object. This also updates the permissions that refer to this if theSKIP_UPDATE_PERMISSIONS_FLAGis set.- Parameters:
- inputLine-
- Throws:
- Throwable
 
 - 
isBadIDprotected boolean isBadID(URI uri) 
 - 
findSingletonprotected Identifiable findSingleton(InputLine inputLine, String errorMessage) throws Throwable Does all the checks for a command that accepts a single store object. Throws an exception if not found. Note that this returns the object from the store- Parameters:
- inputLine-
- Returns:
- Throws:
- Throwable
 
 - 
findSingletonprotected Identifiable findSingleton(InputLine inputLine) throws Throwable - Throws:
- Throwable
 
 - 
printIndexHelpprotected void printIndexHelp(boolean singletonsOnly) 
 - 
extractRawListprotected String extractRawList(InputLine inputLine, String key) Assumes there is a key and the original line is of the form -key [x, y, ... ]. *If the user has a more complex list they can terminate it withLIST_EOL_MARKER, e.g.my_command -foo -my_list [3, 5, -1] !! -other_flag fnordTells this function that everything from -my_list to !! is a single expression. Otherwise, this extracts everything between the [ and ] inclusive (most common case). It then truncates the original line and reparses it. This allows for the "whittle while you work" approach to input lines. Note that there is a call for getting a list, InputLine.getArgList(String)which does this, but with very simple logic. The difference is that theprocessList(InputLine, String)function in this class should allow for executing the lists as QDL later.This utility is used in other implementations of processList(InputLine, String)- Parameters:
- inputLine-
- key-
- Returns:
 
 
- 
 
-