/** * @see nu.validator.checker.Checker#startElement(java.lang.String, java.lang.String, * java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { if ("http://www.w3.org/1999/xhtml" == uri) { if ("img" == localName) { if (atts.getIndex("", "border") > -1) { warn( "The \u201Cborder\u201D attribute is obsolete." + " Consider specifying \u201Cimg { border: 0; }\u201D" + " in CSS instead."); } } else if ("script" == localName) { if (AttributeUtil.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "javascript", atts.getValue("", "language"))) { String type = atts.getValue("", "type"); if (type == null || AttributeUtil.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "text/javascript", type)) { warn( "The \u201Clanguage\u201D attribute on the" + " \u201Cscript\u201D element is obsolete." + " You can safely omit it."); } } } else if ("a" == localName) { if (atts.getIndex("", "name") > -1) { warn( "The \u201Cname\u201D attribute is obsolete." + " Consider putting an \u201Cid\u201D attribute" + " on the nearest container instead."); } } } }
/** * Return the enabled status of the account. * * <p>If the ENABLE operational attribute is present, it's value takes precedence over the current * value. If it is missing, the currentlyEnabled status is returned instead. * * @param defaultTo the default state if enable is not found. * @return true if the account is enabled, false otherwise */ public boolean getEnabled(boolean defaultTo) { boolean result = defaultTo; final Attribute enable = find(OperationalAttributes.ENABLE_NAME); if (enable != null) { result = AttributeUtil.getBooleanValue(enable); } return result; }
/** * Maps the attributes. * * @param source The source object. * @param target The target object. */ public void mapAttributes(final AttributeSource source, final AttributeSink target) { if (source == null) { throw new IllegalArgumentException( getClass().getName() + ": source object must not be null."); } if (target == null) { throw new IllegalArgumentException( getClass().getName() + ": target object must not be null."); } for (final Map.Entry<String, String> entry : this.attributeMap.entrySet()) { final String sourceAttr = entry.getKey(); final String targetAttr = entry.getValue(); LOGGER.trace("\t'" + sourceAttr + "'--> '" + targetAttr + "'"); AttributeUtil.copyValues(source, sourceAttr, target, targetAttr); } }
/** * Get the map value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the map value. * @return null if the value is null otherwise the map value for the attribute. * @throws ClassCastException if the object in the attribute is not a map. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public Map<String, Object> findMap(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getMapValue(attribute); }
/** * Get the guarded string value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the guarded string value. * @return null if the value is null otherwise the guarded string value for the attribute. * @throws ClassCastException if the object in the attribute is not a guarded string. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public GuardedString findGuardedString(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getGuardedStringValue(attribute); }
/** * Get the guarded byte array value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the guarded byte array value. * @return null if the value is null otherwise the guarded byte array value for the attribute. * @throws ClassCastException if the object in the attribute is not a guarded byte array. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public GuardedByteArray findGuardedByteArray(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getGuardedByteArrayValue(attribute); }
/** * Get the big integer value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the big integer value. * @return null if the value is null otherwise the big integer value for the attribute. * @throws ClassCastException if the object in the attribute is not a big integer. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public BigInteger findBigInteger(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getBigIntegerValue(attribute); }
/** * Get the byte array value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the byte array value. * @return null if the value is null otherwise the byte array value for the attribute. * @throws ClassCastException if the object in the attribute is not a byte. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public Byte[] findByteArray(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getByteArrayValue(attribute); }
/** * Get the boolean value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the boolean value. * @return null if the value is null otherwise the boolean value for the attribute. * @throws ClassCastException if the object in the attribute is not an {@link Boolean}. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). */ public Boolean findBoolean(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getBooleanValue(attribute); }
/** * Get the float value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the float value. * @return null if the value is null otherwise the float value for the attribute. * @throws ClassCastException if the object in the attribute is not a float. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public Float findFloat(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getFloatValue(attribute); }
/** * Get the double value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the double value. * @return null if the value is null otherwise the double value for the attribute. * @throws ClassCastException if the object in the attribute is not a double. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued).. */ public Double findDouble(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getDoubleValue(attribute); }
/** * Get the long value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the long value. * @return null if the value is null otherwise the long value for the attribute. * @throws ClassCastException if the object in the attribute is not an long. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). */ public Long findLong(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getLongValue(attribute); }
/** * Get the integer value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the long value. * @return null if the value is null otherwise the long value for the attribute. * @throws ClassCastException if the object in the attribute is not an long. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). */ public Integer findInteger(final String name) { final Attribute attribute = find(name); return (attribute == null) ? null : AttributeUtil.getIntegerValue(attribute); }
/** * Get the character value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the character value. * @return null if the value is null otherwise the character value for the attribute. * @throws ClassCastException if the object in the attribute is not a character. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). * @since 1.4 */ public Character findCharacter(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getCharacterValue(attribute); }
/** * Get the password as a GuardeString. * * @return the password as a guarded String */ public GuardedString getPassword() { final Attribute attribute = find(OperationalAttributes.PASSWORD_NAME); return attribute == null ? null : AttributeUtil.getGuardedStringValue(attribute); }
public AttributesAccessor(final Set<Attribute> attrs) { attributeMap = AttributeUtil.toMap(attrs); }
/** * Get the big decimal value from the specified (single-valued) attribute. * * @param name Attribute from which to retrieve the big decimal value. * @return null if the value is null otherwise the big decimal value for the attribute. * @throws ClassCastException if the object in the attribute is not an big decimal. * @throws IllegalArgumentException if the attribute is a multi-valued (rather than * single-valued). */ public BigDecimal findBigDecimal(final String name) { final Attribute attribute = find(name); return attribute == null ? null : AttributeUtil.getBigDecimalValue(attribute); }
/** * Add the attribute to the builder * * @param oclass * @param attr * @param options */ public void setAttribute(ObjectClass oclass, Attribute attr, OperationOptions options) { log.ok("Account: getSQLParam"); // At first, couldn't do anything to null fields except make sql call // updating tables directly. Bug#9005 forced us to find oracle constants // to do this. // I couldn't null out fields with Oracle constants thru callablestatement, // instead, collect all null fields and make a preparedstatement call to // api with null fields. // Handle the special attributes first to use them in decission later if (attr.is(Name.NAME)) { // cstmt1.setString(1, identity.toUpperCase()); final String userName = AttributeUtil.getAsStringValue(attr).toUpperCase(); setSqlValue(USER_NAME, userName); } else if (attr.is(Uid.NAME)) { // cstmt1.setString(1, identity.toUpperCase()); final String userName = AttributeUtil.getAsStringValue(attr).toUpperCase(); setSqlValue(USER_NAME, userName); } else if (StringUtil.isNotBlank(cfg.getPasswordAttribute()) && attr.is(cfg.getPasswordAttribute())) { /* * cstmt1.setString(3, (String)accountAttrChanges.get(UNENCRYPT_PWD)); * only set 'password_date' if password changed * if ((String)accountAttrChanges.get(UNENCRYPT_PWD) != null) { * cstmt1.setDate(9, new java.sql.Date( * (new java.util.Date().getTime()) )); */ if (AttributeUtil.getSingleValue(attr) != null) { resourcePassword = AttributeUtil.getGuardedStringValue(attr); } } else if (attr.is(OperationalAttributes.PASSWORD_NAME)) { /* * cstmt1.setString(3, (String)accountAttrChanges.get(UNENCRYPT_PWD)); * only set 'password_date' if password changed * if ((String)accountAttrChanges.get(UNENCRYPT_PWD) != null) { * cstmt1.setDate(9, new java.sql.Date( * (new java.util.Date().getTime()) )); */ if (AttributeUtil.getSingleValue(attr) != null) { password = AttributeUtil.getGuardedStringValue(attr); } } else if (attr.is(OperationalAttributes.PASSWORD_EXPIRED_NAME) || attr.is(EXP_PWD)) { /* ------ adapter code ---------- * Boolean expirePassword = null; * if ( ((String)accountAttrChanges.get("OPERATION")).equalsIgnoreCase("CREATE") ) { * if (accountAttrChanges.containsKey(EXP_PWD)) { * expirePassword = ((Boolean)accountAttrChanges.get(EXP_PWD)); * if (expirePassword.booleanValue()) { * nullFields.append(",x_last_logon_date => FND_USER_PKG.null_date"); * nullFields.append(",x_password_date => FND_USER_PKG.null_date"); * } else { * cstmt1.setDate(7, new java.sql.Date( * (new java.util.Date().getTime()) )); * } * } else { * cstmt1.setDate(7, new java.sql.Date( * (new java.util.Date().getTime()) )); * } * } else if ( ((String)accountAttrChanges.get("OPERATION")).equalsIgnoreCase("UPDATE") ) { * if (accountAttrChanges.containsKey(EXP_PWD)) { * expirePassword = ((Boolean)accountAttrChanges.get(EXP_PWD)); * if (expirePassword.booleanValue()) { * nullFields.append(",x_last_logon_date => FND_USER_PKG.null_date"); * nullFields.append(",x_password_date => FND_USER_PKG.null_date"); * } * } * } * * Handle expiring password differently in create vs update * On create if expirePassword is false/null, set last_logon_date to today * On update if expirePassword is false/null, do nothing * On both is if expirePassword is true, null out last_logon_date, and password_date */ boolean passwordExpired = false; if (AttributeUtil.getSingleValue(attr) != null) { passwordExpired = AttributeUtil.getBooleanValue(attr); } if (passwordExpired) { setNullValue(LAST_LOGON_DATE, NULL_DATE); log.ok("passwordExpired: {0} => NULL_DATE", LAST_LOGON_DATE); setNullValue(PWD_DATE, NULL_DATE); log.ok("append also {0} => NULL_DATE", PWD_DATE); } else if (create) { setSqlValue(LAST_LOGON_DATE, currentDate); log.ok( "create account with not expired password {0} => {1}", LAST_LOGON_DATE, currentDate); } } else if (attr.is(OWNER)) { // cstmt1.setString(2, (String)accountAttrChanges.get(OWNER)); final String owner = AttributeUtil.getAsStringValue(attr); setSqlValue(OWNER, owner); log.ok("{0} = > {1}, Types.VARCHAR", OWNER, owner); } else if (attr.is(START_DATE) || attr.is(OperationalAttributes.ENABLE_DATE_NAME)) { /* ------ adapter code ---------- * start_date 'not null' type * if (accountAttrChanges.containsKey(START_DATE)) { * if (accountAttrChanges.get(START_DATE) != null) { * cstmt1.setTimestamp(5, java.sql.Timestamp.valueOf((String)accountAttrChanges.get(START_DATE)) ); * } * } */ final String dateString = AttributeUtil.getAsStringValue(attr); if (dateString != null) { Timestamp tms = stringToTimestamp(dateString); // stringToTimestamp(dateString); setSqlValue(START_DATE, tms); log.ok("{0} => {1} , Types.TIMESTAMP", START_DATE, tms); } } else if (attr.is(END_DATE) || attr.is(OperationalAttributes.DISABLE_DATE_NAME)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(END_DATE)) { * if (accountAttrChanges.get(END_DATE) == null) { * nullFields.append(",x_end_date => FND_USER_PKG.null_date"); * } else if ( ((String)accountAttrChanges.get(END_DATE)).equalsIgnoreCase(SYSDATE)) { * // force sysdate into end_date * nullFields.append(",x_end_date => sysdate"); * } else { * cstmt1.setTimestamp(6, java.sql.Timestamp.valueOf( * (String)accountAttrChanges.get(END_DATE)) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(END_DATE, NULL_DATE); log.ok("NULL {0} => NULL_DATE : continue", END_DATE); } else { final String dateString = AttributeUtil.getAsStringValue(attr); if (SYSDATE.equalsIgnoreCase(dateString)) { setNullValue(END_DATE, SYSDATE); log.ok("sysdate value in {0} => {1} : continue", END_DATE, SYSDATE); } else { Timestamp tms = stringToTimestamp(dateString); setSqlValue(END_DATE, tms); log.ok("{0} => {1}, Types.TIMESTAMP", END_DATE, tms); } } } else if (attr.is(DESCR)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(DESCR)) { * if (accountAttrChanges.get(DESCR) == null) { * nullFields.append(",x_description => FND_USER_PKG.null_char"); * } else { * cstmt1.setString(8, (String)accountAttrChanges.get(DESCR)); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(DESCR, NULL_CHAR); log.ok("NULL {0} => NULL_CHAR", DESCR); } else { final String descr = AttributeUtil.getAsStringValue(attr); setSqlValue(DESCR, descr); log.ok("{0} => {1}, Types.VARCHAR", DESCR, descr); } } else if (attr.is(PWD_ACCESSES_LEFT)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(PWD_ACCESSES_LEFT)) { * if ( (accountAttrChanges.get(PWD_ACCESSES_LEFT) == null) || * ( ((String)accountAttrChanges.get(PWD_ACCESSES_LEFT)).length() == 0) ) { * nullFields.append(",x_password_accesses_left => FND_USER_PKG.null_number"); * } else { * cstmt1.setInt(10, (new Integer((String)accountAttrChanges.get(PWD_ACCESSES_LEFT)).intValue()) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(PWD_ACCESSES_LEFT, NULL_NUMBER); log.ok("NULL {0} => NULL_NUMBER", PWD_ACCESSES_LEFT); } else { final String accessLeft = AttributeUtil.getAsStringValue(attr); setSqlValue(PWD_ACCESSES_LEFT, new Integer(accessLeft)); log.ok("{0} => {1}, Types.INTEGER", DESCR, accessLeft); } } else if (attr.is(PWD_LIFESPAN_ACCESSES)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(PWD_LIFESPAN_ACCESSES)) { * if ( (accountAttrChanges.get(PWD_LIFESPAN_ACCESSES) == null) || * ( ((String)accountAttrChanges.get(PWD_LIFESPAN_ACCESSES)).length() == 0) ) { * nullFields.append(",x_password_lifespan_accesses => FND_USER_PKG.null_number"); * } else { * cstmt1.setInt(11, (new Integer((String)accountAttrChanges.get(PWD_LIFESPAN_ACCESSES)).intValue()) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(PWD_LIFESPAN_ACCESSES, NULL_NUMBER); log.ok("NULL {0} => NULL_NUMBER", PWD_LIFESPAN_ACCESSES); } else { final String lifeAccess = AttributeUtil.getAsStringValue(attr); setSqlValue(PWD_LIFESPAN_ACCESSES, new Integer(lifeAccess)); log.ok("{0} => {1}, Types.INTEGER", PWD_LIFESPAN_ACCESSES, lifeAccess); } } else if (attr.is(PWD_LIFESPAN_DAYS)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(PWD_LIFESPAN_DAYS)) { * if ( (accountAttrChanges.get(PWD_LIFESPAN_DAYS) == null) || * ( ((String)accountAttrChanges.get(PWD_LIFESPAN_DAYS)).length() == 0) ) { * nullFields.append(",x_password_lifespan_days => FND_USER_PKG.null_number"); * } else { * cstmt1.setInt(12, (new Integer((String)accountAttrChanges.get(PWD_LIFESPAN_DAYS)).intValue()) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(PWD_LIFESPAN_DAYS, NULL_NUMBER); log.ok("NULL {0} => NULL_NUMBER", PWD_LIFESPAN_DAYS); } else { final String lifeDays = AttributeUtil.getAsStringValue(attr); setSqlValue(PWD_LIFESPAN_DAYS, new Integer(lifeDays)); log.ok("{0} => {1}, Types.INTEGER", PWD_LIFESPAN_DAYS, lifeDays); } } else if (attr.is(EMP_ID)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(EMP_ID)) { * if ( (accountAttrChanges.get(EMP_ID) == null) || * ( ((String)accountAttrChanges.get(EMP_ID)).length() == 0) ) { * nullFields.append(",x_employee_id => FND_USER_PKG.null_number"); * } else { * cstmt1.setInt(13, (new Integer((String)accountAttrChanges.get(EMP_ID)).intValue()) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(EMP_ID, NULL_NUMBER); log.ok("NULL {0} => NULL_NUMBER", EMP_ID); } else { final String empId = AttributeUtil.getAsStringValue(attr); setSqlValue(EMP_ID, new Integer(empId)); log.ok("{0} => {1}, Types.INTEGER", EMP_ID, empId); } } else if (attr.is(EMAIL)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(EMAIL)) { * if (accountAttrChanges.get(EMAIL) == null) { * nullFields.append(",x_email_address => FND_USER_PKG.null_char"); * } else { * cstmt1.setString(14, (String)accountAttrChanges.get(EMAIL)); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(EMAIL, NULL_CHAR); log.ok("NULL {0} => NULL_CHAR", EMAIL); } else { final String email = AttributeUtil.getAsStringValue(attr); setSqlValue(EMAIL, email); log.ok("{0} => {1}, Types.VARCHAR", EMAIL, email); } } else if (attr.is(FAX)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(FAX)) { * if (accountAttrChanges.get(FAX) == null) { * nullFields.append(",x_fax => FND_USER_PKG.null_char"); * } else { * cstmt1.setString(15, (String)accountAttrChanges.get(FAX)); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(FAX, NULL_CHAR); log.ok("NULL {0} => NULL_CHAR", FAX); } else { final String fax = AttributeUtil.getAsStringValue(attr); setSqlValue(FAX, fax); log.ok("{0} => {1}, Types.VARCHAR", FAX, fax); } } else if (attr.is(CUST_ID)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(CUST_ID)) { * if ( (accountAttrChanges.get(CUST_ID) == null) || * ( ((String)accountAttrChanges.get(CUST_ID)).length() == 0) ) { * nullFields.append(",x_customer_id => FND_USER_PKG.null_number"); * } else { * cstmt1.setInt(16, (new Integer((String)accountAttrChanges.get(CUST_ID)).intValue()) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(CUST_ID, NULL_NUMBER); log.ok("NULL {0} => NULL_NUMBER", CUST_ID); } else { final String custId = AttributeUtil.getAsStringValue(attr); setSqlValue(CUST_ID, new Integer(custId)); log.ok("{0} => {1}, Types.INTEGER", CUST_ID, custId); } } else if (attr.is(SUPP_ID)) { /* ------ adapter code ---------- * if (accountAttrChanges.containsKey(SUPP_ID)) { * if ( (accountAttrChanges.get(SUPP_ID) == null) || * ( ((String)accountAttrChanges.get(SUPP_ID)).length() == 0) ) { * nullFields.append(",x_supplier_id => FND_USER_PKG.null_number"); * } else { * cstmt1.setInt(17, (new Integer((String)accountAttrChanges.get(SUPP_ID)).intValue()) ); * } * } */ if (AttributeUtil.getSingleValue(attr) == null) { setNullValue(SUPP_ID, NULL_NUMBER); log.ok("NULL {0} => NULL_NUMBER", SUPP_ID); } else { final String suppId = AttributeUtil.getAsStringValue(attr); setSqlValue(SUPP_ID, new Integer(suppId)); log.ok("{0} => {1}, Types.INTEGER", SUPP_ID, suppId); } } }