Example usage for java.util Hashtable remove

List of usage examples for java.util Hashtable remove

Introduction

In this page you can find the example usage for java.util Hashtable remove.

Prototype

public synchronized V remove(Object key) 

Source Link

Document

Removes the key (and its corresponding value) from this hashtable.

Usage

From source file:org.agnitas.web.MailingStatAction.java

/**
 * Loads mailing statistics.//  w w w. j a v  a  2s  .c om
 */
protected void loadMailingStat(MailingStatForm aForm, HttpServletRequest req) {
    //set variables from form:

    MailingStat aMailStat = (MailingStat) getBean("MailingStat");
    aMailStat.setCompanyID(getCompanyID(req));
    int tid = aForm.getTargetID();
    aMailStat.setTargetID(tid);
    int mid = aForm.getMailingID();
    aMailStat.setMailingID(mid);

    if (aForm.getTargetIDs() != null) {
        LinkedList targets = aForm.getTargetIDs();
        int atid = aForm.getNextTargetID();
        if (targets.contains(new Integer(atid)) == false) {
            targets.add(new Integer(atid));
        }

        if (req.getParameter("delTargetID") != null) {
            if (targets.contains(new Integer(req.getParameter("delTargetID"))) && targets.size() > 1) {
                targets.remove(new Integer(req.getParameter("delTargetID")));
            }
        }
        aMailStat.setTargetIDs(targets);
    } else {
        LinkedList targets = new LinkedList();
        targets.add(new Integer(0));
        aMailStat.setTargetIDs(targets);
    }

    // if we come from the mailstat page itself, pass statValues data:
    if (req.getParameter("add.x") != null) {
        aMailStat.setStatValues(aForm.getStatValues());
    } else if (req.getParameter("delTargetID") != null) {
        // delete MailingStatEntry for targetID to be deleted:
        Hashtable tmpStatVal = aForm.getStatValues();
        if (tmpStatVal.containsKey(new Integer(req.getParameter("delTargetID")))) {
            tmpStatVal.remove(new Integer(req.getParameter("delTargetID")));
        }
        // and put the statValues in the MailingStat class:
        aMailStat.setStatValues(tmpStatVal);
    } else {
        // delete all stat info:
        LinkedList targets = new LinkedList();
        targets.add(new Integer(0));
        aMailStat.setTargetIDs(targets);
        Hashtable tmpStatVal = new Hashtable();
        aMailStat.setStatValues(tmpStatVal);
    }

    if (aMailStat.getMailingStatFromDB(this.getWebApplicationContext(),
            (Locale) req.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY)) == true) {
        // write results back to form:
        aForm.setCsvfile(aMailStat.getCsvfile());
        aForm.setClickSubscribers(aMailStat.getClickSubscribers());
        aForm.setClicks(aMailStat.getClicks());
        aForm.setOpenedMails(aMailStat.getOpenedMails());
        aForm.setOptOuts(aMailStat.getOptOuts());
        aForm.setBounces(aMailStat.getBounces());
        aForm.setTotalSubscribers(aMailStat.getTotalSubscribers());
        aForm.setValues(aMailStat.getValues());
        aForm.setMailingShortname(aMailStat.getMailingShortname());
        aForm.setMailingID(mid);
        aForm.setStatValues(aMailStat.getStatValues());
        aForm.setTargetIDs(aMailStat.getTargetIDs());
        aForm.setUrlNames(aMailStat.getUrls());
        aForm.setUrlShortnames(aMailStat.getUrlShortnames());
        aForm.setMaxblue(aMailStat.getMaxblue());
        aForm.setMaxNRblue(aMailStat.getMaxNRblue());
        aForm.setMaxSubscribers(aMailStat.getMaxSubscribers());
        aForm.setClickedUrls(aMailStat.getClickedUrls());
        aForm.setNotRelevantUrls(aMailStat.getNotRelevantUrls());
    } else {
        AgnUtils.logger().error("loadMailingStat: could not load mailing stats.");
    }
}

From source file:org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl.java

public void afterPropertiesSet() throws Exception {
    logger.debug("after Properties Set");
    // Check Anonymous bind

    Hashtable<String, String> env = new Hashtable<String, String>(authenticatedEnvironment.size());
    env.putAll(authenticatedEnvironment);
    env.remove(Context.SECURITY_PRINCIPAL);
    env.remove(Context.SECURITY_CREDENTIALS);
    if (isSSLSocketFactoryRequired()) {
        KeyStore trustStore = initTrustStore();
        AlfrescoSSLSocketFactory.initTrustedSSLSocketFactory(trustStore);
        env.put("java.naming.ldap.factory.socket", AlfrescoSSLSocketFactory.class.getName());
    }//  w ww  .ja v a 2  s  . c o  m
    try {
        new InitialDirContext(env);

        logger.warn("LDAP server supports anonymous bind " + env.get(Context.PROVIDER_URL));
    } catch (javax.naming.AuthenticationException ax) {

    } catch (AuthenticationNotSupportedException e) {

    } catch (NamingException nx) {
        logger.error("Unable to connect to LDAP Server; check LDAP configuration", nx);
        return;
    }

    // Simple DN and password

    env = new Hashtable<String, String>(authenticatedEnvironment.size());
    env.putAll(authenticatedEnvironment);
    env.put(Context.SECURITY_PRINCIPAL, "daftAsABrush");
    env.put(Context.SECURITY_CREDENTIALS, "daftAsABrush");
    if (isSSLSocketFactoryRequired()) {
        KeyStore trustStore = initTrustStore();
        AlfrescoSSLSocketFactory.initTrustedSSLSocketFactory(trustStore);
        env.put("java.naming.ldap.factory.socket", AlfrescoSSLSocketFactory.class.getName());
    }
    try {

        new InitialDirContext(env);

        throw new AuthenticationException("The ldap server at " + env.get(Context.PROVIDER_URL)
                + " falls back to use anonymous bind if invalid security credentials are presented. This is not supported.");
    } catch (javax.naming.AuthenticationException ax) {
        logger.info("LDAP server does not fall back to anonymous bind for a string uid and password at "
                + env.get(Context.PROVIDER_URL));
    } catch (AuthenticationNotSupportedException e) {
        logger.info("LDAP server does not fall back to anonymous bind for a string uid and password at "
                + env.get(Context.PROVIDER_URL));
    } catch (NamingException nx) {
        logger.info("LDAP server does not support simple string user ids and invalid credentials at "
                + env.get(Context.PROVIDER_URL));
    }

    // DN and password

    env = new Hashtable<String, String>(authenticatedEnvironment.size());
    env.putAll(authenticatedEnvironment);
    env.put(Context.SECURITY_PRINCIPAL, "cn=daftAsABrush,dc=woof");
    env.put(Context.SECURITY_CREDENTIALS, "daftAsABrush");
    if (isSSLSocketFactoryRequired()) {
        KeyStore trustStore = initTrustStore();
        AlfrescoSSLSocketFactory.initTrustedSSLSocketFactory(trustStore);
        env.put("java.naming.ldap.factory.socket", AlfrescoSSLSocketFactory.class.getName());
    }
    try {

        new InitialDirContext(env);

        throw new AuthenticationException("The ldap server at " + env.get(Context.PROVIDER_URL)
                + " falls back to use anonymous bind if invalid security credentials are presented. This is not supported.");
    } catch (javax.naming.AuthenticationException ax) {
        logger.info("LDAP server does not fall back to anonymous bind for a simple dn and password at "
                + env.get(Context.PROVIDER_URL));
    } catch (AuthenticationNotSupportedException e) {
        logger.info("LDAP server does not fall back to anonymous bind for a simple dn and password at "
                + env.get(Context.PROVIDER_URL));
    } catch (NamingException nx) {
        logger.info("LDAP server does not support simple DN and invalid password at "
                + env.get(Context.PROVIDER_URL));
    }

    // Check more if we have a real principal we expect to work

    String principal = defaultEnvironment.get(Context.SECURITY_PRINCIPAL);
    if (principal != null) {
        // Correct principal invalid password

        env = new Hashtable<String, String>(authenticatedEnvironment.size());
        env.putAll(authenticatedEnvironment);
        env.put(Context.SECURITY_PRINCIPAL, principal);
        env.put(Context.SECURITY_CREDENTIALS, "sdasdasdasdasd123123123");
        if (isSSLSocketFactoryRequired()) {
            KeyStore trustStore = initTrustStore();
            AlfrescoSSLSocketFactory.initTrustedSSLSocketFactory(trustStore);
            env.put("java.naming.ldap.factory.socket", AlfrescoSSLSocketFactory.class.getName());
        }
        if (!checkedEnvs.contains(env)) {

            try {

                new InitialDirContext(env);

                throw new AuthenticationException("The ldap server at " + env.get(Context.PROVIDER_URL)
                        + " falls back to use anonymous bind for a known principal if  invalid security credentials are presented. This is not supported.");
            } catch (javax.naming.AuthenticationException ax) {
                logger.info(
                        "LDAP server does not fall back to anonymous bind for known principal and invalid credentials at "
                                + env.get(Context.PROVIDER_URL));
            } catch (AuthenticationNotSupportedException e) {
                logger.info("LDAP server does not support the required authentication mechanism");
            } catch (NamingException nx) {
                // already done
            }
            // Record this environment as checked so that we don't check it again on further restarts / other subsystem
            // instances
            checkedEnvs.add(env);
        }
    }
}

From source file:adams.flow.control.TimedSubProcess.java

/**
 * Restores the state of the actor before the variables got updated.
 *
 * @param state   the backup of the state to restore from
 *//*  w  w  w. j a v a  2 s  . c  o  m*/
@Override
protected void restoreState(Hashtable<String, Object> state) {
    super.restoreState(state);

    if (state.containsKey(BACKUP_CALLABLEACTOR)) {
        m_CallableActor = (Actor) state.get(BACKUP_CALLABLEACTOR);
        state.remove(BACKUP_CALLABLEACTOR);
    }

    if (state.containsKey(BACKUP_CONFIGURED)) {
        m_Configured = (Boolean) state.get(BACKUP_CONFIGURED);
        state.remove(BACKUP_CONFIGURED);
    }
}

From source file:ORG.oclc.os.SRW.HouseKeeping.java

public void run() {
    Enumeration enumer, enum2;
    Hashtable sortedResults;
    long now = System.currentTimeMillis(), when;
    QueryResult result, sortedResult;/*  w  w w .  j  av  a2s.com*/
    String key, resultSetName;
    for (enumer = timers.keys(); enumer.hasMoreElements();) {
        resultSetName = (String) enumer.nextElement();
        when = ((Long) timers.get(resultSetName)).longValue();
        if (when < now) {
            log.debug("removing resultSet " + resultSetName);
            result = (QueryResult) oldResultSets.remove(resultSetName);
            sortedResults = result.getSortedResults();
            enum2 = sortedResults.keys();
            while (enum2.hasMoreElements()) {
                key = (String) enum2.nextElement();
                sortedResult = (QueryResult) sortedResults.remove(key);
                sortedResult.close();
            }
            result.close();
            timers.remove(resultSetName);
        }
    }
}

From source file:org.wso2.carbon.event.output.adapter.jms.JMSEventAdapter.java

private PublisherDetails initPublisher(OutputEventAdapterConfiguration outputEventAdaptorConfiguration,
        Map<String, String> messageConfig) {

    PublisherDetails publisherDetails;//  w  w w .j a  v a  2 s  .  c  o m
    Hashtable<String, String> adapterProperties = convertMapToHashTable(
            outputEventAdaptorConfiguration.getStaticProperties());

    Map<String, String> jmsProperties = this.extractProperties(
            eventAdapterConfiguration.getStaticProperties().get(JMSEventAdapterConstants.ADAPTER_PROPERTIES));

    Map<String, String> jmsSecuredProperties = this.extractProperties(eventAdapterConfiguration
            .getStaticProperties().get(JMSEventAdapterConstants.ADAPTER_SECURED_PROPERTIES));

    if (jmsProperties != null) {
        adapterProperties.remove(JMSEventAdapterConstants.ADAPTER_PROPERTIES);
        adapterProperties.putAll(jmsProperties);
    }

    if (jmsSecuredProperties != null) {
        adapterProperties.remove(JMSEventAdapterConstants.ADAPTER_SECURED_PROPERTIES);
        adapterProperties.putAll(jmsSecuredProperties);
    }

    int maxConnections;
    if (JMSEventAdapterConstants.ADAPTER_JMS_ALLOW_CONCURRENT_CONNECTIONS_NOT_ALLOWED
            .equals(eventAdapterConfiguration.getStaticProperties()
                    .get(JMSEventAdapterConstants.ADAPTER_JMS_ALLOW_CONCURRENT_CONNECTIONS))) {
        maxConnections = 1;
    } else if (globalProperties.get(JMSEventAdapterConstants.ADAPTER_MAX_THREAD_POOL_SIZE_NAME) != null) {
        maxConnections = Integer
                .parseInt(globalProperties.get(JMSEventAdapterConstants.ADAPTER_MAX_THREAD_POOL_SIZE_NAME));
    } else {
        maxConnections = JMSEventAdapterConstants.ADAPTER_MAX_THREAD_POOL_SIZE;
    }

    JMSConnectionFactory jmsConnectionFactory = new JMSConnectionFactory(adapterProperties,
            outputEventAdaptorConfiguration.getName(),
            messageConfig.get(JMSEventAdapterConstants.ADAPTER_JMS_DESTINATION), maxConnections);
    JMSMessageSender jmsMessageSender = new JMSMessageSender(jmsConnectionFactory);
    publisherDetails = new PublisherDetails(jmsConnectionFactory, jmsMessageSender, messageConfig);

    return publisherDetails;
}

From source file:org.apache.axis2.transport.mail.EMailSender.java

private void sendReceive(MessageContext msgContext, String msgId) throws AxisFault {
    storeMessageContext(msgContext, msgId);
    ConfigurationContext cc = msgContext.getConfigurationContext();
    //While sysncmial listner .not complete
    Options options = msgContext.getOptions();
    long outInMilliSeconds = options.getTimeOutInMilliSeconds();
    SynchronousMailListener synchronousMailListener = null;
    //No need to stor the message context if the mep is out-only
    AxisOperation axisOperation = msgContext.getAxisOperation();
    // piggy back message constant is used to pass a piggy back
    // message context in asnych model
    if (axisOperation instanceof OutOnlyAxisOperation
            && (msgContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null)) {
        return;/*w  w w  .ja va2  s .  c o m*/
    }

    if (!options.isUseSeparateListener() && !msgContext.isServerSide()) {
        if (!cc.getListenerManager().isListenerRunning(Constants.MAILTO)) {
            TransportInDescription mailTo = cc.getAxisConfiguration().getTransportIn(Constants.MAILTO);
            if (mailTo == null) {
                throw new AxisFault("Could not found transport for " + Constants.MAILTO);
            }
            cc.getListenerManager().addListener(mailTo, false);
        }
        Hashtable callBackTable = (Hashtable) cc.getProperty(Constants.CALLBACK_TABLE);

        if (callBackTable != null) {
            synchronousMailListener = new SynchronousMailListener(messageContext, outInMilliSeconds);
            callBackTable.put(msgId, synchronousMailListener);
        }
        while (!synchronousMailListener.isComplete()) {
            try {
                Thread.sleep(6000);
            } catch (InterruptedException e) {
                throw new AxisFault(e.getMessage(), e);
            }
        }
        callBackTable.remove(msgId);
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java

/**
 * Given a list of locale pairs, remove them from the list of all locale
 * pairs. Then create a hashtable where the key is the source locale, and
 * the value is all possible target locales.
 * //from w w w  .j av a 2 s. c  om
 */
public static Hashtable getRemainingLocales(List currentLocales) throws EnvoyServletException {
    Hashtable remaining = new Hashtable();
    Vector sourceLocales = UserHandlerHelper.getAllSourceLocales();
    for (int i = 0; i < sourceLocales.size(); i++) {
        GlobalSightLocale curLocale = (GlobalSightLocale) sourceLocales.elementAt(i);
        Vector validTargets = UserHandlerHelper.getTargetLocales(curLocale);
        remaining.put(curLocale, validTargets);
    }

    // Now that we have a hashtable of all valid source locales and
    // their target locales, removes the ones that already exist for
    // this vendor.
    for (int i = 0; i < currentLocales.size(); i++) {
        LocalePair pair = (LocalePair) currentLocales.get(i);
        GlobalSightLocale target = pair.getTarget();
        Vector targets = (Vector) remaining.get(pair.getSource());
        if (targets != null && targets.contains(target)) {
            targets.remove(target);
            if (targets.size() == 0) {
                // no valid targets left so remove the entry in the hash
                remaining.remove(pair.getSource());
            }
        }
    }

    return remaining;
}

From source file:org.apache.pig.impl.logicalLayer.LOFRJoin.java

@Override
/**/*from   w w  w  .  j av a2 s  . co  m*/
 * Uses the schema from its input operators and dedups
 * those fields that have the same alias and sets the
 * schema for the join
 */
public Schema getSchema() throws FrontendException {
    List<LogicalOperator> inputs = mPlan.getPredecessors(this);
    mType = DataType.BAG;//mType is from the super class
    Hashtable<String, Integer> nonDuplicates = new Hashtable<String, Integer>();
    if (!mIsSchemaComputed) {
        List<Schema.FieldSchema> fss = new ArrayList<Schema.FieldSchema>();
        int i = -1;
        for (LogicalOperator op : inputs) {
            try {
                Schema cSchema = op.getSchema();
                if (cSchema != null) {

                    for (FieldSchema schema : cSchema.getFields()) {
                        ++i;
                        if (nonDuplicates.containsKey(schema.alias)) {
                            if (nonDuplicates.get(schema.alias) != -1) {
                                nonDuplicates.remove(schema.alias);
                                nonDuplicates.put(schema.alias, -1);
                            }
                        } else
                            nonDuplicates.put(schema.alias, i);
                        FieldSchema newFS = new FieldSchema(op.getAlias() + "::" + schema.alias, schema.schema,
                                schema.type);
                        newFS.setParent(schema.canonicalName, op);
                        fss.add(newFS);
                    }
                } else
                    fss.add(new FieldSchema(null, DataType.BYTEARRAY));
            } catch (FrontendException ioe) {
                mIsSchemaComputed = false;
                mSchema = null;
                throw ioe;
            }
        }
        mIsSchemaComputed = true;
        for (Entry<String, Integer> ent : nonDuplicates.entrySet()) {
            int ind = ent.getValue();
            if (ind == -1)
                continue;
            FieldSchema prevSch = fss.get(ind);
            fss.set(ind, new FieldSchema(ent.getKey(), prevSch.schema, prevSch.type));
        }
        mSchema = new Schema(fss);
    }
    return mSchema;
}

From source file:edu.ku.brc.af.ui.forms.persist.ViewLoader.java

/**
 * Re-maps and clones the definitions.// ww w  .ja v  a2  s . com
 * @param viewDefs the hash table to be mapped
 * @throws Exception
 */
public static void mapDefinitionViewDefs(final Hashtable<String, ViewDefIFace> viewDefs) throws Exception {
    // Now that all the definitions have been read in
    // cycle thru and have all the tableform objects clone there definitions
    for (ViewDefIFace viewDef : new Vector<ViewDefIFace>(viewDefs.values())) {
        if (viewDef.getType() == ViewDefIFace.ViewType.formtable) {
            String viewDefName = ((FormViewDefIFace) viewDef).getDefinitionName();
            if (viewDefName != null) {
                //log.debug(viewDefName);
                ViewDefIFace actualDef = viewDefs.get(viewDefName);
                if (actualDef != null) {
                    viewDefs.remove(viewDef.getName());
                    actualDef = (ViewDef) actualDef.clone();
                    actualDef.setType(ViewDefIFace.ViewType.formtable);
                    actualDef.setName(viewDef.getName());
                    viewDefs.put(actualDef.getName(), actualDef);

                } else {
                    String msg = "Couldn't find the ViewDef for formtable definition name["
                            + ((FormViewDefIFace) viewDef).getDefinitionName() + "]";
                    log.error(msg);
                    FormDevHelper.appendFormDevError(msg);
                }
            }
        }
    }
}

From source file:DDTDate.java

/**
 * Replenish a single property in the variables map varsMap
 * @param key/*from  www .j a  va 2  s .co m*/
 * @param value
 * @param varsMap
 */
private void maintainDateProperty(String key, Object value, Hashtable<String, Object> varsMap) {
    String tmp = key.toLowerCase(); // varsMap is maintained in lower case by convention
    Object oldValue = varsMap.get(tmp);
    if (oldValue != null) {
        // Change value in varsMap only if needed.
        if (oldValue.equals(value))
            return;
        varsMap.remove(tmp);
    }

    varsMap.put(tmp, String.valueOf(value));

    // Reporting ... @TODO comment out when done testing (thanks) (you are welcome)
    /*
          if (oldValue == null)
             System.out.println(" key " + Util.sq(key) + " set to " + Util.sq(value.toString()) + " in the variables map.");
          else
             System.out.println("Old version of key " + Util.sq(key) + " => " + Util.sq(oldValue.toString()) + " reset to " + Util.sq(value.toString()) + " in the variables map.");
    */

}