Example usage for java.util HashMap remove

List of usage examples for java.util HashMap remove

Introduction

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

Prototype

public V remove(Object key) 

Source Link

Document

Removes the mapping for the specified key from this map if present.

Usage

From source file:io.teak.sdk.Raven.java

public synchronized void addUserData(@NonNull String key, Object value) {
    @SuppressWarnings("unchecked")
    HashMap<String, Object> user = (HashMap<String, Object>) payloadTemplate.get("user");
    if (user == null) {
        user = new HashMap<>();
        payloadTemplate.put("user", user);
    }//from   w  ww .j  a v  a2s  .  c o m

    if (value != null) {
        user.put(key, value);
    } else {
        user.remove(key);
    }
}

From source file:org.apparatus_templi.web.handler.SettingsHandler.java

private byte[] getResponse() {
    byte[] returnBytes = null;
    byte[] templateBytes = HttpHelper.getFileBytes(webserver.getResourceFolder() + "inc/template.html");
    if (templateBytes != null) {
        String template = new String(templateBytes);

        StringBuilder html = new StringBuilder();
        HashMap<String, String> prefs = Coordinator.getPrefs().getPreferencesMap();
        // remove any preferences that should be hidden from the frontend
        prefs.remove(Prefs.Keys.userName);
        prefs.remove(Prefs.Keys.userPass);

        String configFile = prefs.get(Prefs.Keys.configFile);

        if (webserver instanceof EncryptedWebServer) {
            if (!Prefs.isCredentialsSet()) {
                html.append(/*from w w w  .  ja va  2 s.  co  m*/
                        "<div class='info-box' style='width:600px; display: block; margin-right: auto; margin-left: auto; "
                                + "cursor: pointer; font-size: smaller; text-align: center; padding: 10px'><p>No password has been set. "
                                + "Access will be unrestricted until you <a onclick='window.open(\"/set_password\", \"password_change\", "
                                + "\"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=550\");'>"
                                + "set a password</a>.</p></div>");
            }
        }

        // TODO update to a form so that the settings can be sent back in a POST request
        html.append("<div id=\"prefs_form\">");

        // Buttons
        html.append("<div id='settings-buttons'>");
        // TODO what modules can be restarted?
        html.append("<span id=\"restart_all_button\" class=\"btn-group closed\" >"
                + "<a class=\"btn btn-danger\" href=\"/restart_module?module=all\" title='Restarting the service will re-read "
                + "preferences from config file, restart all driver, and re-initialize the web server and the serial connection.'>"
                + "<i class=\"fa fa-refresh fa-fw\"></i> &nbsp;&nbsp;Restart Service</a>"
                + "<a class=\"btn btn-danger dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">"
                + "<span class=\"fa fa-caret-down\"></span></a>" + "<ul class=\"dropdown-menu\">"
                + "<li><a href=\"/restart_module?module=drivers\" title='Ask all drivers to terminate, then re-initialize all "
                + "drivers.  Only drivers specified in the driver list will be started.'><i class=\"fa fa-refresh fa-fw\"></i> "
                + "Restart Drivers</a></li><li><a href=\"/restart_module?module=web\" title='Restart the web server. This will "
                + "bind the web server to a new address and port number if those settings have been changed.'><i class=\"fa "
                + "fa-refresh fa-fw\"></i> Restart Web Server</a></li><li><a href=\"/restart_module?module=serial\" "
                + "title='Re-initialize the serial connection, discarding all partial messages'><i class=\"fa fa-refresh "
                + "fa-fw\"></i> Serial Connection</a></li></ul> </span>");

        // Save preferences button
        // if the config file is the default then we want the save preferences button to be
        // disabled until updated via javascript
        html.append("<span id='form_submit' ");
        if (configFile.equals(Coordinator.getPrefs().getDefPreference(Prefs.Keys.configFile))) {
            html.append("class='btn btn-success disabled'>");
        } else {
            html.append("class ='btn btn-success' ");
            html.append("form=\"prefs\" ");
            html.append("onclick = \"document.getElementById('prefs').submit()\" >");
        }
        html.append("<i class=\"fa fa-save\"></i>&nbsp;&nbsp;" + "Save Preferences to <span id='btn_conf_file'>"
                + configFile + "</span></div>");

        // end submit span
        html.append("</span>");

        // end buttons div
        // html.append("</div>");

        // clear the elements
        // html.append("<div class=\"clear\"></div>");

        html.append("<form name='prefs' id='prefs' action=\"update_settings\" " + "method=\"POST\" >\n");

        // settings boxes div
        html.append("<div id='settings_boxes'>");

        // Preferences for the main section
        html.append("<div id='prefs_section_main' class='prefs_section info-box'><div class='title'>"
                + "<i  class=\"fa fa-code-fork\"></i>&nbsp;Main" + "</div>");
        html.append("<div class='content'>");
        html.append("<div class=\"pref_input\"><span class=\"pref_key\">"
                + "<i class=\"fa fa-question-circle\" " + "title=\""
                + StringEscapeUtils.escapeHtml4(Coordinator.getPrefs().getPreferenceDesc(Prefs.Keys.configFile))
                + "\"></i>&nbsp;" + Prefs.Keys.configFile + "</span><span "
                + "class=\"pref_value\"><input id='f_config_file' type=\"text\" name=\"" + Prefs.Keys.configFile
                + "\" value=\"" + prefs.get(Prefs.Keys.configFile)
                + "\" onChange='updateConfigFile()' onkeypress='updateConfigFile()' onkeyup='updateConfigFile()' "
                + "onBlur='updateConfigFile()' /></span></div><br />\n");
        prefs.remove(Prefs.Keys.configFile);
        for (String key : new String[] { Prefs.Keys.serialPort, Prefs.Keys.driverList, Prefs.Keys.logFile,
                Prefs.Keys.emailList, Prefs.Keys.debugLevel }) {
            String value = prefs.get(key);
            // the serial port name can be a null value, but writing a null string
            // + will print "null" (a non-existent serial port). Write "" instead.
            if (key.equals(Prefs.Keys.serialPort) && value == null) {
                value = "";
            }
            html.append("<div class=\"pref_input\"><span class=\"pref_key \">"
                    + "<i class=\"fa fa-question-circle\" " + "title=\""
                    + StringEscapeUtils.escapeHtml4(Coordinator.getPrefs().getPreferenceDesc(key))
                    + "\"></i>&nbsp;" + Coordinator.getPrefs().getPreferenceName(key) + "</span><span "
                    + "class=\"pref_value\"><input "
                    + ((key == Prefs.Keys.userPass) ? " type='password' " : " type='text'") + " name=\"" + key
                    + "\" value=\"" + value + "\" /></span></div><br />\n");
            prefs.remove(key);
        }
        if (Prefs.isCredentialsSet() && webserver instanceof EncryptedWebServer) {
            html.append(
                    "<div style='margin-right: auto; margin-left: auto; cursor: pointer; text-align: center'><p><a "
                            + "onclick='window.open(\"/set_password\", \"password_change\", \"toolbar=no,location=no,status=no,"
                            + "menubar=no,scrollbars=yes,resizable=yes,width=750,height=550\");'>Change password</a></p></div>");
        }
        html.append("</div></div>");

        // Preferences for web server
        html.append("<div id='prefs_section_webserver'  class='prefs_section info-box'><div class='title'>"
                + "<i class=\"fa fa-cloud\"></i>&nbsp;Web Server" + "</div>");
        html.append("<div class='content'>");
        for (String key : new String[] { Prefs.Keys.portNum, Prefs.Keys.serverBindLocalhost,
                Prefs.Keys.encryptServer, Prefs.Keys.webResourceFolder }) {
            String value = prefs.get(key);
            html.append("<div class=\"pref_input\"><span class=\"pref_key\">"
                    + "<i class=\"fa fa-question-circle \" " + "title=\""
                    + StringEscapeUtils.escapeHtml4(Coordinator.getPrefs().getPreferenceDesc(key))
                    + "\"></i>&nbsp;" + Coordinator.getPrefs().getPreferenceName(key) + "</span><span "
                    + "class=\"pref_value\"><input "
                    + (key.equals((Prefs.Keys.portNum)) ? " type='number' " : "") + " type=\"text\" name=\""
                    + key + "\" value=\"" + value + "\" /></span></div><br />\n");
            prefs.remove(key);
        }
        html.append("</div></div>");

        // Preferences for the Twitter service
        html.append("<div id='prefs_section_twitter' class='prefs_section info-box'><div class='title'>"
                + "<i  class=\"fa fa-twitter\"></i>&nbsp;Twitter Service" + "</div>");
        html.append("<div class='content'>");
        for (String key : new String[] { Prefs.Keys.twtrAccess, Prefs.Keys.twtrAccessKey }) {
            html.append("<div class=\"pref_input\"><span class=\"pref_key\">"
                    + "<i class=\"fa fa-question-circle \" " + "title=\""
                    + StringEscapeUtils.escapeHtml4(Coordinator.getPrefs().getPreferenceDesc(key))
                    + "\"></i>&nbsp;" + Coordinator.getPrefs().getPreferenceName(key) + "</span><span "
                    + "class=\"pref_value\"><input " + " type=\"password\" name=\"" + key + "\" value=\""
                    + prefs.get(key) + "\" /></span></div><br />\n");
            prefs.remove(key);
        }
        html.append("</div>");
        html.append("<div class='warning'><p class=''>" + ENC_WARNING
                + "All passwords are stored in plaintext.</div>");
        html.append("</div>");

        // Preferences for the email service
        html.append("<div id='prefs_section_email' class='info-box prefs_section'><div class='title'>"
                + "<i  class=\"fa fa-envelope\"></i>&nbsp;Email Service" + "</div>");
        html.append("<div class='content'>");
        for (String key : new String[] { Prefs.Keys.emailAddress, Prefs.Keys.emailUsername,
                Prefs.Keys.emailPassword, Prefs.Keys.emailServer, Prefs.Keys.emailPort }) {
            html.append("<div class=\"pref_input\"><span class=\"pref_key\">"
                    + "<i class=\"fa fa-question-circle \" " + "title=\""
                    + StringEscapeUtils.escapeHtml4(Coordinator.getPrefs().getPreferenceDesc(key))
                    + "\"></i>&nbsp;" + Coordinator.getPrefs().getPreferenceName(key) + "</span><span "
                    + "class=\"pref_value\"><input "
                    + ((key == Prefs.Keys.emailPassword) ? "type = 'password' " : " type=\"text\"") + " name=\""
                    + key + "\" value=\"" + prefs.get(key) + "\" /></span></div><br />\n");
            prefs.remove(key);
        }
        html.append("</div>");
        html.append("<div class='warning'><p class=''>" + ENC_WARNING
                + "All passwords are stored in plaintext.</div>");
        html.append("</div>");

        // Any remaining unclassified preferences
        if (!prefs.isEmpty()) {
            html.append("<div id='prefs_section_unknown' class='info-box prefs_section'><div class='title'>"
                    + "<i  class=\"fa fa-question\"></i>&nbsp;Uncategorized" + "</div>");
            html.append("<div class='content'>");
            for (String key : prefs.keySet()) {
                html.append("<div class=\"pref_input\"><span class=\"pref_key\">"
                        + "<i class=\"fa fa-question-circle \" " + "title=\""
                        + StringEscapeUtils.escapeHtml4(Coordinator.getPrefs().getPreferenceDesc(key))
                        + "\"></i>&nbsp;" + Coordinator.getPrefs().getPreferenceName(key) + "</span><span "
                        + "class=\"pref_value\"><input " + " type=\"text\" name=\"" + key + "\" value=\""
                        + prefs.get(key) + "\" /></span></div><br />\n");
            }
            html.append("</div></div>");
        }
        // end settings boxes div
        html.append("</div>");
        html.append("</form>");
        // clear the elements
        html.append("<div class=\"clear\"></div>");
        // html.append("<hr class=\"fancy-line\"></hr>");

        // buttons div
        html.append("<div id=\"settings_buttons_div\">");

        html.append("</div></div>");
        template = template.replace("!PROTOCOL!", webserver.getProtocol());
        template = template.replace("!MAIN_CONTENT!", html.toString());
        template = template.replace("!JAVASCRIPT!",
                "<script type='text/javascript' src='/resource?file=js/settings.js'></script>");
        returnBytes = template.getBytes();
    }
    return returnBytes;
}

From source file:org.opensilk.music.library.folders.provider.FoldersLibraryProvider.java

@NonNull
public static List<File> filterAudioFiles(Context context, List<File> files) {
    if (files.size() == 0) {
        return Collections.emptyList();
    }/*from  www.j av a  2  s  .c  om*/
    //Map for cursor
    final HashMap<String, File> pathMap = new HashMap<>();
    //The returned list
    final List<File> audioFiles = new ArrayList<>();

    //Build the selection
    final int size = files.size();
    final StringBuilder selection = new StringBuilder();
    selection.append(MediaStore.Files.FileColumns.DATA + " IN (");
    for (int i = 0; i < size; i++) {
        final File f = files.get(i);
        final String path = f.getAbsolutePath();
        pathMap.put(path, f); //Add file to map while where iterating
        selection.append("'").append(StringUtils.replace(path, "'", "''")).append("'");//TODO it would probably be better to use selectionArgs
        if (i < size - 1) {
            selection.append(",");
        }
    }
    selection.append(")");
    Cursor c = null;
    try {
        c = context.getContentResolver().query(MediaStore.Files.getContentUri("external"),
                MEDIA_TYPE_PROJECTION, selection.toString(), null, null);
        if (c != null && c.moveToFirst()) {
            do {
                final int mediaType = c.getInt(0);
                final String path = c.getString(1);
                final File f = pathMap.remove(path);
                if (f != null && mediaType == MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO) {
                    audioFiles.add(f);
                } //else throw away
            } while (c.moveToNext());
        }
        //either the query failed or the cursor didn't contain all the files we asked for.
        if (!pathMap.isEmpty()) {
            Timber.w("%d files weren't found in mediastore. Best guessing mime type", pathMap.size());
            for (File f : pathMap.values()) {
                final String mime = guessMimeType(f);
                if (StringUtils.contains(mime, "audio") || "application/ogg".equals(mime)) {
                    audioFiles.add(f);
                }
            }
        }
    } catch (Exception e) {
        if (ModelUtil.DUMPSTACKS)
            Timber.e(e, "filterAudioFiles");
    } finally {
        closeQuietly(c);
    }
    return audioFiles;
}

From source file:gov.nih.nci.cabig.caaers.service.synchronizer.StudyOrganizationSynchronizer.java

/**
 * This method will synchronize the study site
 * @param dbStudy//from  w  ww.  j  a  va 2 s.  com
 * @param xmlStudy
 * @param outcome
 */
private void syncStudySite(Study dbStudy, Study xmlStudy, DomainObjectImportOutcome<Study> outcome) {

    //do nothing if study sites section is empty in xmlStudy
    if (CollectionUtils.isEmpty(xmlStudy.getStudySites())) {
        return;
    }

    //create an index consisting of sites, in dbStudy
    HashMap<String, StudySite> siteIndexMap = new HashMap<String, StudySite>();
    for (StudySite ss : dbStudy.getStudySites()) {
        siteIndexMap.put(generateIndexKey(ss), ss);
    }

    //loop through xmlStudy sites, and sync the personnel and investigators
    for (StudySite xmlStudySite : xmlStudy.getStudySites()) {
        StudySite ss = siteIndexMap.remove(generateIndexKey(xmlStudySite));
        if (ss == null) {
            //new so add it to dbStudy
            dbStudy.addStudySite(xmlStudySite);
            continue;
        }

        //sync the staff & investigators
        syncStudyInvestigators(ss, xmlStudySite, ss.getOrganization(), outcome);
        syncStudyPersonnels(ss, xmlStudySite, ss.getOrganization(), outcome);

    }

    //de-activate, all the other sites
    for (StudySite ss : siteIndexMap.values()) {
        ss.deactivate();
    }

}

From source file:org.wso2.carbon.core.deployment.DeploymentInterceptor.java

private void removeFaultyServiceDueToModule(String moduleName, String serviceGroupName) {
    synchronized (faultyServicesDueToModules) {
        HashMap<String, AxisDescription> faultyServices = faultyServicesDueToModules.get(moduleName);
        if (faultyServices != null) {
            faultyServices.remove(serviceGroupName);
            if (faultyServices.isEmpty()) {
                faultyServicesDueToModules.remove(moduleName);
            }//from  ww w  .j ava2 s  .  c o  m
        }
    }
}

From source file:eu.planets_project.tb.gui.backing.wf.EditWorkflowParameterInspector.java

private void removeServiceInformationFromSessionMap() {
    FacesContext ctx = FacesContext.getCurrentInstance();
    Object o = ctx.getExternalContext().getSessionMap().get(EDIT_WORKFLOW_PARAM_SERURL_MAP);
    if (o != null) {
        HashMap<String, String> editParamSerURLMap = (HashMap<String, String>) o;
        editParamSerURLMap.remove(this.experimentId);
    }/*from  w w w  . ja v  a  2  s . com*/
    Object o2 = ctx.getExternalContext().getSessionMap().get(EDIT_WORKFLOW_PARAM_SERID_MAP);
    if (o2 != null) {
        HashMap<String, String> editParamSerIDMap = (HashMap<String, String>) o;
        editParamSerIDMap.remove(this.experimentId);
    }
}

From source file:org.sakaiproject.tool.assessment.ui.listener.evaluation.QuestionScoreUpdateListener.java

private void updateAttachment(ItemGradingData itemGradingData, AgentResults agentResults,
        QuestionScoresBean bean) {// w w  w.  ja  v  a 2s  .c om
    List oldList = itemGradingData.getItemGradingAttachmentList();
    List newList = agentResults.getItemGradingAttachmentList();
    if ((oldList == null || oldList.size() == 0) && (newList == null || newList.size() == 0))
        return;
    List attachmentList = new ArrayList();
    HashMap map = getAttachmentIdHash(oldList);
    for (int i = 0; i < newList.size(); i++) {
        ItemGradingAttachment itemGradingAttachment = (ItemGradingAttachment) newList.get(i);
        if (map.get(itemGradingAttachment.getAttachmentId()) != null) {
            // exist already, remove it from map
            map.remove(itemGradingAttachment.getAttachmentId());
        } else {
            // new attachments
            itemGradingAttachment.setItemGrading(itemGradingData);
            itemGradingAttachment.setAttachmentType(AttachmentIfc.ITEMGRADING_ATTACHMENT);
            attachmentList.add(itemGradingAttachment);
        }
    }
    // save new ones
    GradingService gradingService = new GradingService();
    if (attachmentList.size() > 0) {
        gradingService.saveOrUpdateAttachments(attachmentList);
        EventTrackingService
                .post(EventTrackingService.newEvent("sam.student.score.update",
                        "siteId=" + AgentFacade.getCurrentSiteId() + ", Adding " + attachmentList.size()
                                + " attachments for itemGradingData id = " + itemGradingData.getItemGradingId(),
                        true));
    }

    // remove old ones
    Set set = map.keySet();
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        Long attachmentId = (Long) iter.next();
        gradingService.removeItemGradingAttachment(attachmentId.toString());
        EventTrackingService.post(EventTrackingService.newEvent("sam.student.score.update",
                "siteId=" + AgentFacade.getCurrentSiteId() + ", Removing attachmentId = " + attachmentId,
                true));
    }
    bean.setIsAnyItemGradingAttachmentListModified(true);
}

From source file:org.duracloud.sync.config.SyncToolConfigParserTest.java

@Test
public void testStandardOptions() throws Exception {
    HashMap<String, String> argsMap = getArgsMap();

    // Process configs, make sure values match
    SyncToolConfig syncConfig = syncConfigParser.processStandardOptions(mapToArray(argsMap));
    checkStandardOptions(argsMap, syncConfig);

    // Remove optional params
    argsMap.remove("-f");
    argsMap.remove("-r");
    argsMap.remove("-i");
    argsMap.remove("-t");
    argsMap.remove("-m");
    argsMap.remove("-d");
    argsMap.remove("-l");
    argsMap.remove("-x");
    argsMap.remove("-w");
    argsMap.remove("-a");
    argsMap.remove("-e");
    argsMap.remove("-n");
    argsMap.remove("-o");
    argsMap.remove("-j");

    // Process configs, make sure optional params are set to defaults
    syncConfig = syncConfigParser.processStandardOptions(mapToArray(argsMap));
    assertEquals(SyncToolConfigParser.DEFAULT_POLL_FREQUENCY, syncConfig.getPollFrequency());
    assertEquals(SyncToolConfigParser.DEFAULT_PORT, syncConfig.getPort());
    assertNull(syncConfig.getStoreId());
    assertEquals(SyncToolConfigParser.DEFAULT_NUM_THREADS, syncConfig.getNumThreads());
    assertEquals(SyncToolConfigParser.DEFAULT_MAX_FILE_SIZE * SyncToolConfigParser.GIGABYTE,
            syncConfig.getMaxFileSize());
    assertEquals(false, syncConfig.syncDeletes());
    assertEquals(false, syncConfig.isCleanStart());
    assertEquals(false, syncConfig.exitOnCompletion());
    assertEquals(expectedPassword, syncConfig.getPassword());
    assertNull(syncConfig.getWorkDir());
    assertNull(syncConfig.getPrefix());//from  w  ww.  j  av a  2  s . c  o  m
    assertNull(syncConfig.getExcludeList());
    assertFalse(syncConfig.isRenameUpdates());
    assertTrue(syncConfig.isSyncUpdates());
    assertFalse(syncConfig.isJumpStart());

    // Make sure error is thrown on missing required params
    for (String arg : argsMap.keySet()) {
        String failMsg = "An exception should have been thrown due to " + "missing arg: " + arg;
        removeArgFailTest(argsMap, arg, failMsg);
    }

    // Make sure error is thrown when numerical args are not numerical
    String failMsg = "Frequency arg should require a numerical value";
    addArgFailTest(argsMap, "-f", "nonNum", failMsg);
    failMsg = "Port arg should require a numerical value";
    addArgFailTest(argsMap, "-r", "nonNum", failMsg);
    failMsg = "Threads arg should require a numerical value";
    addArgFailTest(argsMap, "-t", "nonNum", failMsg);
    failMsg = "Max file size arg should require a numerical value";
    addArgFailTest(argsMap, "-m", "nonNum", failMsg);
    failMsg = "Max file size arg should be between 1 and 5";
    addArgFailTest(argsMap, "-m", "0", failMsg);
    addArgFailTest(argsMap, "-m", "6", failMsg);
}

From source file:ch.cyberduck.core.azure.AzureWriteFeature.java

@Override
public StatusOutputStream<Void> write(final Path file, final TransferStatus status,
        final ConnectionCallback callback) throws BackgroundException {
    try {//from  www  .  j  a  va2  s . co m
        final CloudAppendBlob blob = session.getClient()
                .getContainerReference(containerService.getContainer(file).getName())
                .getAppendBlobReference(containerService.getKey(file));
        if (StringUtils.isNotBlank(status.getMime())) {
            blob.getProperties().setContentType(status.getMime());
        }
        final HashMap<String, String> headers = new HashMap<>();
        // Add previous metadata when overwriting file
        headers.putAll(status.getMetadata());
        blob.setMetadata(headers);
        // Remove additional headers not allowed in metadata and move to properties
        if (headers.containsKey(HttpHeaders.CACHE_CONTROL)) {
            blob.getProperties().setCacheControl(headers.get(HttpHeaders.CACHE_CONTROL));
            headers.remove(HttpHeaders.CACHE_CONTROL);
        }
        if (headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
            blob.getProperties().setCacheControl(headers.get(HttpHeaders.CONTENT_TYPE));
            headers.remove(HttpHeaders.CONTENT_TYPE);
        }
        final Checksum checksum = status.getChecksum();
        if (Checksum.NONE != checksum) {
            switch (checksum.algorithm) {
            case md5:
                try {
                    blob.getProperties().setContentMD5(
                            Base64.toBase64String(Hex.decodeHex(status.getChecksum().hash.toCharArray())));
                    headers.remove(HttpHeaders.CONTENT_MD5);
                } catch (DecoderException e) {
                    // Ignore
                }
                break;
            }
        }
        final BlobRequestOptions options = new BlobRequestOptions();
        options.setConcurrentRequestCount(1);
        options.setStoreBlobContentMD5(preferences.getBoolean("azure.upload.md5"));
        final BlobOutputStream out;
        if (status.isAppend()) {
            options.setStoreBlobContentMD5(false);
            out = blob.openWriteExisting(AccessCondition.generateEmptyCondition(), options, context);
        } else {
            out = blob.openWriteNew(AccessCondition.generateEmptyCondition(), options, context);
        }
        return new VoidStatusOutputStream(out) {
            @Override
            protected void handleIOException(final IOException e) throws IOException {
                if (StringUtils.equals(SR.STREAM_CLOSED, e.getMessage())) {
                    log.warn(String.format("Ignore failure %s", e));
                    return;
                }
                final Throwable cause = ExceptionUtils.getRootCause(e);
                if (cause instanceof StorageException) {
                    throw new IOException(e.getMessage(),
                            new AzureExceptionMappingService().map((StorageException) cause));
                }
                throw e;
            }
        };
    } catch (StorageException e) {
        throw new AzureExceptionMappingService().map("Upload {0} failed", e, file);
    } catch (URISyntaxException e) {
        throw new NotfoundException(e.getMessage(), e);
    }
}

From source file:org.exoplatform.wiki.tree.TreeNode.java

protected int getNumberOfChildren(HashMap<String, Object> context, int size) {
    String childNumCdt = (String) context.get(CHILDREN_NUMBER);
    int childrenNUm = (childNumCdt == null || StringUtils.EMPTY.equals(childNumCdt)) ? -1
            : Integer.valueOf(childNumCdt);
    if (childrenNUm < 0 || childrenNUm > size) {
        childrenNUm = size;/*from   w ww  . j  ava  2s.  c  o  m*/
    }
    //Only apply for the first level
    if (context.containsKey(CHILDREN_NUMBER))
        context.remove(CHILDREN_NUMBER);

    return childrenNUm;
}