Class BeansUtils
- 
Method SummaryModifier and TypeMethodDescriptionadditionalIdentifiersIntersection(String firstAdditionalIdentifiers, String secondAdditionalIdentifiers) creates an intersection of two additionalIdentifiers arrays given as string.static StringattributeValueToString(Attribute attribute) Converts attribute value to string (for storing into DB)static StringattributeValueToString(Object attributeValue, String type) Converts attribute value to string (serialize object to string).static StringconvertRichBeanNameToBeanName(String beanName) Take perunBean name and if it is RichObject, convert it to simple name.static CandidateconvertRichMemberToCandidate(RichMember richMember, UserExtSource primaryUserExtSource) Convert object richMember to object candidate.static StringcreateEscaping(String text) This method take text and for every chars in "invalid input: '<'>\" create escaping Escaping char is \.deserializeStringToMap(String text) This method get map created by example : {= , = } Keys and values are escaped for "\", "invalid input: '<'" and ">" Example of escaping key="key\\s\>" is "key\s>" Return Mapinvalid input: '<'String, String> attribute to value. static StringeraseEscaping(String text) This method take text and for every chars in "invalid input: '<'>\" erase escaping also change '\0' to 'null' if it is escaped zero symbol.getAllPropertiesFromCustomConfiguration(String propertyFile) Gets all properties from custom property file.static StringReturns abbreviation in format [Entity]:[V/D/C]:[friendlyName] [Entity] is something like 'U' for user, 'G-R' for group-resource etc.static CoreConfigstatic DateFormatMethod create formatter with default settings for perun timestamps and set lenient on false Timestamp format: "yyyy-MM-dd HH:mm:ss.S" - "ex. 2014-01-01 10:10:10.0"static DateFormatMethod create formatter with default settings for perun timestamps (only date without time) and set lenient on false.static JavaMailSenderReturn instance of JavaMailSender with shared Perun configuration used to send mail notifications by.static StringgetPropertyFromCustomConfiguration(String propertyFile, String propertyName) Gets particular property from custom property file.static IntegergetSingleId(Set<Pair<Integer, Integer>> pairs) getSinglePair(Set<Pair<Integer, Integer>> pairs) static booleanTrue if DB initializator is enabled, false if not Default is falsestatic booleanReturn true, if char on position in text is escaped by '\' Return false, if not.static booleanTrue if this instance of perun is read only.static voidChecks whether the object is null or not.static StringparseEscapedListValue(String value) From the given list, parses all values separated by the comma ',' char.static StringprepareInSqlClause(String identifier, List<? extends PerunBean> beans) Create a string with set of IN clause.static StringprepareInSqlClause(List<Integer> beansIds, String identifier) Create a string with set of IN clause.static StringThis method get text and all escaped \0 replace for text nullstatic StringThis method get text and all nonescaped characters invalid input: '<' and > replace by apostrophestatic voidsetConfig(CoreConfig coreConfig) Set configuration that can be later queried by getCoreConfig().static ObjectstringToAttributeValue(String stringValue, String type) Converts string representation of an attribute value to correct java objectstatic LinkedHashMap<String, String> stringToMapOfAttributes(String attributesAsString) Converts string representation of an attribute value to the LinkedHashMap
- 
Method Details- 
getDateFormatterMethod create formatter with default settings for perun timestamps and set lenient on false Timestamp format: "yyyy-MM-dd HH:mm:ss.S" - "ex. 2014-01-01 10:10:10.0"Lenient on false means that formatter will be more strict to creating timestamp from string IMPORTANT: SimpleDateFormat is not thread safe !!! - Returns:
- date formatter
 
- 
getDateFormatterWithoutTimeMethod create formatter with default settings for perun timestamps (only date without time) and set lenient on false.Timestamp format: "yyyy-MM-dd" - "ex. 2014-01-01" Lenient on false means that formatter will be more strict to creating timestamp from string IMPORTANT: SimpleDateFormat is not thread safe !!! - Returns:
- date formatter
 
- 
eraseEscapingThis method take text and for every chars in "invalid input: '<'>\" erase escaping also change '\0' to 'null' if it is escaped zero symbol.Escaping char is \. Expecting: Before using this method, text must be escaped by using method createEscaping. So in text will never be string like "\\>", "\" or "\\\". For every \ in text it put \\ and for every invalid input: '<' it put \invalid input: '<' and for every > it put \> - Parameters:
- text- text from which will be erase escaping
- Returns:
- nonescaped text
 
- 
createEscapingThis method take text and for every chars in "invalid input: '<'>\" create escaping Escaping char is \. For every \\ in text it put \ and for every \invalid input: '<' it put invalid input: '<' and for every \> it put >- Parameters:
- text- text from which will be erase escaping
- Returns:
- escaped text
 
- 
replacePointyBracketsByApostropheThis method get text and all nonescaped characters invalid input: '<' and > replace by apostrophe- Parameters:
- text-
- Returns:
- text where nonescaped characters invalid input: '<' and > will be reaplace by apostrophe '
 
- 
replaceEscapedNullByStringNullThis method get text and all escaped \0 replace for text null- Parameters:
- text-
- Returns:
- text where \0 is replaced for null
 
- 
isEscapedReturn true, if char on position in text is escaped by '\' Return false, if not.- Parameters:
- text- text in which will be searching
- position- position in text invalid input: '<'0-text.length>
- Returns:
- true if char is escaped, false if not
 
- 
attributeValueToStringConverts attribute value to string (serialize object to string). This is a wrapper for passing value and type only for specific use.- Parameters:
- attributeValue- value of the attribute
- type- type of resulting attribute
- Returns:
- string representation of the value
- Throws:
- InternalErrorException
- See Also:
 
- 
attributeValueToStringConverts attribute value to string (for storing into DB)- Parameters:
- attribute- value of the attribute
- Returns:
- string representation of the value
- Throws:
- InternalErrorException
 
- 
deserializeStringToMapThis method get map created by example : {= , = } Keys and values are escaped for "\", "invalid input: '<'" and ">" Example of escaping key="key\\s\>" is "key\s>" Return Mapinvalid input: '<'String, String> attribute to value. - Parameters:
- text- text from which will be parsed map
- Returns:
- mapinvalid input: '<'string, string> attributes
 
- 
parseEscapedListValueFrom the given list, parses all values separated by the comma ',' char. The value has to end with the comma ',' char.All escaped commas '{backslash},' will not be used to split the value. If there is a backslash character: * it must be either follow by the comma ',' meaning that this comma is not used for split; or * it must be paired with another backslash '{backslash}{backslash}'. In that case, this double backslash in the result value would be replaced by a single back slash. Example: input: 'value1,val{backslash}ue2,val{backslash},ue3,' result: ['value1', 'val{backslash}ue2', val,ue3'] - Parameters:
- value- value to be parsed
- Returns:
- list of parsed values
 
- 
stringToAttributeValueConverts string representation of an attribute value to correct java object- Parameters:
- stringValue- string representation of the attribute value
- type- type of the value ("Java.lang.String" for example)/
- Returns:
- Throws:
- InternalErrorException
 
- 
stringToMapOfAttributesConverts string representation of an attribute value to the LinkedHashMap- Parameters:
- attributesAsString- Map attribute in String representation.
- Returns:
- LinkedHashMap with key values pairs extracted from the input or an empty map when the input parameter is an empty string or null.
 
- 
convertRichBeanNameToBeanNameTake perunBean name and if it is RichObject, convert it to simple name.RichObject mean: starts with "Rich" and continue with Upper Letter [A-Z] Ex.: RichGroup -> Group, RichUser -> User Ex.: RichardObject -> RichardObject Ex.: Null -> Null - Parameters:
- beanName- bean Name of PerunBean (simple name of object)
- Returns:
- converted beanName (without Rich part)
 
- 
prepareInSqlClauseCreate a string with set of IN clause. Every in clause has maximum 1000 ids. Identifier means for what IN clause is calling (Like 'table.id')Reason for using is compatibility with oracle and other dbs. Example: " ( in (10,15,...) or in (...) or ... ) " - Parameters:
- beans- list of perun beans
- Returns:
- string with some sql IN clause
 
- 
prepareInSqlClauseCreate a string with set of IN clause. Every in clause has maximum 1000 ids. Identifier means for what IN clause is calling (Like 'table.id')Reason for using is compatibility with oracle and other dbs. Example: " ( in (10,15,...) or in (...) or ... ) " - Parameters:
- beansIds- list of perun bean ids
- Returns:
- string with some sql IN clause
 
- 
getPropertyFromCustomConfigurationGets particular property from custom property file.- Parameters:
- propertyFile- name of properties file
- propertyName- name of the property
- Returns:
- value of the property
 
- 
getAllPropertiesFromCustomConfigurationGets all properties from custom property file.- Parameters:
- propertyFile- name of properties file
- Returns:
- all properties with values
 
- 
isPerunReadOnlypublic static boolean isPerunReadOnly()True if this instance of perun is read only. False if not.- Returns:
- true or false (readOnly or not)
 
- 
initializatorEnabledpublic static boolean initializatorEnabled()True if DB initializator is enabled, false if not Default is false- Returns:
- true if enabled, false if disabled
 
- 
notNullChecks whether the object is null or not.- Parameters:
- e-
- name-
- Throws:
- InternalErrorException- which wraps NullPointerException
 
- 
setConfigSet configuration that can be later queried by getCoreConfig().
- 
getCoreConfig
- 
getSinglePair
- 
getSingleId
- 
getAttributeDefinitionAbbreviationReturns abbreviation in format [Entity]:[V/D/C]:[friendlyName] [Entity] is something like 'U' for user, 'G-R' for group-resource etc.- Parameters:
- ad- attribute definition
- Returns:
- abbreviation in format [Entity]:[V/D/C]:[friendlyName]
 
- 
parseEntityAbbreviation
- 
getDefaultMailSenderReturn instance of JavaMailSender with shared Perun configuration used to send mail notifications by.- Returns:
- single instance of JavaMailSender
 
- 
convertRichMemberToCandidatepublic static Candidate convertRichMemberToCandidate(RichMember richMember, UserExtSource primaryUserExtSource) Convert object richMember to object candidate. PrimaryUserExtSource is used as the main userExtSource for candidate object- Parameters:
- richMember-
- primaryUserExtSource- main userExtSource for candidate object
- Returns:
- converted object candidate from richMember
 
- 
additionalIdentifiersIntersectionpublic static List<String> additionalIdentifiersIntersection(String firstAdditionalIdentifiers, String secondAdditionalIdentifiers) creates an intersection of two additionalIdentifiers arrays given as string.- Parameters:
- firstAdditionalIdentifiers- first parameter which contains additional identifiers
- secondAdditionalIdentifiers- second parameter which contains additional identifiers
- Returns:
- Intersection of the given String parameters
 
 
-