Class BeansUtils
-
Method Summary
Modifier and TypeMethodDescriptionadditionalIdentifiersIntersection
(String firstAdditionalIdentifiers, String secondAdditionalIdentifiers) creates an intersection of two additionalIdentifiers arrays given as string.static String
attributeValueToString
(Attribute attribute) Converts attribute value to string (for storing into DB)static String
attributeValueToString
(Object attributeValue, String type) Converts attribute value to string (serialize object to string).static String
convertRichBeanNameToBeanName
(String beanName) Take perunBean name and if it is RichObject, convert it to simple name.static Candidate
convertRichMemberToCandidate
(RichMember richMember, UserExtSource primaryUserExtSource) Convert object richMember to object candidate.static String
createEscaping
(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 String
eraseEscaping
(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 String
Returns abbreviation in format [Entity]:[V/D/C]:[friendlyName] [Entity] is something like 'U' for user, 'G-R' for group-resource etc.static CoreConfig
static DateFormat
Method 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 DateFormat
Method create formatter with default settings for perun timestamps (only date without time) and set lenient on false.static JavaMailSender
Return instance of JavaMailSender with shared Perun configuration used to send mail notifications by.static String
getPropertyFromCustomConfiguration
(String propertyFile, String propertyName) Gets particular property from custom property file.static Integer
getSingleId
(Set<Pair<Integer, Integer>> pairs) getSinglePair
(Set<Pair<Integer, Integer>> pairs) static boolean
True if DB initializator is enabled, false if not Default is falsestatic boolean
Return true, if char on position in text is escaped by '\' Return false, if not.static boolean
True if this instance of perun is read only.static void
Checks whether the object is null or not.static String
parseEscapedListValue
(String value) From the given list, parses all values separated by the comma ',' char.static String
prepareInSqlClause
(String identifier, List<? extends PerunBean> beans) Create a string with set of IN clause.static String
prepareInSqlClause
(List<Integer> beansIds, String identifier) Create a string with set of IN clause.static String
This method get text and all escaped \0 replace for text nullstatic String
This method get text and all nonescaped characters invalid input: '<' and > replace by apostrophestatic void
setConfig
(CoreConfig coreConfig) Set configuration that can be later queried by getCoreConfig().static Object
stringToAttributeValue
(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
-
getDateFormatter
Method 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
-
getDateFormatterWithoutTime
Method 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
-
eraseEscaping
This 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
-
createEscaping
This 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
-
replacePointyBracketsByApostrophe
This 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 '
-
replaceEscapedNullByStringNull
This method get text and all escaped \0 replace for text null- Parameters:
text
-- Returns:
- text where \0 is replaced for null
-
isEscaped
Return true, if char on position in text is escaped by '\' Return false, if not.- Parameters:
text
- text in which will be searchingposition
- position in text invalid input: '<'0-text.length>- Returns:
- true if char is escaped, false if not
-
attributeValueToString
Converts 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 attributetype
- type of resulting attribute- Returns:
- string representation of the value
- Throws:
InternalErrorException
- See Also:
-
attributeValueToString
Converts attribute value to string (for storing into DB)- Parameters:
attribute
- value of the attribute- Returns:
- string representation of the value
- Throws:
InternalErrorException
-
deserializeStringToMap
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. - Parameters:
text
- text from which will be parsed map- Returns:
- mapinvalid input: '<'string, string> attributes
-
parseEscapedListValue
From 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
-
stringToAttributeValue
Converts string representation of an attribute value to correct java object- Parameters:
stringValue
- string representation of the attribute valuetype
- type of the value ("Java.lang.String" for example)/- Returns:
- Throws:
InternalErrorException
-
stringToMapOfAttributes
Converts 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.
-
convertRichBeanNameToBeanName
Take 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)
-
prepareInSqlClause
Create 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
-
prepareInSqlClause
Create 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
-
getPropertyFromCustomConfiguration
Gets particular property from custom property file.- Parameters:
propertyFile
- name of properties filepropertyName
- name of the property- Returns:
- value of the property
-
getAllPropertiesFromCustomConfiguration
Gets all properties from custom property file.- Parameters:
propertyFile
- name of properties file- Returns:
- all properties with values
-
isPerunReadOnly
public static boolean isPerunReadOnly()True if this instance of perun is read only. False if not.- Returns:
- true or false (readOnly or not)
-
initializatorEnabled
public static boolean initializatorEnabled()True if DB initializator is enabled, false if not Default is false- Returns:
- true if enabled, false if disabled
-
notNull
Checks whether the object is null or not.- Parameters:
e
-name
-- Throws:
InternalErrorException
- which wraps NullPointerException
-
setConfig
Set configuration that can be later queried by getCoreConfig(). -
getCoreConfig
-
getSinglePair
-
getSingleId
-
getAttributeDefinitionAbbreviation
Returns 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
-
getDefaultMailSender
Return instance of JavaMailSender with shared Perun configuration used to send mail notifications by.- Returns:
- single instance of JavaMailSender
-
convertRichMemberToCandidate
public 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
-
additionalIdentifiersIntersection
public 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 identifierssecondAdditionalIdentifiers
- second parameter which contains additional identifiers- Returns:
- Intersection of the given String parameters
-