Package com.salas.bb.domain

Examples of com.salas.bb.domain.FeedMetaDataHolder


    {
        long lastUpdate = aFeed.getLastMetaDataUpdateTime();
        if (lastUpdate < updateTimeThreshold)
        {
            URL baseURL = getBaseURL(aFeed);
            FeedMetaDataHolder holder = aFeed.getMetaDataHolder();
            if (baseURL != null && holder != null)
            {
                if (LOG.isLoggable(Level.FINE)) LOG.fine("Updating meta-data of " + aFeed);
                metaDataManager.update(holder, baseURL);
            }
View Full Code Here


     *
     * @return meta-data object.
     */
    public FeedMetaDataHolder lookup(URL url)
    {
        FeedMetaDataHolder holder = null;

        if (url != null)
        {
            String urlString = url.toString();
            synchronized (repository)
View Full Code Here

        }

        List holdersList = new ArrayList(holders.length);
        for (int i = 0; i < holders.length; i++)
        {
            FeedMetaDataHolder holder = holders[i];
            if (holder.isComplete() && holder.isDiscoveredValid() && !holdersList.contains(holder))
            {
                holdersList.add(holder);
            }
        }
View Full Code Here

        List keysToRemove = new ArrayList();
        for (int i = 0; i < entries.length; i++)
        {
            Map.Entry entry = entries[i];
            FeedMetaDataHolder holder = (FeedMetaDataHolder)entry.getValue();

            if (holdersList.contains(holder)) keysToRemove.add(entry.getKey());
        }

        Iterator iterator = keysToRemove.iterator();
View Full Code Here

     * @param aConnectionState  connection state interface.
     */
    public static void processDiscovery(MDDiscoveryRequest aRequest,
                                        ConnectionState aConnectionState)
    {
        FeedMetaDataHolder holder = aRequest.getHolder();
        holder.setComplete(false);

        if (!isFilteredOut(aRequest.getUrl()))
        {
            queryDirectly(aRequest);
            if (aConnectionState.isServiceAccessible() && !aRequest.isLocal()) queryService(aRequest);
        } else
        {
            // If the URL is filtered out and no discovery necessary,
            // we mark the link as invalid and all discovery methods as complete.
            holder.setInvalid(true);
            aRequest.setDirectDiscoveryComplete(true);
            aRequest.setServiceDiscoveryComplete(true);
        }

        updateHolderStatus(aRequest);
View Full Code Here

        boolean directComplete = request.isDirectDiscoveryComplete();
        boolean serviceComplete = request.isServiceDiscoveryComplete();
        boolean local = request.isLocal();

        FeedMetaDataHolder holder = request.getHolder();
        if (holder.isInvalid() != null)
        {
            boolean invalid = holder.isInvalid();

            if (((directComplete || serviceComplete) && !invalid) ||
                 (directComplete && serviceComplete && invalid))
            {
                complete = true;
            }
        } else if (local && directComplete)
        {
            complete = true;
        }

        if (complete)
        {
            holder.setComplete(true);
            holder.setLastUpdateTime(System.currentTimeMillis());
        }
    }
View Full Code Here

     *
     * @param request   discovery request.
     */
    private static void queryDirectly(MDDiscoveryRequest request)
    {
        FeedMetaDataHolder holder = request.getHolder();
        if (request.isDirectDiscoveryComplete() || holder.getXmlURL() != null) return;

        if (LOG.isLoggable(Level.FINE))
        {
            LOG.fine("Direct discovery started: URL=" + request.getUrl());
        }

        DirectDiscoverer dd = new DirectDiscoverer();
        String failureMessage = null;
        try
        {
            DiscoveryResult res = dd.discover(request.getUrl());
            if (res != null)
            {
                URL link = res.getLink();
                if (link != null)
                {
                    holder.setXmlURL(link);
                    holder.setInvalid(false);
                }
            }

            request.setDirectDiscoveryComplete(true);
        } catch (UrlDiscovererException e)
        {
            Throwable cause = e.getCause();
            failureMessage = causeToFailureMessage(cause);

            if (failureMessage != null)
            {
                request.setDirectDiscoveryComplete(true);

                // We can't set invalid flag here because it is very brief check
                // and we can count only on positive result.
            } else
            {
                LOG.log(Level.FINE, "Direct discovery failed temporary.", e);
            }
        } catch (IllegalArgumentException e)
        {
            // This exception is thrown by parser when it is unable to find root element of
            // the feed. Usually it happens when we give it non-xml file as input. Here we mark direct
            // discovery as complete as it doesn't make any sense to continue hitting the same exception.

            request.setDirectDiscoveryComplete(true);
        }

        if (request.isDirectDiscoveryComplete() && LOG.isLoggable(Level.FINE))
        {
            LOG.fine("Direct discovery finished: URL=" + request.getUrl() +
                (holder.getXmlURL() != null ? " Discovered" : " Undiscovered") +
                (failureMessage != null ? " (" + failureMessage + ")" : ""));
        }
    }
View Full Code Here

        // Read data into the wrapper
        Integer statusCodeI = (Integer)results.get(KEY_STATUS_CODE);
        int statusCode = statusCodeI == null ? -1 : statusCodeI;

        // Make decision what to do with information
        FeedMetaDataHolder holder = request.getHolder();
        switch (statusCode)
        {
            case STATUS_PROCESSING:
                break;
            case STATUS_VALID:
                copyData(results, holder, request.getUrl());
                holder.setInvalid(false);
                request.setServiceDiscoveryComplete(true);
                break;
            case STATUS_INVALID:
                if (holder.isInvalid() == null) holder.setInvalid(true);
                request.setServiceDiscoveryComplete(true);
                break;
            default:
                LOG.warning(MessageFormat.format("Unrecognized service code: {0}", statusCode));
        }
View Full Code Here

     *
     * @return meta-data object.
     */
    public FeedMetaDataHolder lookupOrDiscover(URL url)
    {
        FeedMetaDataHolder holder = lookup(url);

        if (holder == null)
        {
            holder = new FeedMetaDataHolder();
            repository.record(holder, url);
            discoverer.scheduleDiscovery(url, holder);
        }

        return holder;
View Full Code Here

     *
     * @param request   discovery request.
     */
    private void discoveryFinished(MDDiscoveryRequest request)
    {
        FeedMetaDataHolder holder = request.getHolder();

        boolean reschedule = !holder.isComplete() ||
            (!request.isServiceDiscoveryComplete() && !request.isLocal());

        if (holder.isComplete())
        {
            URL url = request.getUrl();

            if (LOG.isLoggable(Level.FINE)) LOG.fine("Discovery finished: " + url);

            if (!reschedule) markAsNotScheduled(url);
        }

        fireDiscoveryFinished(request.getUrl(), holder.isComplete());

        if (reschedule) rescheduleDiscovery(request);
    }
View Full Code Here

TOP

Related Classes of com.salas.bb.domain.FeedMetaDataHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.