Example usage for java.util Locale ROOT

List of usage examples for java.util Locale ROOT

Introduction

In this page you can find the example usage for java.util Locale ROOT.

Prototype

Locale ROOT

To view the source code for java.util Locale ROOT.

Click Source Link

Document

Useful constant for the root locale.

Usage

From source file:org.elasticsearch.client.RequestConvertersTests.java

private static void setRandomSearchParams(SearchRequest searchRequest, Map<String, String> expectedParams) {
    expectedParams.put(RestSearchAction.TYPED_KEYS_PARAM, "true");
    if (randomBoolean()) {
        searchRequest.routing(randomAlphaOfLengthBetween(3, 10));
        expectedParams.put("routing", searchRequest.routing());
    }/*ww w. j  a  v a2  s  .c  o m*/
    if (randomBoolean()) {
        searchRequest.preference(randomAlphaOfLengthBetween(3, 10));
        expectedParams.put("preference", searchRequest.preference());
    }
    if (randomBoolean()) {
        searchRequest.searchType(randomFrom(SearchType.values()));
    }
    expectedParams.put("search_type", searchRequest.searchType().name().toLowerCase(Locale.ROOT));
    if (randomBoolean()) {
        searchRequest.requestCache(randomBoolean());
        expectedParams.put("request_cache", Boolean.toString(searchRequest.requestCache()));
    }
    if (randomBoolean()) {
        searchRequest.allowPartialSearchResults(randomBoolean());
        expectedParams.put("allow_partial_search_results",
                Boolean.toString(searchRequest.allowPartialSearchResults()));
    }
    if (randomBoolean()) {
        searchRequest.setBatchedReduceSize(randomIntBetween(2, Integer.MAX_VALUE));
    }
    expectedParams.put("batched_reduce_size", Integer.toString(searchRequest.getBatchedReduceSize()));
    if (randomBoolean()) {
        searchRequest.scroll(randomTimeValue());
        expectedParams.put("scroll", searchRequest.scroll().keepAlive().getStringRep());
    }
}

From source file:org.elasticsearch.client.RequestConvertersTests.java

private static void setRandomVersionType(Consumer<VersionType> setter, Map<String, String> expectedParams) {
    if (randomBoolean()) {
        VersionType versionType = randomFrom(VersionType.values());
        setter.accept(versionType);//from   w w  w.  j  ava 2 s. c  om
        if (versionType != VersionType.INTERNAL) {
            expectedParams.put("version_type", versionType.name().toLowerCase(Locale.ROOT));
        }
    }
}

From source file:org.elasticsearch.client.RequestConvertersTests.java

private static String[] randomIndicesNames(int minIndicesNum, int maxIndicesNum) {
    int numIndices = randomIntBetween(minIndicesNum, maxIndicesNum);
    String[] indices = new String[numIndices];
    for (int i = 0; i < numIndices; i++) {
        indices[i] = "index-" + randomAlphaOfLengthBetween(2, 5).toLowerCase(Locale.ROOT);
    }/*  ww w . java 2  s.  c  o m*/
    return indices;
}

From source file:net.www_eee.portal.channels.ProxyChannel.java

/**
 * Create an {@linkplain #createProxiedDocumentInputSource(Page.Request, HttpResponse, URL, MimeType) input source},
 * {@linkplain MarkupManager#parseXMLDocument(InputSource, DefaultHandler2, boolean, boolean, boolean, boolean) feed}
 * it to an XML parser, and/*from w w w.j  a  va2 s  . c o  m*/
 * {@linkplain #createProxiedDocumentContentHandler(Page.Request, Channel.ViewResponse, URL, TypedInputSource) handle}
 * the results.
 * 
 * @param pageRequest The {@link net.www_eee.portal.Page.Request Request} currently being processed.
 * @param viewResponse The {@link net.www_eee.portal.Channel.ViewResponse ViewResponse} currently being generated.
 * @param proxyResponse The {@link HttpResponse} received for the proxied file.
 * @param proxiedFileURL The {@linkplain #getProxiedFileURL(Page.Request, Channel.Mode, boolean) proxied file URL}.
 * @param responseContentType The {@link MimeType} of the proxied file.
 * @throws WWWEEEPortal.Exception If a problem occurred while determining the result.
 * @see #isRenderedUsingXMLView(Page.Request, HttpResponse, MimeType)
 * @see #createProxiedDocumentInputSource(Page.Request, HttpResponse, URL, MimeType)
 * @see MarkupManager#parseXMLDocument(InputSource, DefaultHandler2, boolean, boolean, boolean, boolean)
 * @see #createProxiedDocumentContentHandler(Page.Request, Channel.ViewResponse, URL, TypedInputSource)
 * @see #PARSE_XML_HOOK
 */
protected void renderXMLView(final Page.Request pageRequest, final ViewResponse viewResponse,
        final HttpResponse proxyResponse, final URL proxiedFileURL,
        final @Nullable MimeType responseContentType) throws WWWEEEPortal.Exception {
    final TypedInputSource proxiedDocumentInputSource = createProxiedDocumentInputSource(pageRequest,
            proxyResponse, proxiedFileURL, responseContentType);

    final DefaultHandler2 contentHandler = createProxiedDocumentContentHandler(pageRequest, viewResponse,
            proxiedFileURL, proxiedDocumentInputSource);

    final Object[] context = new Object[] { viewResponse, proxiedDocumentInputSource, contentHandler };
    Boolean parsedXML = PARSE_XML_HOOK.value(plugins, context, pageRequest);
    if (!Boolean.TRUE.equals(parsedXML)) {

        MarkupManager.parseXMLDocument(proxiedDocumentInputSource.getInputSource(), contentHandler,
                isParserHaltOnWarningsEnabled(pageRequest), !isParserHaltOnErrorsDisabled(pageRequest),
                !isParserHaltOnFatalErrorsDisabled(pageRequest), false);

    }

    PARSE_XML_HOOK.filter(plugins, context, pageRequest, Boolean.TRUE);

    final Optional<Element> contentRootElement = DOMUtil
            .getChildElement(viewResponse.getContentContainerElement(), null, null);
    if (contentRootElement.isPresent()) {
        final Locale contentLocale = DOMUtil.getXMLLangAttr(contentRootElement.get(), Locale.ROOT);
        if (!Locale.ROOT.equals(contentLocale))
            viewResponse.setLocale(contentLocale);
    }

    return;
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.java

/**
 * Returns if the specified token is a reserved color keyword.
 * @param token the token to check//from  w ww . j a  v a 2s  .  c  o  m
 * @return whether the token is a reserved color keyword or not
 */
private static boolean isColorKeyword(final String token) {
    return CSSColors_.containsKey(token.toLowerCase(Locale.ROOT));
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.java

/**
 * Gets the RGB equivalent of a CSS color if the provided color is recognized.
 * @param color the color// ww w  .  j av a 2 s . com
 * @return the provided color if this is not a recognized color keyword, the RGB value
 * in the form "rgb(x, y, z)" otherwise
 */
public static String toRGBColor(final String color) {
    final String rgbValue = CSSColors_.get(color.toLowerCase(Locale.ROOT));
    if (rgbValue != null) {
        return rgbValue;
    }
    return color;
}

From source file:org.getlantern.firetweet.util.Utils.java

/**
 * User-Agent format of official client:
 * TwitterAndroid/[versionName] ([versionCode]-[buildName]-[r|d)]-[buildNumber]) [deviceInfo]
 *
 * @param context/*from www. j a v  a  2  s . c  o m*/
 * @param cb
 */
public static void setMockOfficialUserAgent(final Context context, final ConfigurationBuilder cb) {
    cb.setClientVersion("5.32.0");
    cb.setClientName("TwitterAndroid");
    cb.setClientURL(null);
    final String deviceInfo = String.format(Locale.ROOT, "%s/%s (%s;%s;%s;%s;)", Build.MODEL,
            Build.VERSION.RELEASE, Build.MANUFACTURER, Build.MODEL, Build.BRAND, Build.PRODUCT);
    cb.setHttpUserAgent(String.format(Locale.ROOT, "TwitterAndroid/%s (%d-%c-%d) %s", "5.32.0", 3030745, 'r',
            692, deviceInfo));
}

From source file:org.getlantern.firetweet.util.Utils.java

public static boolean handleMenuItemClick(Context context, Fragment fragment, FragmentManager fm,
        AsyncTwitterWrapper twitter, ParcelableStatus status, MenuItem item) {
    switch (item.getItemId()) {
    case MENU_COPY: {
        if (ClipboardUtils.setText(context, status.text_plain)) {
            showOkMessage(context, R.string.text_copied, false);
        }/*from   w  w  w. j  a v  a  2  s  . c  om*/
        break;
    }
    case MENU_RETWEET: {
        if (isMyRetweet(status)) {
            twitter.cancelRetweetAsync(status.account_id, status.id, status.my_retweet_id);
        } else {
            twitter.retweetStatusAsync(status.account_id, status.id);
        }
        break;
    }
    case MENU_QUOTE: {
        final Intent intent = new Intent(INTENT_ACTION_QUOTE);
        intent.putExtra(EXTRA_STATUS, status);
        context.startActivity(intent);
        break;
    }
    case MENU_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_REPLY);
        intent.putExtra(EXTRA_STATUS, status);
        context.startActivity(intent);
        break;
    }
    case MENU_FAVORITE: {
        if (status.is_favorite) {
            twitter.destroyFavoriteAsync(status.account_id, status.id);
        } else {
            twitter.createFavoriteAsync(status.account_id, status.id);
        }
        break;
    }
    case MENU_DELETE: {
        DestroyStatusDialogFragment.show(fm, status);
        break;
    }
    case MENU_ADD_TO_FILTER: {
        AddStatusFilterDialogFragment.show(fm, status);
        break;
    }
    case MENU_SET_COLOR: {
        final Intent intent = new Intent(context, ColorPickerDialogActivity.class);
        final int color = getUserColor(context, status.user_id, true);
        if (color != 0) {
            intent.putExtra(EXTRA_COLOR, color);
        }
        intent.putExtra(EXTRA_CLEAR_BUTTON, color != 0);
        intent.putExtra(EXTRA_ALPHA_SLIDER, false);
        if (fragment != null) {
            fragment.startActivityForResult(intent, REQUEST_SET_COLOR);
        } else if (context instanceof Activity) {
            ((Activity) context).startActivityForResult(intent, REQUEST_SET_COLOR);
        }
        break;
    }
    case MENU_CLEAR_NICKNAME: {
        clearUserNickname(context, status.user_id);
        break;
    }
    case MENU_SET_NICKNAME: {
        final String nick = getUserNickname(context, status.user_id, true);
        SetUserNicknameDialogFragment.show(fm, status.user_id, nick);
        break;
    }
    case MENU_TRANSLATE: {
        final ParcelableCredentials account = ParcelableAccount.getCredentials(context, status.account_id);
        if (isOfficialCredentials(context, account)) {
            StatusTranslateDialogFragment.show(fm, status);
        } else {
            final Resources resources = context.getResources();
            final Locale locale = resources.getConfiguration().locale;
            try {
                final String template = "http://translate.google.com/#%s|%s|%s";
                final String sourceLang = "auto";
                final String targetLang = URLEncoder.encode(locale.getLanguage(), HTTP.UTF_8);
                final String text = URLEncoder.encode(status.text_unescaped, HTTP.UTF_8);
                final Uri uri = Uri.parse(String.format(Locale.ROOT, template, sourceLang, targetLang, text));
                final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.addCategory(Intent.CATEGORY_BROWSABLE);
                context.startActivity(intent);
            } catch (UnsupportedEncodingException ignore) {

            }
        }
        break;
    }
    case MENU_OPEN_WITH_ACCOUNT: {
        final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT);
        intent.setClass(context, AccountSelectorActivity.class);
        intent.putExtra(EXTRA_SINGLE_SELECTION, true);
        if (fragment != null) {
            fragment.startActivityForResult(intent, REQUEST_SELECT_ACCOUNT);
        } else if (context instanceof Activity) {
            ((Activity) context).startActivityForResult(intent, REQUEST_SELECT_ACCOUNT);
        }
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                context.startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Crashlytics.logException(e);
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:org.apache.manifoldcf.crawler.connectors.livelink.LivelinkConnector.java

/**
* Connects to the specified Livelink document using HTTP protocol
* @param documentIdentifier is the document identifier (as far as the crawler knows).
* @param activities is the process activity structure, so we can ingest
*//*from   w  w  w. j  a  va  2  s  .c  o  m*/
protected void ingestFromLiveLink(LivelinkContext llc, String documentIdentifier, String version,
        String[] actualAcls, String[] denyAcls, String[] categoryPaths, IProcessActivity activities,
        MetadataDescription desc, SystemMetadataDescription sDesc)
        throws ManifoldCFException, ServiceInterruption {

    String contextMsg = "for '" + documentIdentifier + "'";

    // Fetch logging
    long startTime = System.currentTimeMillis();
    String resultCode = null;
    String resultDescription = null;
    Long readSize = null;
    int objID;
    int vol;

    int colonPos = documentIdentifier.indexOf(":", 1);

    if (colonPos == -1) {
        objID = new Integer(documentIdentifier.substring(1)).intValue();
        vol = LLENTWK_VOL;
    } else {
        objID = new Integer(documentIdentifier.substring(colonPos + 1)).intValue();
        vol = new Integer(documentIdentifier.substring(1, colonPos)).intValue();
    }

    // Try/finally for fetch logging
    try {
        String viewHttpAddress = convertToViewURI(documentIdentifier);
        if (viewHttpAddress == null) {
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Livelink: No view URI " + contextMsg + " - not ingesting");
            resultCode = "NOVIEWURI";
            resultDescription = "Document had no view URI";
            activities.noDocument(documentIdentifier, version);
            return;
        }

        // Check URL first
        if (!activities.checkURLIndexable(viewHttpAddress)) {
            // Document not ingestable due to URL
            resultCode = activities.EXCLUDED_URL;
            resultDescription = "URL (" + viewHttpAddress + ") was rejected by output connector";
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Livelink: Excluding document " + documentIdentifier
                        + " because its URL (" + viewHttpAddress + ") was rejected by output connector");
            activities.noDocument(documentIdentifier, version);
            return;
        }

        // Add general metadata
        ObjectInformation objInfo = llc.getObjectInformation(vol, objID);
        VersionInformation versInfo = llc.getVersionInformation(vol, objID, 0);
        if (!objInfo.exists()) {
            resultCode = "OBJECTNOTFOUND";
            resultDescription = "Object was not found in Livelink";
            Logging.connectors.debug("Livelink: No object " + contextMsg + ": not ingesting");
            activities.noDocument(documentIdentifier, version);
            return;
        }
        if (!versInfo.exists()) {
            resultCode = "VERSIONNOTFOUND";
            resultDescription = "Version was not found in Livelink";
            Logging.connectors.debug("Livelink: No version data " + contextMsg + ": not ingesting");
            activities.noDocument(documentIdentifier, version);
            return;
        }

        String mimeType = versInfo.getMimeType();
        if (!activities.checkMimeTypeIndexable(mimeType)) {
            // Document not indexable because of its mime type
            resultCode = activities.EXCLUDED_MIMETYPE;
            resultDescription = "Mime type (" + mimeType + ") was rejected by output connector";
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Livelink: Excluding document " + documentIdentifier
                        + " because its mime type (" + mimeType + ") was rejected by output connector");
            activities.noDocument(documentIdentifier, version);
            return;
        }

        Long dataSize = versInfo.getDataSize();
        if (dataSize == null) {
            // Document had no length
            resultCode = "DOCUMENTNOLENGTH";
            resultDescription = "Document had no length in Livelink";
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug(
                        "Livelink: Excluding document " + documentIdentifier + " because it had no length");
            activities.noDocument(documentIdentifier, version);
            return;
        }

        if (!activities.checkLengthIndexable(dataSize.longValue())) {
            // Document not indexable because of its length
            resultCode = activities.EXCLUDED_LENGTH;
            resultDescription = "Document length (" + dataSize + ") was rejected by output connector";
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Livelink: Excluding document " + documentIdentifier
                        + " because its length (" + dataSize + ") was rejected by output connector");
            activities.noDocument(documentIdentifier, version);
            return;
        }

        Date modifyDate = versInfo.getModifyDate();
        if (!activities.checkDateIndexable(modifyDate)) {
            // Document not indexable because of its date
            resultCode = activities.EXCLUDED_DATE;
            resultDescription = "Document date (" + modifyDate + ") was rejected by output connector";
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Livelink: Excluding document " + documentIdentifier
                        + " because its date (" + modifyDate + ") was rejected by output connector");
            activities.noDocument(documentIdentifier, version);
            return;
        }

        String fileName = versInfo.getFileName();
        Date creationDate = objInfo.getCreationDate();
        Integer parentID = objInfo.getParentId();

        RepositoryDocument rd = new RepositoryDocument();

        // Add general data we need for the output connector
        if (mimeType != null)
            rd.setMimeType(mimeType);
        if (fileName != null)
            rd.setFileName(fileName);
        if (creationDate != null)
            rd.setCreatedDate(creationDate);
        if (modifyDate != null)
            rd.setModifiedDate(modifyDate);

        rd.addField(GENERAL_NAME_FIELD, objInfo.getName());
        rd.addField(GENERAL_DESCRIPTION_FIELD, objInfo.getComments());
        if (creationDate != null)
            rd.addField(GENERAL_CREATIONDATE_FIELD, DateParser.formatISO8601Date(creationDate));
        if (modifyDate != null)
            rd.addField(GENERAL_MODIFYDATE_FIELD, DateParser.formatISO8601Date(modifyDate));
        if (parentID != null)
            rd.addField(GENERAL_PARENTID, parentID.toString());
        UserInformation owner = llc.getUserInformation(objInfo.getOwnerId().intValue());
        UserInformation creator = llc.getUserInformation(objInfo.getCreatorId().intValue());
        UserInformation modifier = llc.getUserInformation(versInfo.getOwnerId().intValue());
        if (owner != null)
            rd.addField(GENERAL_OWNER, owner.getName());
        if (creator != null)
            rd.addField(GENERAL_CREATOR, creator.getName());
        if (modifier != null)
            rd.addField(GENERAL_MODIFIER, modifier.getName());

        // Iterate over the metadata items.  These are organized by category
        // for speed of lookup.

        Iterator<MetadataItem> catIter = desc.getItems(categoryPaths);
        while (catIter.hasNext()) {
            MetadataItem item = catIter.next();
            MetadataPathItem pathItem = item.getPathItem();
            if (pathItem != null) {
                int catID = pathItem.getCatID();
                // grab the associated catversion
                LLValue catVersion = getCatVersion(objID, catID);
                if (catVersion != null) {
                    // Go through attributes now
                    Iterator<String> attrIter = item.getAttributeNames();
                    while (attrIter.hasNext()) {
                        String attrName = attrIter.next();
                        // Create a unique metadata name
                        String metadataName = pathItem.getCatName() + ":" + attrName;
                        // Fetch the metadata and stuff it into the RepositoryData structure
                        String[] metadataValue = getAttributeValue(catVersion, attrName);
                        if (metadataValue != null)
                            rd.addField(metadataName, metadataValue);
                        else
                            Logging.connectors.warn("Livelink: Metadata attribute '" + metadataName
                                    + "' does not seem to exist; please correct the job");
                    }
                }

            }
        }

        if (actualAcls != null && denyAcls != null)
            rd.setSecurity(RepositoryDocument.SECURITY_TYPE_DOCUMENT, actualAcls, denyAcls);

        // Add the path metadata item into the mix, if enabled
        String pathAttributeName = sDesc.getPathAttributeName();
        if (pathAttributeName != null && pathAttributeName.length() > 0) {
            String pathString = sDesc.getPathAttributeValue(documentIdentifier);
            if (pathString != null) {
                if (Logging.connectors.isDebugEnabled())
                    Logging.connectors.debug("Livelink: Path attribute name is '" + pathAttributeName + "'"
                            + contextMsg + ", value is '" + pathString + "'");
                rd.addField(pathAttributeName, pathString);
            }
        }

        if (ingestProtocol != null) {
            // Use HTTP to fetch document!
            String ingestHttpAddress = convertToIngestURI(documentIdentifier);
            if (ingestHttpAddress == null) {
                if (Logging.connectors.isDebugEnabled())
                    Logging.connectors.debug("Livelink: No fetch URI " + contextMsg + " - not ingesting");
                resultCode = "NOURI";
                resultDescription = "Document had no fetch URI";
                activities.noDocument(documentIdentifier, version);
                return;
            }

            // Set up connection
            HttpClient client = getInitializedClient(contextMsg);

            long currentTime;

            if (Logging.connectors.isInfoEnabled())
                Logging.connectors.info("Livelink: " + ingestHttpAddress);

            HttpGet method = new HttpGet(getHost().toURI() + ingestHttpAddress);
            method.setHeader(new BasicHeader("Accept", "*/*"));

            boolean wasInterrupted = false;
            ExecuteMethodThread methodThread = new ExecuteMethodThread(client, method);
            methodThread.start();
            try {
                int statusCode = methodThread.getResponseCode();
                switch (statusCode) {
                case 500:
                case 502:
                    Logging.connectors.warn("Livelink: Service interruption during fetch " + contextMsg
                            + " with Livelink HTTP Server, retrying...");
                    resultCode = "FETCHFAILED";
                    resultDescription = "HTTP error code " + statusCode + " fetching document";
                    throw new ServiceInterruption("Service interruption during fetch",
                            new ManifoldCFException(Integer.toString(statusCode) + " error while fetching"),
                            System.currentTimeMillis() + 60000L, System.currentTimeMillis() + 600000L, -1,
                            true);

                case HttpStatus.SC_UNAUTHORIZED:
                    Logging.connectors.warn("Livelink: Document fetch unauthorized for " + ingestHttpAddress
                            + " (" + contextMsg + ")");
                    // Since we logged in, we should fail here if the ingestion user doesn't have access to the
                    // the document, but if we do, don't fail hard.
                    resultCode = "UNAUTHORIZED";
                    resultDescription = "Document fetch was unauthorized by IIS";
                    activities.noDocument(documentIdentifier, version);
                    return;

                case HttpStatus.SC_OK:
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors
                                .debug("Livelink: Created http document connection to Livelink " + contextMsg);
                    // A non-existent content length will cause a value of -1 to be returned.  This seems to indicate that the session login did not work right.
                    if (methodThread.getResponseContentLength() < 0) {
                        resultCode = "SESSIONLOGINFAILED";
                        resultDescription = "Response content length was -1, which usually means session login did not succeed";
                        activities.noDocument(documentIdentifier, version);
                        return;
                    }

                    try {
                        InputStream is = methodThread.getSafeInputStream();
                        try {
                            rd.setBinary(is, dataSize);

                            activities.ingestDocumentWithException(documentIdentifier, version, viewHttpAddress,
                                    rd);
                            resultCode = "OK";
                            readSize = dataSize;

                            if (Logging.connectors.isDebugEnabled())
                                Logging.connectors.debug("Livelink: Ingesting done " + contextMsg);

                        } finally {
                            // Close stream via thread, since otherwise this can hang
                            is.close();
                        }
                    } catch (InterruptedException e) {
                        wasInterrupted = true;
                        throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
                                ManifoldCFException.INTERRUPTED);
                    } catch (HttpException e) {
                        resultCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                        resultDescription = e.getMessage();
                        handleHttpException(contextMsg, e);
                    } catch (IOException e) {
                        resultCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                        resultDescription = e.getMessage();
                        handleIOException(contextMsg, e);
                    }
                    break;
                case HttpStatus.SC_BAD_REQUEST:
                case HttpStatus.SC_USE_PROXY:
                case HttpStatus.SC_GONE:
                    resultCode = "HTTPERROR";
                    resultDescription = "Http request returned status " + Integer.toString(statusCode);
                    throw new ManifoldCFException(
                            "Unrecoverable request failure; error = " + Integer.toString(statusCode));
                default:
                    resultCode = "UNKNOWNHTTPCODE";
                    resultDescription = "Http request returned status " + Integer.toString(statusCode);
                    Logging.connectors.warn("Livelink: Attempt to retrieve document from '" + ingestHttpAddress
                            + "' received a response of " + Integer.toString(statusCode)
                            + "; retrying in one minute");
                    currentTime = System.currentTimeMillis();
                    throw new ServiceInterruption("Fetch failed; retrying in 1 minute",
                            new ManifoldCFException(
                                    "Fetch failed with unknown code " + Integer.toString(statusCode)),
                            currentTime + 60000L, currentTime + 600000L, -1, true);
                }
            } catch (InterruptedException e) {
                // Drop the connection on the floor
                methodThread.interrupt();
                methodThread = null;
                throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
                        ManifoldCFException.INTERRUPTED);
            } catch (HttpException e) {
                resultCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                resultDescription = e.getMessage();
                handleHttpException(contextMsg, e);
            } catch (IOException e) {
                resultCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                resultDescription = e.getMessage();
                handleIOException(contextMsg, e);
            } finally {
                if (methodThread != null) {
                    methodThread.abort();
                    try {
                        if (!wasInterrupted)
                            methodThread.finishUp();
                    } catch (InterruptedException e) {
                        throw new ManifoldCFException(e.getMessage(), e, ManifoldCFException.INTERRUPTED);
                    }
                }
            }
        } else {
            // Use FetchVersion instead
            long currentTime;

            // Fire up the document reading thread
            DocumentReadingThread t = new DocumentReadingThread(vol, objID, 0);
            boolean wasInterrupted = false;
            t.start();
            try {
                try {
                    InputStream is = t.getSafeInputStream();
                    try {
                        // Can only index while background thread is running!
                        rd.setBinary(is, dataSize);
                        activities.ingestDocumentWithException(documentIdentifier, version, viewHttpAddress,
                                rd);
                        resultCode = "OK";
                        readSize = dataSize;
                    } finally {
                        is.close();
                    }
                } catch (java.net.SocketTimeoutException e) {
                    throw e;
                } catch (InterruptedIOException e) {
                    wasInterrupted = true;
                    throw e;
                } finally {
                    if (!wasInterrupted)
                        t.finishUp();
                }

                // No errors.  Record the fact that we made it.
            } catch (InterruptedException e) {
                t.interrupt();
                throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
                        ManifoldCFException.INTERRUPTED);
            } catch (IOException e) {
                resultCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                resultDescription = e.getMessage();
                handleIOException(contextMsg, e);
            } catch (RuntimeException e) {
                resultCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                resultDescription = e.getMessage();
                handleLivelinkRuntimeException(e, 0, true);
            }
        }
    } catch (ManifoldCFException e) {
        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
            resultCode = null;
        throw e;
    } finally {
        if (resultCode != null)
            activities.recordActivity(new Long(startTime), ACTIVITY_FETCH, readSize, vol + ":" + objID,
                    resultCode, resultDescription, null);
    }
}