Example usage for java.util.logging Level FINER

List of usage examples for java.util.logging Level FINER

Introduction

In this page you can find the example usage for java.util.logging Level FINER.

Prototype

Level FINER

To view the source code for java.util.logging Level FINER.

Click Source Link

Document

FINER indicates a fairly detailed tracing message.

Usage

From source file:com.esri.gpt.catalog.search.SearchEngineRest.java

/**
 * Gets the search query./* w w w .  j  av a2s . com*/
 * 
 * @return the search query
 * @throws SearchException the search exception
 */
@SuppressWarnings("unchecked")
@Override
public String getSearchQuery() throws SearchException {
    String searchQuery = null;
    Exception ex = null;
    Map<String, String> map = this.getFactoryAttributes();
    map.put(XSL_PARAM_OPENSEARCH_URL, this.getEndPointSearchUrl());

    try {
        searchQuery = this.readXslProfile().generateGetRecordsRequest(this.getRequestDefinition().getCriteria(),
                map, this.getHitsOnly());
        String searchEndPoint = this.getEndPointSearchUrl();
        // assign values from the xslt
        Document doc = DomUtil.makeDomFromString(searchQuery, false);
        NodeList paramList = doc.getElementsByTagName("parameter");
        for (int i = 0; i < paramList.getLength(); i++) {
            Node paramNode = paramList.item(i);
            String key = paramNode.getAttributes().getNamedItem("key").getNodeValue();
            String value = paramNode.getAttributes().getNamedItem("value").getNodeValue();

            String paramValue = this.getFactoryAttributes().get(key);
            if (paramValue != null) {
                String paramValues[] = paramValue.split(DELIMETER_KVP);
                for (int j = 0; j < paramValues.length; j++) {
                    String paramValueValues[] = Val.chkStr(paramValues[j]).split(DELIMETER_KV);
                    if (paramValueValues.length < 2) {
                        continue;
                    }
                    if (Val.chkStr(paramValueValues[0]).equalsIgnoreCase(value)) {
                        value = paramValueValues[1];
                    }
                }
            }
            key = key.replaceAll("([\\\\*+\\[\\](){}\\$.?\\^|])", "\\\\$1");
            searchEndPoint = searchEndPoint.replaceAll("(?i)" + key, URLEncoder.encode(value, "UTF-8"));
        }

        // assign default values input
        Map<String, String> paramVals = this.readDefaultParamValues();
        Iterator<String> keyIter = paramVals.keySet().iterator();
        while (keyIter.hasNext()) {
            String key = keyIter.next();
            if (searchEndPoint.contains(key + "=&") || searchEndPoint.endsWith(key + "=")) {
                searchEndPoint = searchEndPoint.replaceAll(key + "=",
                        key + "=" + URLEncoder.encode(paramVals.get(key), "UTF-8"));
            }
        }

        // replace sections of the url
        paramVals = this.readReplaceParamValues();
        keyIter = paramVals.keySet().iterator();
        while (keyIter.hasNext()) {
            String key = Val.chkStr(keyIter.next());
            String value = Val.chkStr(paramVals.get(key));
            searchEndPoint.replaceAll(key, value);
        }

        LOG.log(Level.FINER, "Search Query: {0}", searchEndPoint);
        return searchEndPoint;
    } catch (XPathExpressionException e) {
        ex = e;
    } catch (TransformerException e) {
        ex = e;
    } catch (ParserConfigurationException e) {
        ex = e;
    } catch (SAXException e) {
        ex = e;
    } catch (IOException e) {
        ex = e;
    }
    if (ex == null) {
        throw new SearchException("Error when generating search query", ex);
    }

    return searchQuery;

}

From source file:com.esri.gpt.framework.http.HttpClientRequest.java

/**
 * Executes the HTTP request./*from  w w w.j  a v a  2s.  com*/
 * @throws IOException if an Exception occurs
 */
public void execute() throws IOException {

    // initialize
    this.executionLog.setLength(0);
    StringBuffer log = this.executionLog;
    ResponseInfo respInfo = this.getResponseInfo();
    respInfo.reset();
    InputStream responseStream = null;
    HttpMethodBase method = null;

    try {
        log.append("HTTP Client Request\n").append(this.getUrl());

        // make the Apache HTTPClient
        HttpClient client = this.batchHttpClient;
        if (client == null) {
            client = new HttpClient();
            boolean alwaysClose = Val.chkBool(Val.chkStr(ApplicationContext.getInstance().getConfiguration()
                    .getCatalogConfiguration().getParameters().getValue("httpClient.alwaysClose")), false);
            if (alwaysClose) {
                client.setHttpConnectionManager(new SimpleHttpConnectionManager(true));
            }
        }

        // setting timeout info
        client.getHttpConnectionManager().getParams().setConnectionTimeout(getConnectionTimeOutMs());
        client.getHttpConnectionManager().getParams().setSoTimeout(getResponseTimeOutMs());

        // setting retries
        int retries = this.getRetries();

        // create the client and method, apply authentication and proxy settings
        method = this.createMethod();
        //method.setFollowRedirects(true);
        if (retries > -1) {
            // TODO: not taking effect yet?
            DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(retries, true);
            client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
            method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
        }

        this.applyAuthAndProxySettings(client, this.getUrl());

        // execute the method, determine basic information about the response
        respInfo.setResponseCode(client.executeMethod(method));
        this.determineResponseInfo(method);

        // collect logging info
        if (LOGGER.isLoggable(Level.FINER)) {
            log.append("\n>>").append(method.getStatusLine());
            log.append("\n--Request Header");
            for (Header hdr : method.getRequestHeaders()) {
                log.append("\n  ").append(hdr.getName() + ": " + hdr.getValue());
            }
            log.append("\n--Response Header");
            for (Header hdr : method.getResponseHeaders()) {
                log.append("\n  ").append(hdr.getName() + ": " + hdr.getValue());
            }

            //log.append(" responseCode=").append(this.getResponseInfo().getResponseCode());
            //log.append(" responseContentType=").append(this.getResponseInfo().getContentType());
            //log.append(" responseContentEncoding=").append(this.getResponseInfo().getContentEncoding());
            //log.append(" responseContentLength=").append(this.getResponseInfo().getContentLength());

            if (this.getContentProvider() != null) {
                String loggable = this.getContentProvider().getLoggableContent();
                if (loggable != null) {
                    log.append("\n--Request Content------------------------------------\n").append(loggable);
                }
            }
        }

        // throw an exception if an error is encountered
        if ((respInfo.getResponseCode() < 200) || (respInfo.getResponseCode() >= 300)) {
            String msg = "HTTP Request failed: " + method.getStatusLine();
            if (respInfo.getResponseCode() == HttpStatus.SC_UNAUTHORIZED) {
                AuthState authState = method.getHostAuthState();
                AuthScheme authScheme = authState.getAuthScheme();
                HttpClient401Exception authException = new HttpClient401Exception(msg);
                authException.setUrl(this.getUrl());
                authException.setRealm(authState.getRealm());
                authException.setScheme(authScheme.getSchemeName());
                if ((authException.getRealm() == null) || (authException.getRealm().length() == 0)) {
                    authException.setRealm(authException.generateHostBasedRealm());
                }
                throw authException;
            } else {
                throw new HttpClientException(respInfo.getResponseCode(), msg);
            }
        }

        // handle the response
        if (this.getContentHandler() != null) {
            if (getContentHandler().onBeforeReadResponse(this)) {
                responseStream = getResponseStream(method);
                if (responseStream != null) {
                    this.getContentHandler().readResponse(this, responseStream);
                }
            }

            // log thre response content
            String loggable = this.getContentHandler().getLoggableContent();
            long nBytesRead = this.getResponseInfo().getBytesRead();
            long nCharsRead = this.getResponseInfo().getCharactersRead();
            if ((nBytesRead >= 0) || (nCharsRead >= 0) || (loggable != null)) {
                log.append("\n--Response Content------------------------------------");
                if (nBytesRead >= 0)
                    log.append("\n(").append(nBytesRead).append(" bytes read)");
                if (nCharsRead >= 0)
                    log.append("\n(").append(nCharsRead).append(" characters read)");
                if (loggable != null)
                    log.append("\n").append(loggable);
            }
        }

    } finally {

        // cleanup
        try {
            if (responseStream != null)
                responseStream.close();
        } catch (Throwable t) {
            LOGGER.log(Level.SEVERE, "Unable to close HTTP response stream.", t);
        }
        try {
            if (method != null)
                method.releaseConnection();
        } catch (Throwable t) {
            LOGGER.log(Level.SEVERE, "Unable to release HttpMethod", t);
        }

        // log the request/response
        if (LOGGER.isLoggable(Level.FINER)) {
            LOGGER.finer(this.getExecutionLog().toString());
        }
    }
}

From source file:org.b3log.solo.processor.ArticleProcessor.java

/**
 * Shows author articles with the specified context.
 * //from   ww w.jav a  2s.  c om
 * @param context the specified context
 * @param request the specified request
 * @param response the specified response
 * @throws IOException io exception
 * @throws JSONException json exception 
 */
@RequestProcessing(value = "/authors/**", method = HTTPRequestMethod.GET)
public void showAuthorArticles(final HTTPRequestContext context, final HttpServletRequest request,
        final HttpServletResponse response) throws IOException, JSONException {
    final AbstractFreeMarkerRenderer renderer = new FrontRenderer();
    context.setRenderer(renderer);

    renderer.setTemplateName("author-articles.ftl");

    try {
        String requestURI = request.getRequestURI();
        if (!requestURI.endsWith("/")) {
            requestURI += "/";
        }

        final String authorId = getAuthorId(requestURI);

        LOGGER.log(Level.FINER, "Request author articles[requestURI={0}, authorId={1}]",
                new Object[] { requestURI, authorId });

        final int currentPageNum = getAuthorCurrentPageNum(requestURI, authorId);
        if (-1 == currentPageNum) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        LOGGER.log(Level.FINER, "Request author articles[authorId={0}, currentPageNum={1}]",
                new Object[] { authorId, currentPageNum });

        final JSONObject preference = preferenceQueryService.getPreference();
        if (null == preference) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        final int pageSize = preference.getInt(Preference.ARTICLE_LIST_DISPLAY_COUNT);
        final int windowSize = preference.getInt(Preference.ARTICLE_LIST_PAGINATION_WINDOW_SIZE);

        final JSONObject result = userQueryService.getUser(authorId);
        final JSONObject author = result.getJSONObject(User.USER);

        final Map<String, String> langs = langPropsService.getAll(Latkes.getLocale());
        request.setAttribute(PageCaches.CACHED_TYPE, langs.get(PageTypes.AUTHOR_ARTICLES.getLangeLabel()));
        request.setAttribute(PageCaches.CACHED_OID, "No id");
        request.setAttribute(PageCaches.CACHED_TITLE,
                langs.get(PageTypes.AUTHOR_ARTICLES.getLangeLabel()) + "  [" + langs.get("pageNumLabel") + "="
                        + currentPageNum + ", " + langs.get("authorLabel") + "="
                        + author.getString(User.USER_NAME) + "]");
        request.setAttribute(PageCaches.CACHED_LINK, requestURI);

        final String authorEmail = author.getString(User.USER_EMAIL);
        final List<JSONObject> articles = articleQueryService.getArticlesByAuthorEmail(authorEmail,
                currentPageNum, pageSize);
        if (articles.isEmpty()) {
            try {
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            } catch (final IOException ex) {
                LOGGER.severe(ex.getMessage());
            }
        }

        filler.setArticlesExProperties(articles, author, preference);

        if (preference.optBoolean(Preference.ENABLE_ARTICLE_UPDATE_HINT)) {
            Collections.sort(articles, Comparators.ARTICLE_UPDATE_DATE_COMPARATOR);
        } else {
            Collections.sort(articles, Comparators.ARTICLE_CREATE_DATE_COMPARATOR);
        }

        final int articleCount = author.getInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT);
        final int pageCount = (int) Math.ceil((double) articleCount / (double) pageSize);

        final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize);

        final Map<String, Object> dataModel = renderer.getDataModel();
        prepareShowAuthorArticles(pageNums, dataModel, pageCount, currentPageNum, articles, author, preference);
        dataModel.put(Keys.PAGE_TYPE, PageTypes.AUTHOR_ARTICLES);
        filler.fillBlogHeader(request, dataModel, preference);
        filler.fillSide(request, dataModel, preference);
        Skins.fillSkinLangs(preference.optString(Preference.LOCALE_STRING),
                (String) request.getAttribute(Keys.TEMAPLTE_DIR_NAME), dataModel);
    } catch (final ServiceException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);

        try {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        } catch (final IOException ex) {
            LOGGER.severe(ex.getMessage());
        }
    }
}

From source file:org.jenkins.plugins.lockableresources.LockableResourcesManager.java

public synchronized void unreserve(List<LockableResource> resources) {
    // make sure there is a list of resources to unreserve
    if (resources == null || (resources.size() == 0)) {
        return;/*w  ww  . j  a  v  a  2s .  co m*/
    }
    List<String> resourceNamesToUnreserve = new ArrayList<>();
    for (LockableResource r : resources) {
        resourceNamesToUnreserve.add(r.getName());
    }

    // check if there are resources which can be unlocked (and shall not be unlocked)
    Set<LockableResource> requiredResourceForNextContext = null;
    QueuedContextStruct nextContext = this.getNextQueuedContext(resourceNamesToUnreserve, false, null);

    // no context is queued which can be started once these resources are free'd.
    if (nextContext == null) {
        LOGGER.log(Level.FINER, "No context queued for resources "
                + StringUtils.join(resourceNamesToUnreserve, ", ") + " so unreserving and proceeding.");
        unreserveResources(resources);
        return;
    }

    PrintStream nextContextLogger = null;
    try {
        TaskListener nextContextTaskListener = nextContext.getContext().get(TaskListener.class);
        if (nextContextTaskListener != null) {
            nextContextLogger = nextContextTaskListener.getLogger();
        }
    } catch (IOException | InterruptedException e) {
        LOGGER.log(Level.FINE, "Could not get logger for next context: " + e, e);
    }

    // remove context from queue and process it
    requiredResourceForNextContext = checkResourcesAvailability(nextContext.getResources(), nextContextLogger,
            resourceNamesToUnreserve);
    this.queuedContexts.remove(nextContext);

    // resourceNamesToUnreserve contains the names of the previous resources.
    // requiredResourceForNextContext contains the resource objects which are required for the next context.
    // It is guaranteed that there is an overlap between the two - the resources which are to be reused.
    boolean needToWait = false;
    for (LockableResource requiredResource : requiredResourceForNextContext) {
        if (!resourceNamesToUnreserve.contains(requiredResource.getName())) {
            if (requiredResource.isReserved() || requiredResource.isLocked()) {
                needToWait = true;
                break;
            }
        }
    }

    if (needToWait) {
        unreserveResources(resources);
        return;
    } else {
        unreserveResources(resources);
        List<String> resourceNamesToLock = new ArrayList<String>();

        // lock all (old and new resources)
        for (LockableResource requiredResource : requiredResourceForNextContext) {
            try {
                requiredResource.setBuild(nextContext.getContext().get(Run.class));
                resourceNamesToLock.add(requiredResource.getName());
            } catch (Exception e) {
                // skip this context, as the build cannot be retrieved (maybe it was deleted while running?)
                LOGGER.log(Level.WARNING,
                        "Skipping queued context for lock. Can not get the Run object from the context to proceed with lock, "
                                + "this could be a legitimate status if the build waiting for the lock was deleted or"
                                + " hard killed. More information at Level.FINE if debug is needed.");
                LOGGER.log(Level.FINE, "Can not get the Run object from the context to proceed with lock", e);
                return;
            }
        }

        // continue with next context
        LockStepExecution.proceed(resourceNamesToLock, nextContext.getContext(),
                nextContext.getResourceDescription(), null, false);
    }
    save();
}

From source file:org.geotools.imageio.netcdf.AncillaryFileManager.java

@Override
public void purge() {
    try {/*from w  w  w .  jav a 2s. co m*/
        resetSliceManager();
    } catch (IOException e) {
        LOGGER.log(Level.FINER, e.getMessage(), e);
    }
    fileSetManager.purge();
}

From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java

public void updateTableWithNameClusters(Project project, List<NameCluster> nameClusters,
        List<Dataset> datasets) {
    Table<NameCluster, String, Set<String>> precalc = HashBasedTable.create();

    if (nameClusters == null) {
        dataTableView.setItems(FXCollections.emptyObservableList());
        return;/*from  www.j a  va2 s  .c o m*/
    }
    boolean flag_nameClustersAreTaxonConcepts = false;

    if (nameClusters.size() > 0 && TaxonConcept.class.isAssignableFrom(nameClusters.get(0).getClass()))
        flag_nameClustersAreTaxonConcepts = true;
    dataTableView.setItems(FXCollections.observableList(nameClusters));

    // Precalculate.
    List<String> existingColNames = new ArrayList<>();
    existingColNames.add("id");
    existingColNames.add("name");
    existingColNames.add("names_in_dataset");
    existingColNames.add("all_names_in_cluster");

    // If these are taxon concepts, there's three other columns we want
    // to emit.
    if (flag_nameClustersAreTaxonConcepts) {
        existingColNames.add("name_cluster_id");
        existingColNames.add("starts_with");
        existingColNames.add("ends_with");
        existingColNames.add("is_ongoing");
    } else {
        existingColNames.add("taxon_concept_count");
        existingColNames.add("taxon_concepts");
    }

    // Set<Name> recognizedNamesInDataset = namesDataset.getRecognizedNames(project).collect(Collectors.toSet());

    for (NameCluster cluster : nameClusters) {
        precalc.put(cluster, "id", getOneElementSet(cluster.getId().toString()));

        // Okay, here's what we need to do:
        //   - If names is ALL, then we can't do better than cluster.getName().
        // if(namesDataset == ALL) {
        precalc.put(cluster, "names_in_dataset",
                cluster.getNames().stream().map(n -> n.getFullName()).collect(Collectors.toSet()));
        precalc.put(cluster, "name", getOneElementSet(cluster.getName().getFullName()));
        //} else {
        /*
           // hey, here's something cool we can do: figure out which name(s)
           // this dataset uses from this cluster!
           List<String> namesInDataset = cluster.getNames().stream()
              .filter(n -> recognizedNamesInDataset.contains(n))
              .map(n -> n.getFullName())
              .collect(Collectors.toList());
           String firstName = "";
           if(namesInDataset.size() > 0)
              firstName = namesInDataset.get(0);
                   
           precalc.put(cluster, "names_in_dataset", new HashSet<>(namesInDataset));
           precalc.put(cluster, "name", getOneElementSet(firstName));            
        }*/

        precalc.put(cluster, "all_names_in_cluster",
                cluster.getNames().stream().map(n -> n.getFullName()).collect(Collectors.toSet()));

        // If it's a taxon concept, precalculate a few more columns.
        if (flag_nameClustersAreTaxonConcepts) {
            TaxonConcept tc = (TaxonConcept) cluster;

            precalc.put(cluster, "name_cluster_id", getOneElementSet(tc.getNameCluster().getId().toString()));
            precalc.put(cluster, "starts_with",
                    tc.getStartsWith().stream().map(ch -> ch.toString()).collect(Collectors.toSet()));
            precalc.put(cluster, "ends_with",
                    tc.getEndsWith().stream().map(ch -> ch.toString()).collect(Collectors.toSet()));
            precalc.put(cluster, "is_ongoing", getOneElementSet(tc.isOngoing(project) ? "yes" : "no"));
        } else {
            // If it's a true name cluster, then perhaps people will want
            // to know what taxon concepts are in here? Maybe for some sort
            // of PhD?
            List<TaxonConcept> tcs = cluster.getTaxonConcepts(project);

            precalc.put(cluster, "taxon_concept_count", getOneElementSet(String.valueOf(tcs.size())));
            precalc.put(cluster, "taxon_concepts",
                    tcs.stream().map(tc -> tc.toString()).collect(Collectors.toSet()));
        }

        // Okay, here's where we reconcile!
        for (Name n : cluster.getNames()) {
            // TODO: there's probably an optimization here, in which we should
            // loop on the smaller set (either loop on 'datasets' and compare
            // to cluster, or loop on cluster.foundIn and compare to 'datasets').
            for (Dataset ds : datasets) {
                Map<Name, Set<DatasetRow>> rowsByName = ds.getRowsByName();

                // Are we included in this name cluster? If not, skip!
                if (!cluster.getFoundIn().contains(ds))
                    continue;

                // Check to see if we have any rows for this name; if not, skip.
                if (!rowsByName.containsKey(n))
                    continue;

                Set<DatasetRow> matched = rowsByName.get(n);
                LOGGER.log(Level.FINER, "Adding {0} rows under name ''{1}''",
                        new Object[] { matched.size(), n.getFullName() });

                Map<Set<DatasetColumn>, List<DatasetRow>> rowsByCols = matched.stream()
                        .collect(Collectors.groupingBy((DatasetRow row) -> row.getColumns()));

                for (Set<DatasetColumn> cols : rowsByCols.keySet()) {
                    for (DatasetColumn col : cols) {
                        String colName = col.getName();

                        if (existingColNames.contains(colName))
                            colName = "datasets." + colName;

                        if (!precalc.contains(cluster, colName))
                            precalc.put(cluster, colName, new HashSet());

                        for (DatasetRow row : rowsByCols.get(cols)) {
                            if (!row.hasColumn(col))
                                continue;

                            precalc.get(cluster, colName).add(row.get(col));
                        }

                        LOGGER.log(Level.FINER, "Added {0} rows under name ''{1}''",
                                new Object[] { rowsByCols.get(cols).size(), n.getFullName() });
                    }
                }
            }
        }
    }

    dataTableView.getColumns().clear();
    for (String colName : existingColNames) {
        dataTableView.getColumns().add(createColumnFromPrecalc(colName, precalc));
    }

    // Get distinct column names.
    Stream<String> colNames = precalc.cellSet().stream().map(set -> set.getColumnKey());

    // Eliminate columns that are in the existingColNames.
    colNames = colNames.filter(colName -> !existingColNames.contains(colName));

    // And add tablecolumns for the rest.
    List<TableColumn<NameCluster, String>> cols = colNames.distinct().sorted()
            .map(colName -> createColumnFromPrecalc(colName, precalc)).collect(Collectors.toList());
    dataTableView.getColumns().addAll(cols);
    dataTableView.refresh();

    // Fill in status text field.
    statusTextField
            .setText(dataTableView.getItems().size() + " rows across " + cols.size() + " reconciled columns");
}

From source file:org.b3log.solo.service.ArticleMgmtService.java

/**
 * Decrements reference count of every tag of an article specified by the
 * given article id.//from  w w  w. ja  v a  2s .  co m
 *
 * @param articleId the given article id
 * @throws ServiceException service exception
 */
private void decTagRefCount(final String articleId) throws ServiceException {
    try {
        final List<JSONObject> tags = tagRepository.getByArticleId(articleId);
        final JSONObject article = articleRepository.get(articleId);

        for (final JSONObject tag : tags) {
            final String tagId = tag.getString(Keys.OBJECT_ID);
            final int refCnt = tag.getInt(Tag.TAG_REFERENCE_COUNT);
            tag.put(Tag.TAG_REFERENCE_COUNT, refCnt - 1);
            final int publishedRefCnt = tag.getInt(Tag.TAG_PUBLISHED_REFERENCE_COUNT);
            if (article.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
                tag.put(Tag.TAG_PUBLISHED_REFERENCE_COUNT, publishedRefCnt - 1);
            } else {
                tag.put(Tag.TAG_PUBLISHED_REFERENCE_COUNT, publishedRefCnt);
            }
            tagRepository.update(tagId, tag);
            LOGGER.log(Level.FINEST, "Deced tag[title={0}, refCnt={1}, publishedRefCnt={2}] of article[id={3}]",
                    new Object[] { tag.getString(Tag.TAG_TITLE), tag.getInt(Tag.TAG_REFERENCE_COUNT),
                            tag.getInt(Tag.TAG_PUBLISHED_REFERENCE_COUNT), articleId });
        }
    } catch (final Exception e) {
        LOGGER.log(Level.SEVERE, "Decs tag references count of article[id" + articleId + "] failed", e);
        throw new ServiceException(e);
    }

    LOGGER.log(Level.FINER, "Deced all tag reference count of article[id={0}]", articleId);
}

From source file:org.aselect.server.request.handler.aselect.authentication.ApplicationBrowserHandler.java

/**
 * Process application browser requests.<br>
 * <br>/*  w w w . j av  a 2  s.c  o  m*/
 * 
 * @param htServiceRequest
 *            the service request
 * @param servletResponse
 *            the servlet response
 * @param pwOut
 *            the output PrintWriter
 * @throws ASelectException
 * @see org.aselect.server.request.handler.aselect.authentication.AbstractBrowserRequestHandler#processBrowserRequest(java.util.HashMap,
 *      javax.servlet.http.HttpServletResponse, java.io.PrintWriter)
 */
// NOTE: pwOut is closed by the caller!!!
public void processBrowserRequest(HashMap htServiceRequest, HttpServletResponse servletResponse,
        PrintWriter pwOut) throws ASelectException {
    String sMethod = "processBrowserRequest";
    boolean useUsi = false;

    String sRequest = (String) htServiceRequest.get("request");
    _systemLogger.log(Level.FINEST, _sModule, sMethod,
            "ApplBrowREQ sRequest=" + sRequest + " user language=" + _sUserLanguage);

    // 20120611, Bauke: added "usi" handling
    if (sRequest != null && ("logout".equals(sRequest) || sRequest.startsWith("direct_login")
            || sRequest.startsWith("login"))) {
        _timerSensor.setTimerSensorLevel(1); // enable sensor
        useUsi = true;
    }

    String sReqLanguage = (String) htServiceRequest.get("language");
    if (sReqLanguage != null && !sReqLanguage.equals("")) {
        _sUserLanguage = sReqLanguage;
        _systemLogger.log(Level.FINEST, _sModule, sMethod,
                "Set user language=" + _sUserLanguage + " from Request");
    }
    // TGT was read if available

    // Bauke, 20090929: added localization, do this asap.
    String sRid = (String) htServiceRequest.get("rid");
    if (sRid != null) {
        _htSessionContext = _sessionManager.getSessionContext(sRid);
        if (_htSessionContext == null) {
            throw new ASelectException(Errors.ERROR_ASELECT_SERVER_SESSION_EXPIRED);
        }
        // 20120611, Bauke: added "usi" handling
        String sUsi = (String) _htSessionContext.get("usi");
        String sAppId = (String) _htSessionContext.get("app_id");
        if (useUsi) {
            if (Utils.hasValue(sUsi)) // overwrite
                _timerSensor.setTimerSensorId(sUsi);
            if (Utils.hasValue(sAppId))
                _timerSensor.setTimerSensorAppId(sAppId);
        }
        Tools.resumeSensorData(_configManager, _systemLogger, _htSessionContext); // 20111102
        if (sReqLanguage != null && !sReqLanguage.equals("")) {
            _htSessionContext.put("language", sReqLanguage); // store language for posterity
            _sessionManager.setUpdateSession(_htSessionContext, _systemLogger); // 20120401, Bauke: postpone session action
        }
        // Copy language & country to session if not present yet (session takes precedence)
        Utils.transferLocalization(_htSessionContext, _sUserLanguage, _sUserCountry);
        // And copy language back
        _sUserLanguage = (String) _htSessionContext.get("language"); // override
        String sUserState = (String) _htSessionContext.get("user_state");
        _systemLogger.log(Level.FINEST, _sModule, sMethod,
                "After transfer: userLanguage=" + _sUserLanguage + " user_state=" + sUserState);
    }

    boolean bAllowLoginToken = "true".equals(ASelectAuthenticationProfile.get_sAllowLoginToken());
    String sAllowedLoginTokenMethod = ASelectAuthenticationProfile.get_sAllowedLoginTokenMethod();

    _systemLogger.log(Level.FINEST, _sModule, sMethod,
            "bAllowLoginToken=" + bAllowLoginToken + ", sAllowedLoginTokenMethod: " + sAllowedLoginTokenMethod);

    if (sRequest == null) {
        // Show info page if nothing else to do
        String sUrl = (String) htServiceRequest.get("my_url");
        String sAsUid = (String) htServiceRequest.get("aselect_credentials_uid");
        _systemLogger.log(Level.FINEST, _sModule, sMethod,
                "ApplBrowREQ request=null sUrl=" + sUrl + " aselect_credentials_uid=" + sAsUid);

        if (sAsUid != null)
            showUserInfo(htServiceRequest, _servletResponse, pwOut); // pauses sensor
        else {
            String sServerInfoForm = _configManager.getHTMLForm("serverinfo", _sUserLanguage, _sUserCountry);
            sServerInfoForm = Utils.replaceString(sServerInfoForm, "[message]", " ");

            try {
                Object aselect = _configManager.getSection(null, "aselect");
                String sFriendlyName = ASelectConfigManager.getSimpleParam(aselect,
                        "organization_friendly_name", false);
                sServerInfoForm = Utils.replaceString(sServerInfoForm, "[organization_friendly]",
                        sFriendlyName);
            } catch (Exception e) {
                _systemLogger.log(Level.WARNING, _sModule, sMethod, "Configuration error: " + e);
            }
            sServerInfoForm = _configManager.updateTemplate(sServerInfoForm, _htSessionContext,
                    _servletRequest);
            Tools.pauseSensorData(_configManager, _systemLogger, _htSessionContext); //20111102

            if (_htSessionContext != null)
                _htSessionContext.put("user_state", "state_serverinfo");
            _sessionManager.setUpdateSession(_htSessionContext, _systemLogger); // 20120401, Bauke: changed, was update()

            pwOut.println(sServerInfoForm);
        }
    } else if (sRequest.equals("logout")) {
        //         handleLogout(htServiceRequest, _servletResponse, pwOut);   // RH, 20140819, o
        // RH, 20140819, sn
        //////////////////////////////////////////////////////
        boolean doSamlLogout = false; // true = for testing, get this from e.g. presence of sp_issuer and/or sso_session in tgtcontext
        doSamlLogout = (_htTGTContext != null) && (_htTGTContext.get("sp_issuer") != null)
                && (_htTGTContext.get("sso_session") != null);

        if (doSamlLogout) {
            _systemLogger.log(Level.FINER, _sModule, sMethod, "doSamlLogout, _htTGTContext:" + _htTGTContext);
            handleSamlLogout(htServiceRequest, _servletRequest, _servletResponse, pwOut);
        } else {
            handleLogout(htServiceRequest, _servletResponse, pwOut);
        }
        // RH, 20140819, en

    } else if (sRequest.equals("org_choice")) {
        handleOrgChoice(htServiceRequest, _servletResponse);
    }

    // handle OnBehalfOf
    else if (sRequest.equals("obo_choice")) {
        handleOnBehalfOf(htServiceRequest, _servletResponse, pwOut);
    } else if (sRequest.equals("alive")) {
        pwOut.println("<html><body>Server is ALIVE</body></html>");
    }
    //      else if (bAllowLoginToken && sRequest.equals("login_token")) {
    else if (bAllowLoginToken && sRequest.equals("login_token") && (sAllowedLoginTokenMethod == null
            || _servletRequest.getMethod().equalsIgnoreCase(sAllowedLoginTokenMethod))) {
        handleLoginToken(htServiceRequest, _servletResponse, pwOut);
    } else { // Precondition, need a session
        if (sRid == null) {
            _systemLogger.log(Level.WARNING, _sModule, sMethod, "Missing RID parameter");
            throw new ASelectCommunicationException(Errors.ERROR_ASELECT_SERVER_INVALID_REQUEST);
        }

        // If a valid session is found, it will be valid during the whole servlet request handling.
        if (_htSessionContext == null) {
            _systemLogger.log(Level.WARNING, _sModule, sMethod, "Invalid RID: " + sRid);
            throw new ASelectException(Errors.ERROR_ASELECT_SERVER_SESSION_EXPIRED);
        }

        // Session is available
        String sDirectAuthSP = (String) _htSessionContext.get("direct_authsp");
        _systemLogger.log(Level.FINEST, _sModule, sMethod, "direct_authsp=" + sDirectAuthSP);
        if (sDirectAuthSP != null && !sRequest.startsWith("direct_login")) {
            _systemLogger.log(Level.WARNING, _sModule, sMethod,
                    "'direct_authsp' found, but not a 'direct_login' request, rid='" + sRid + "'");
            throw new ASelectException(Errors.ERROR_ASELECT_SERVER_INVALID_REQUEST);
        }

        // 20100828, Bauke:
        // Allow application to force the login user name upon us
        String sSpecials = Utils.getAselectSpecials(_htSessionContext, true, _systemLogger); // decodes from base64 coded value
        if (Utils.hasValue(sSpecials)) {
            String sSearch = Utils.getParameterValueFromUrl(sSpecials, "set_forced_uid");
            if (sSearch != null)
                _htSessionContext.put("user_id", sSearch);
            _sessionManager.setUpdateSession(_htSessionContext, _systemLogger); // 20120401, Bauke: added
        }

        while (true) {
            if (sRequest.equals("login1")) {
                int rc = handleLogin1(htServiceRequest, _servletResponse, pwOut);
                if (rc != 1)
                    return;
                sRequest = "login1"; // allow new login attempt
            } else if (sRequest.equals("login2")) {
                int rc = handleLogin2(htServiceRequest, _servletResponse, pwOut);
                if (rc != 1)
                    return;
                sRequest = "login1"; // allow new login attempt
            } else
                break; // other requests
        }
        if (sRequest.equals("login3")) {
            handleLogin3(htServiceRequest, _servletResponse, pwOut);
        } else if (sRequest.equals("cross_login")) {
            handleCrossLogin(htServiceRequest, _servletResponse, pwOut);
        } else if (sRequest.equals("login25")) {
            handleLogin25(htServiceRequest, _servletResponse, pwOut);
        } else if (sRequest.equals("ip_login")) {
            handleIPLogin1(htServiceRequest, pwOut);
        } else if (sRequest.startsWith("direct_login")) {
            handleDirectLogin(htServiceRequest, _servletResponse, pwOut);
        } else if (sRequest.equals("create_tgt")) {
            handleCreateTGT(htServiceRequest);
        } else {
            throw new ASelectException(Errors.ERROR_ASELECT_SERVER_INVALID_REQUEST);
        }
    }
}

From source file:com.cyberway.issue.crawler.frontier.AdaptiveRevisitFrontier.java

public synchronized CrawlURI next() throws InterruptedException, EndedException {
    controller.checkFinish();/*from w  w  w.  j av  a2 s . com*/

    while (shouldPause) {
        controller.toePaused();
        wait();
    }

    if (shouldTerminate) {
        throw new EndedException("terminated");
    }

    AdaptiveRevisitHostQueue hq = hostQueues.getTopHQ();

    while (hq.getState() != AdaptiveRevisitHostQueue.HQSTATE_READY) {
        // Ok, so we don't have a ready queue, wait until the top one
        // will become available.
        long waitTime = hq.getNextReadyTime() - System.currentTimeMillis();
        if (waitTime > 0) {
            wait(waitTime);
        }
        // The top HQ may have changed, so get it again
        hq = hostQueues.getTopHQ();
    }

    if (shouldTerminate) {
        // May have been terminated while thread was waiting for IO
        throw new EndedException("terminated");
    }

    try {
        CrawlURI curi = hq.next();
        // Populate CURI with 'transient' variables such as server.
        logger.fine("Issuing " + curi.toString());
        long temp = curi.getLong(A_TIME_OF_NEXT_PROCESSING);
        long currT = System.currentTimeMillis();
        long overdue = (currT - temp);
        if (logger.isLoggable(Level.FINER)) {
            String waitI = "not set";
            if (curi.containsKey(A_WAIT_INTERVAL)) {
                waitI = ArchiveUtils.formatMillisecondsToConventional(curi.getLong(A_WAIT_INTERVAL));
            }
            logger.finer("Wait interval: " + waitI + ", Time of next proc: " + temp + ", Current time: " + currT
                    + ", Overdue by: " + overdue + "ms");
        }
        if (overdue < 0) {
            // This should never happen.
            logger.severe("Time overdue for " + curi.toString() + "is negative (" + overdue + ")!");
        }
        curi.putLong(A_FETCH_OVERDUE, overdue);
        return curi;
    } catch (IOException e) {
        // TODO: Need to handle this in an intelligent manner. 
        //       Is probably fatal?
        e.printStackTrace();
    }

    return null;
}

From source file:com.ibm.team.build.internal.hjplugin.RTCScm.java

@DataBoundConstructor
public RTCScm(boolean overrideGlobal, String buildTool, String serverURI, int timeout, String userId,
        Secret password, String passwordFile, String buildWorkspace) {

    this.overrideGlobal = overrideGlobal;
    if (this.overrideGlobal) {
        this.buildTool = buildTool;
        this.serverURI = serverURI;
        this.timeout = timeout;
        this.userId = userId;
        this.password = password;
        this.passwordFile = passwordFile;
    }// w  w w.j  a  va 2  s.  c om
    this.buildWorkspace = buildWorkspace;

    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("RTCScm constructed with " + //$NON-NLS-1$
                " overrideGlobal=\"" + this.overrideGlobal + //$NON-NLS-1$
                "\" buildTool=\"" + this.buildTool + //$NON-NLS-1$
                "\" serverURI=\"" + this.serverURI + //$NON-NLS-1$
                "\" timeout=\"" + this.timeout + //$NON-NLS-1$
                "\" userId=\"" + this.userId + //$NON-NLS-1$
                "\" password " + (this.password == null ? "is not supplied" //$NON-NLS-1$//$NON-NLS-2$
                        : "(" + Secret.toString(this.password).length() + " characters)") //$NON-NLS-1$//$NON-NLS-2$
                + " passwordFile=\"" + this.passwordFile + "\" buildWorkspace=\"" + this.buildWorkspace + "\""); //$NON-NLS-3$
    }
}