Examples of LinkInformation


Examples of org.eurekastreams.server.domain.stream.LinkInformation

     *             shouldn't happen.
     */
    @Test
    public final void imgDownloadRelativePathNoTrailingSlashTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com");

        final String html = "<html><body>" + "<img src=\"someimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
            {
                oneOf(urlUtils).getImgHeight("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

                oneOf(urlUtils).getImgWidth("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

            }
        });

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertTrue(link.getImageUrls().contains("http://www.someurl.com/someimg1.png"));

        context.assertIsSatisfied();
    }
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

     *             shouldn't happen.
     */
    @Test
    public final void imgDownloadRelativePathTrailingSlashTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com/");

        final String html = "<html><body>" + "<img src=\"someimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
            {
                oneOf(urlUtils).getImgHeight("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

                oneOf(urlUtils).getImgWidth("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

            }
        });

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertTrue(link.getImageUrls().contains("http://www.someurl.com/someimg1.png"));

        context.assertIsSatisfied();
    }
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

     *             shouldn't happen.
     */
    @Test
    public final void malformedUrl() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com/");

        final String html = "<html><body>" + "<img src=\"http://\\f\\2w\\asomeimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

     *             shouldn't happen.
     */
    @Test
    public final void ioExceptionUrl() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com/");

        final String html = "<html><body>" + "<img src=\"http://\\f\\2w\\asomeimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

        // faster one
        if (((fetchedLink == null || fetchedLink == "") && link == null) || fetchedLink == link.getUrl())
        {     
          linkUrl.setText("");
            linkUrl.checkBox();
            LinkInformation addedLink = link;

            if (null == addedLink)
            {
                addedLink = new LinkInformation();
            }

            addPanel.setVisible(false);
            fetchLink.removeStyleName(StaticResourceBundle.INSTANCE.coreCss().verifyingLink());
            displayPanel.setVisible(null != link);
            addLink.setVisible(null == link);

            selector.setLink(addedLink);

            if (!addedLink.getImageUrls().isEmpty())
            {
                displayPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().hasThumbnail());
            }

            linkUrlDisplay.setText("source: " + addedLink.getSource());

            title.setVisibleLength(MAX_LENGTH);
            title.setValue(addedLink.getTitle());
            title.addBlurHandler(new BlurHandler()
            {
                public void onBlur(final BlurEvent event)
                {
                    // This check is a workaround for the real problem, which is that the blur handler is getting wired
                    // up
                    // multiple times (once on the first time the user clicks 'add link' and once when the activity is
                    // posted and everything is being cleared out). Maybe this control will get redesigned when
                    // PostToStreamComposite gets refactored from MVC to the current design.
                    if (link != null)
                    {
                        link.setTitle(title.getValue());
                    }
                }
            });

            linkDesc.setText(addedLink.getDescription());
        }
    }
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

                    .makeRequest("getParsedLinkInformation", inLinkUrl, new AsyncCallback<LinkInformation>()
                    {
                        /* implement the async call back methods */
                        public void onFailure(final Throwable caught)
                        {
                            LinkInformation linkInformation = new LinkInformation();
                            linkInformation.setTitle(inLinkUrl);
                            linkInformation.setUrl(inLinkUrl);

                            MessageAttachmentChangedEvent event = new MessageAttachmentChangedEvent(new Bookmark(
                                    linkInformation));
                            eventBus.notifyObservers(event);

View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

    public final void performActionLinkCachedTest() throws Exception
    {
        final Serializable[] params = new Serializable[1];
        params[0] = "http://www.youtube.com/someFile.html";

        final LinkInformation link = new LinkInformation();

        context.checking(new Expectations()
        {
            {
                oneOf(fileDownloader).getFinalUrl((String) params[0], TEST_ACCOUNT);
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

    @Override
    public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException
    {
        String url = (String) inActionContext.getParams();

        LinkInformation theLink = null;

        try
        {
            // First see if the user supplied a url with a protocol. If they didn't
            // prepend http:// onto it.
            if (!Pattern.matches("^([a-z]+://.+)", url))
            {
                url = "http://" + url;
            }
            url = connection.getFinalUrl(url, inActionContext.getPrincipal().getAccountId());

            UniqueStringRequest req = new UniqueStringRequest(url);
            theLink = mapper.execute(req);

            if (null == theLink)
            {
                theLink = new LinkInformation();
                theLink.setUrl(url);
                // set the source to the protocol + authority
                // (Take everything up to the first slash beyond the protocol-authority separator ://)
                int postAuthorityIndex = url.indexOf("/", url.indexOf("://") + "://".length());
                theLink.setSource(postAuthorityIndex == -1 ? url : url.substring(0, postAuthorityIndex));

                // Attempt to retrieve the contents of the resource.
                log.debug("Downloading resource: " + url);
                try
                {
                    String htmlString = connection.downloadFile(url, inActionContext.getPrincipal().getAccountId());
                    htmlString = htmlString.replace("\\s+", " ");

                    String host = connection.getHost(url);

                    for (HtmlLinkParser strategy : parsingStrategies)
                    {
                        Matcher match = Pattern.compile(strategy.getRegex()).matcher(host);

                        if (match.find())
                        {
                            log.debug("Found: " + strategy.getRegex());
                            strategy.parseLinkInformation(htmlString, theLink, inActionContext.getPrincipal()
                                    .getAccountId());
                            break;
                        }
                        else
                        {
                            log.debug("Didn't find: " + strategy.getRegex());
                        }
                    }
                }
                catch (Exception e)
                {
                    log.info("Failed to download resource and extract link information from it.", e);
                }

                theLink.setCreated(new Date());
                insertMapper.execute(new PersistenceRequest<LinkInformation>(theLink));
                insertMapper.flush();
            }
        }
        catch (Exception ex)
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

        final UniqueStringRequest req = new UniqueStringRequest("http://www.someurl.com");
        sut.setEntityManager(entityManager);
        sut.setQueryOptimizer(queryOptimizer);

        final LinkInformation link = new LinkInformation();
        link.setCreated(new Date());

        final List<LinkInformation> results = new ArrayList<LinkInformation>();
        results.add(link);

        final long timeOut = 7200000L;
View Full Code Here

Examples of org.eurekastreams.server.domain.stream.LinkInformation

        final UniqueStringRequest req = new UniqueStringRequest("http://www.someurl.com");
        sut.setEntityManager(entityManager);
        sut.setQueryOptimizer(queryOptimizer);

        final LinkInformation link = new LinkInformation();
        link.setCreated(new Date(0));

        sut.setExpirationInMilliseconds(0L);

        final List<LinkInformation> results = new ArrayList<LinkInformation>();
        results.add(link);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.