private void processImage(Element element, IFeed feed) { IImage image = Owl.getModelFactory().createImage(feed); /* Check wether the Attributes are to be processed by a Contribution */ processNamespaceAttributes(element, image); /* Interpret Children */ List<?> imageChilds = element.getChildren(); for (Iterator<?> iter = imageChilds.iterator(); iter.hasNext(); ) { Element child = (Element) iter.next(); String name = child.getName().toLowerCase(); /* Check wether this Element is to be processed by a Contribution */ if (processElementExtern(child, image)) continue; /* URL */ else if ("url".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) image.setLink(uri); processNamespaceAttributes(child, image); } /* Title */ else if ("title".equals(name)) { // $NON-NLS-1$ image.setTitle(child.getText()); processNamespaceAttributes(child, image); } /* Link */ else if ("link".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) image.setHomepage(uri); processNamespaceAttributes(child, image); } /* Description */ else if ("description".equals(name)) { // $NON-NLS-1$ image.setDescription(child.getText()); processNamespaceAttributes(child, image); } /* Width */ else if ("width".equals(name)) { // $NON-NLS-1$ int width = StringUtils.stringToInt(child.getTextNormalize()); if (width >= 0) image.setWidth(width); processNamespaceAttributes(child, image); } /* Height */ else if ("height".equals(name)) { // $NON-NLS-1$ int height = StringUtils.stringToInt(child.getTextNormalize()); if (height >= 0) image.setHeight(height); processNamespaceAttributes(child, image); } } }
/* * @see * org.rssowl.core.connection.auth.ICredentialsProvider#getProxyCredentials * (java.net.URI) */ public IProxyCredentials getProxyCredentials(URI link) { Activator activator = Activator.getDefault(); /* Check if Bundle is Stopped */ if (activator == null) return null; IProxyService proxyService = activator.getProxyService(); /* Check if Proxy is enabled */ if (!proxyService.isProxiesEnabled()) return null; String host = URIUtils.safeGetHost(link); boolean isSSL = URIUtils.HTTPS_SCHEME.equals(link.getScheme()); /* Retrieve Proxy Data */ final IProxyData proxyData = proxyService.getProxyDataForHost( host, isSSL ? IProxyData.HTTPS_PROXY_TYPE : IProxyData.HTTP_PROXY_TYPE); if (proxyData != null) { /* Look for Domain as part of Username to support NTLM Proxy */ final String proxyHost = proxyData.getHost(); final int proxyPort = proxyData.getPort(); final Pair<String /* Username */, String /* Domain */> proxyUserAndDomain = splitUserAndDomain(proxyData.getUserId()); final String proxyPassword = proxyData.getPassword(); /* Return as IProxyCredentials Object */ return new IProxyCredentials() { public String getHost() { return proxyHost; } public int getPort() { return proxyPort; } public String getUsername() { return proxyUserAndDomain.getFirst(); } public String getPassword() { return proxyPassword; } public String getDomain() { return proxyUserAndDomain.getSecond(); } }; } /* Feed does not require Proxy or Credentials not supplied */ return null; }
private void processEnclosure(Element element, INews news) { IAttachment attachment = Owl.getModelFactory().createAttachment(null, news); /* Interpret Attributes */ List<?> attachmentAttributes = element.getAttributes(); for (Iterator<?> iter = attachmentAttributes.iterator(); iter.hasNext(); ) { Attribute attribute = (Attribute) iter.next(); String name = attribute.getName().toLowerCase(); /* Check wether this Attribute is to be processed by a Contribution */ if (processAttributeExtern(attribute, attachment)) continue; /* URL */ else if ("url".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(attribute.getValue()); if (uri != null) { attachment.setLink(uri); } } /* Type */ else if ("type".equals(name)) // $NON-NLS-1$ { attachment.setType(attribute.getValue()); /*Generate the mp3 player HTML Object */ if (!Owl.getPreferenceService().getGlobalScope().getBoolean(DefaultPreferences.HIDE_MP3)) { if (Mp3Util.isMp3(attribute.getValue())) { String HTMLtoAppend = ""; // $NON-NLS-1$ if (!(news.isNewsWithMp3())) { news.setNewsWithMp3(); HTMLtoAppend += Mp3Util.getHeader(); } HTMLtoAppend += Mp3Util.getPlayerCode(attachment.getLink().toString()); news.setDescription(news.getDescription() + HTMLtoAppend); } } } /* Length */ else if ("length".equals(name)) { // $NON-NLS-1$ int length = StringUtils.stringToInt(attribute.getValue()); if (length >= 0) attachment.setLength(length); } } }
private void processTextInput(Element element, IFeed feed) { ITextInput input = Owl.getModelFactory().createTextInput(feed); /* Check wether the Attributes are to be processed by a Contribution */ processNamespaceAttributes(element, input); /* Interpret Attributes */ List<?> inputChilds = element.getChildren(); for (Iterator<?> iter = inputChilds.iterator(); iter.hasNext(); ) { Element child = (Element) iter.next(); String name = child.getName().toLowerCase(); /* Check wether this Element is to be processed by a Contribution */ if (processElementExtern(child, input)) continue; /* Title */ else if ("title".equals(name)) { // $NON-NLS-1$ input.setTitle(child.getText()); processNamespaceAttributes(child, input); } /* Description */ else if ("description".equals(name)) { // $NON-NLS-1$ input.setDescription(child.getText()); processNamespaceAttributes(child, input); } /* Name */ else if ("name".equals(name)) { // $NON-NLS-1$ input.setName(child.getText()); processNamespaceAttributes(child, input); } /* Link */ else if ("link".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) input.setLink(uri); processNamespaceAttributes(child, input); } } }
private void processSource(Element element, INews news) { ISource source = Owl.getModelFactory().createSource(news); source.setName(element.getText()); /* Check wether the Attributes are to be processed by a Contribution */ processNamespaceAttributes(element, source); /* Interpret Attributes */ List<?> attributes = element.getAttributes(); for (Iterator<?> iter = attributes.iterator(); iter.hasNext(); ) { Attribute attribute = (Attribute) iter.next(); String name = attribute.getName().toLowerCase(); /* Check wether this Attribute is to be processed by a Contribution */ if (processAttributeExtern(attribute, source)) continue; /* URL */ else if ("url".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(attribute.getValue()); if (uri != null) source.setLink(uri); } } }
private void processChannel(Element element, IFeed feed) { /* Interpret Attributes */ List<?> attributes = element.getAttributes(); for (Iterator<?> iter = attributes.iterator(); iter.hasNext(); ) { Attribute attribute = (Attribute) iter.next(); /* Check wether this Attribute is to be processed by a Contribution */ processAttributeExtern(attribute, feed); } /* Interpret Children */ List<?> channelChildren = element.getChildren(); for (Iterator<?> iter = channelChildren.iterator(); iter.hasNext(); ) { Element child = (Element) iter.next(); String name = child.getName().toLowerCase(); /* Check wether this Element is to be processed by a Contribution */ if (processElementExtern(child, feed)) continue; /* Item */ else if ("item".equals(name)) // $NON-NLS-1$ processItems(child, feed); /* Title */ else if ("title".equals(name)) { // $NON-NLS-1$ feed.setTitle(child.getText()); processNamespaceAttributes(child, feed); } /* Link */ else if ("link".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); /* * Do not use the URI if it is empty. This is a workaround for * FeedBurner feeds that use a Atom 1.0 Link Element in place of an RSS * feed which RSSOwl 2 is not yet able to handle on this scope. */ if (uri != null && StringUtils.isSet(uri.toString())) feed.setHomepage(uri); processNamespaceAttributes(child, feed); } /* Description */ else if ("description".equals(name)) { // $NON-NLS-1$ feed.setDescription(child.getText()); processNamespaceAttributes(child, feed); } /* Publish Date */ else if ("pubdate".equals(name)) { // $NON-NLS-1$ feed.setPublishDate(DateUtils.parseDate(child.getText())); processNamespaceAttributes(child, feed); } /* Image */ else if ("image".equals(name)) // $NON-NLS-1$ processImage(child, feed); /* Language */ else if ("language".equals(name)) { // $NON-NLS-1$ feed.setLanguage(child.getText()); processNamespaceAttributes(child, feed); } /* Copyright */ else if ("copyright".equals(name)) { // $NON-NLS-1$ feed.setCopyright(child.getText()); processNamespaceAttributes(child, feed); } /* Webmaster */ else if ("webmaster".equals(name)) { // $NON-NLS-1$ feed.setWebmaster(child.getText()); processNamespaceAttributes(child, feed); } /* Managing Editor */ else if ("managingeditor".equals(name)) { // $NON-NLS-1$ IPerson person = Owl.getModelFactory().createPerson(null, feed); person.setName(child.getText()); processNamespaceAttributes(child, person); } /* Last Build Date */ else if ("lastbuilddate".equals(name)) { // $NON-NLS-1$ feed.setLastBuildDate(DateUtils.parseDate(child.getText())); processNamespaceAttributes(child, feed); } /* Category */ else if ("category".equals(name)) // $NON-NLS-1$ processCategory(child, feed); /* Generator */ else if ("generator".equals(name)) { // $NON-NLS-1$ feed.setGenerator(child.getText()); processNamespaceAttributes(child, feed); } /* Docs */ else if ("docs".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) feed.setDocs(uri); processNamespaceAttributes(child, feed); } /* Rating */ else if ("rating".equals(name)) { // $NON-NLS-1$ feed.setRating(child.getText()); processNamespaceAttributes(child, feed); } /* TTL */ else if ("ttl".equals(name)) { // $NON-NLS-1$ int ttl = StringUtils.stringToInt(child.getTextNormalize()); if (ttl >= 0) feed.setTTL(ttl); processNamespaceAttributes(child, feed); } /* Skip Hours */ else if ("skiphours".equals(name)) { // $NON-NLS-1$ processNamespaceAttributes(child, feed); List<?> skipHoursChildren = child.getChildren("hour"); // $NON-NLS-1$ /* For each <hour> Element */ for (Iterator<?> iterator = skipHoursChildren.iterator(); iterator.hasNext(); ) { Element skipHour = (Element) iterator.next(); processNamespaceAttributes(skipHour, feed); int hour = StringUtils.stringToInt(skipHour.getTextNormalize()); if (0 <= hour && hour < 24) feed.addHourToSkip(hour); } } /* Skip Days */ else if ("skipdays".equals(name)) { // $NON-NLS-1$ processNamespaceAttributes(child, feed); List<?> skipDaysChildren = child.getChildren("day"); // $NON-NLS-1$ /* For each <day> Element */ for (Iterator<?> iterator = skipDaysChildren.iterator(); iterator.hasNext(); ) { Element skipDay = (Element) iterator.next(); processNamespaceAttributes(skipDay, feed); String day = skipDay.getText().toLowerCase(); int index = IFeed.DAYS.indexOf(day); if (index >= 0) feed.addDayToSkip(index); } } /* TextInput */ else if ("textinput".equals(name)) // $NON-NLS-1$ processTextInput(child, feed); /* Cloud */ else if ("cloud".equals(name)) // $NON-NLS-1$ processCloud(child, feed); } }
private void processItems(Element element, IFeed feed) { INews news = Owl.getModelFactory() .createNews(null, feed, new Date(System.currentTimeMillis() - (fNewsCounter++ * 1))); news.setBase(feed.getBase()); /* Check wether the Attributes are to be processed by a Contribution */ processNamespaceAttributes(element, news); /* Interpret Children */ List<?> newsChilds = element.getChildren(); for (Iterator<?> iter = newsChilds.iterator(); iter.hasNext(); ) { Element child = (Element) iter.next(); String name = child.getName().toLowerCase(); /* Check wether this Element is to be processed by a Contribution */ if (processElementExtern(child, news)) continue; /* Title */ else if ("title".equals(name)) { // $NON-NLS-1$ news.setTitle(child.getText()); processNamespaceAttributes(child, news); } /* Link */ else if ("link".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) { news.setLink(uri); itemUrl = child.getText(); } processNamespaceAttributes(child, news); } /* Description */ else if ("description".equals(name)) { // $NON-NLS-1$ if (!Owl.getPreferenceService().getGlobalScope().getBoolean(DefaultPreferences.HIDE_LIKE)) { news.setDescription(child.getText() + FacebookLikeUtil.getButtonCode(itemUrl)); processNamespaceAttributes(child, news); } else { news.setDescription(child.getText()); processNamespaceAttributes(child, news); } } /* Publish Date */ else if ("pubdate".equals(name)) { // $NON-NLS-1$ news.setPublishDate(DateUtils.parseDate(child.getText())); processNamespaceAttributes(child, news); } /* Author */ else if ("author".equals(name)) { // $NON-NLS-1$ IPerson person = Owl.getModelFactory().createPerson(null, news); person.setName(child.getText()); processNamespaceAttributes(child, person); } /* Comments */ else if ("comments".equals(name)) { // $NON-NLS-1$ news.setComments(child.getText()); processNamespaceAttributes(child, news); } /* Attachment */ else if ("enclosure".equals(name)) // $NON-NLS-1$ processEnclosure(child, news); /* Category */ else if ("category".equals(name)) // $NON-NLS-1$ processCategory(child, news); /* GUID */ else if ("guid".equals(name)) // $NON-NLS-1$ processGuid(child, news); /* Source */ else if ("source".equals(name)) // $NON-NLS-1$ processSource(child, news); } }