@Nonnull public MockHttpServletRequest addUserRole (@Nullable final String sRole) { m_aUserRoles.add (sRole); return this; }
public TestResource (@Nonnull final IReadableResource aRes, @Nullable final ICommonsSet <ErrorDefinition> aExpectedErrors) { ValueEnforcer.notNull (aRes, "Resource"); m_aRes = aRes; if (aExpectedErrors != null) for (final ErrorDefinition aExpectedError : aExpectedErrors) if (aExpectedError != null) m_aExpectedErrors.add (aExpectedError); }
public ICommonsList <String> getPropertyGroups (final String sPrefix) { final ICommonsSet <String> groups = new CommonsLinkedHashSet <> (10); String sRealPrefix = sPrefix; if (!sRealPrefix.endsWith (".")) sRealPrefix += "."; for (final String sKey : m_aProps.keySet ()) { if (sKey.startsWith (sRealPrefix)) { final String groupName = sKey.substring (sRealPrefix.length (), sKey.indexOf ('.', sRealPrefix.length ())); groups.add (groupName); } } return groups.getCopyAsList (); }
public CSSPropertyEnum (@Nonnull final ECSSProperty eProp, @Nullable final ECSSVendorPrefix eVendorPrefix, @Nullable final ICSSPropertyCustomizer aCustomizer, @Nonnull @Nonempty final Iterable <String> aEnumValues) { super (eProp, eVendorPrefix, aCustomizer); ValueEnforcer.notEmptyNoNullValue (aEnumValues, "EnumValues"); m_aEnumValues = new CommonsHashSet<> (); for (final String sPotentialValue : aEnumValues) { if (StringHelper.hasNoText (sPotentialValue)) throw new IllegalArgumentException ("At least one enumeration value is empty"); m_aEnumValues.add (sPotentialValue); } }
public CSSPropertyEnum (@Nonnull final ECSSProperty eProp, @Nullable final ECSSVendorPrefix eVendorPrefix, @Nullable final ICSSPropertyCustomizer aCustomizer, @Nonnull @Nonempty final String... aEnumValues) { super (eProp, eVendorPrefix, aCustomizer); ValueEnforcer.notEmptyNoNullValue (aEnumValues, "EnumValues"); m_aEnumValues = new CommonsHashSet<> (aEnumValues.length); for (final String sPotentialValue : aEnumValues) { if (StringHelper.hasNoText (sPotentialValue)) throw new IllegalArgumentException ("At least one enumeration value is empty"); m_aEnumValues.add (sPotentialValue); } }
@Nullable public static IUserAgent getParsedUserAgent (@Nullable final String sUserAgent) { if (StringHelper.hasNoText (sUserAgent)) return null; // Decrypt outside the lock final IUserAgent aUserAgent = UserAgentDecryptor.decryptUserAgentString (sUserAgent); final boolean bAdded = s_aRWLock.writeLocked ( () -> s_aUniqueUserAgents.add (sUserAgent)); if (bAdded) { if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Found new UserAgent '" + sUserAgent + "'"); s_aRWLock.readLocked ( () -> { if (s_aNewUserAgentCallback != null) s_aNewUserAgentCallback.accept (aUserAgent); }); } return aUserAgent; }
@Nonnull public static UAProfile getParsedUAProfile (@Nonnull final IUAProfileHeaderProvider aHeaderProvider) { // Main extraction final UAProfile aUAProfile = getUAProfileFromRequest (aHeaderProvider); if (aUAProfile == null) return UAProfile.EMPTY; if (aUAProfile.isSet ()) { final boolean bAdded = s_aRWLock.writeLocked ( () -> s_aUniqueUAProfiles.add (aUAProfile)); if (bAdded) { if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Found UA-Profile info: " + aUAProfile.toString ()); if (s_aNewUAProfileCallback != null) s_aNewUAProfileCallback.accept (aUAProfile); } } return aUAProfile; }
@Nonnull @Nonempty public String createNewNonce () { return m_aRWLock.writeLocked ( () -> { String sNonce; int nCount = 0; do { // Ensure a unique nonce final byte [] aNonce = new byte [NONCE_BYTES]; VerySecureRandom.getInstance ().nextBytes (aNonce); sNonce = StringHelper.getHexEncoded (aNonce); // Avoid endless loop if (++nCount > 100) throw new IllegalStateException ("Failed to create a unique nonce after " + nCount + " tries!"); } while (!m_aNonces.add (sNonce)); return sNonce; }); }
@Nonnull private MapBasedNamespaceContext _addMapping (@Nonnull final String sPrefix, @Nonnull final String sNamespaceURI, final boolean bAllowOverwrite) { ValueEnforcer.notNull (sPrefix, "Prefix"); ValueEnforcer.notNull (sNamespaceURI, "NamespaceURI"); if (!bAllowOverwrite && m_aPrefix2NS.containsKey (sPrefix)) throw new IllegalArgumentException ("The prefix '" + sPrefix + "' is already registered to '" + m_aPrefix2NS.get (sPrefix) + "'!"); if (sPrefix.equals (XMLConstants.DEFAULT_NS_PREFIX)) m_sDefaultNamespaceURI = sNamespaceURI; m_aPrefix2NS.put (sPrefix, sNamespaceURI); m_aNS2Prefix.computeIfAbsent (sNamespaceURI, x -> new CommonsHashSet <> ()).add (sPrefix); return this; }
@Nonnull public EChange addItem (final int nIndex, @Nonnull final IJSPathProvider aJSPathProvider) { ValueEnforcer.notNull (aJSPathProvider, "JSPathProvider"); return m_aRWLock.writeLocked ( () -> { // Check uniqueness if (!m_aItems.add (aJSPathProvider)) return EChange.UNCHANGED; // Honour index if (nIndex >= 0) m_aList.add (nIndex, aJSPathProvider); else m_aList.add (aJSPathProvider); if (m_bIsCollected) _collectWarn ("Adding item " + aJSPathProvider + " after collection!"); return EChange.CHANGED; }); }
public void onLongRunningRequest (@Nonnull @Nonempty final String sUniqueRequestID, @Nonnull final IRequestWebScope aRequestScope, @Nonnegative final long nRunningMilliseconds) { if (m_aHandledLongRunning.add (sUniqueRequestID)) { onError ((Throwable) null, aRequestScope, "Long running request.", new StringMap ().add ("request-id", sUniqueRequestID) .add ("millisecconds", nRunningMilliseconds) .add ("URL", aRequestScope.getURL ())); } }
@Nonnull public EChange addItem (final int nIndex, @Nonnull final ICSSPathProvider aCSSPathProvider) { ValueEnforcer.notNull (aCSSPathProvider, "CSSPathProvider"); return m_aRWLock.writeLocked ( () -> { // Check uniqueness if (!m_aItems.add (aCSSPathProvider)) return EChange.UNCHANGED; // Honour index if (nIndex >= 0) m_aList.add (nIndex, aCSSPathProvider); else m_aList.add (aCSSPathProvider); if (m_bIsCollected) _collectWarn ("Adding item " + aCSSPathProvider + " after collection!"); return EChange.CHANGED; }); }
m_aRWLock.writeLocked ( () -> !m_aBlockedURIs.add (sBlockedURI));
try if (!m_aUniqueItems.add (aWorkItem))
resumedGroups.add (pausedJobGroup);
for (final TriggerKey triggerKey : keys) groups.add (triggerKey.getGroup ()); if (m_aTriggersByKey.get (triggerKey) != null)