Wikipedia API: how to retrieve multiple titles AND resolve redirects in 1 call? - redirect

It appears from the MediaWiki API:Query page that you can only resolve a redirect one at a time.
The document even says "The example below isn't really useful because it doesn't use any query modules, but shows how the redirects parameter works."
But how can you get the redirect information -- using a query module that does return multiple results?

If you have any result that returns pages, then you can just append redirects to the query and it resolves the redirects. If you don't have results that returns pages, you can usually convert it to that by using a generator.
For example, the query
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Redirects_from_gender&redirects
returns something like (shortened)
<api>
<query>
<categorymembers>
<cm pageid="648" ns="0" title="Actress" />
<cm pageid="19887132" ns="0" title="Administratrix" />
</categorymembers>
</query>
</api>
If you convert that into a generator
http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category:Redirects_from_gender
you get
<api>
<query>
<pages>
<page pageid="648" ns="0" title="Actress" />
<page pageid="19887132" ns="0" title="Administratrix" />
</pages>
</query>
</api>
And if you now add redirects
http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category:Redirects_from_gender&redirects
you get
<api>
<query>
<redirects>
<r from="Actress" to="Actor" />
<r from="Administratrix" to="Administrator (law)" />
</redirects>
<pages>
<page pageid="21504235" ns="0" title="Actor" />
<page pageid="6676496" ns="0" title="Administrator (law)" />
</pages>
</query>
</api>

You can also use prop=redirects with any generator, e.g. generator=allpages. This is a new feature since MW-1.23, fixing bug T59057.
When using generator=allpages with max limits (gaplimit=max and rdlimit=max) and apihighlimits right is available, all redirects on ArchWiki are resolved in a single query ;)
https://wiki.archlinux.org/api.php?action=query&generator=allpages&gapfilterredir=nonredirects&gaplimit=max&prop=redirects&rdprop=pageid|title|fragment&rdlimit=max

Related

How to Add additional columns to links page to ExternalLink types

How to add columns to ExternalLink on the "Links" page on Azure DevOps Workitem ?
Answered : Not Possible see answer below
Pull Request is not like Code Review Request, it's not a work item
type, we cannot see it from the exported process template. So, I don't
think we can customize the columns like the common work item types. –
Andy Li-MSFT
after going through the following links
link1
link2
and trying the workaround discussed here
I have failed to add more columns to links of the type externallink
i have added the following code as described:
<Page Label="Links" LayoutMode="FirstColumnWide">
<Section>
<Group Label="links">
<Control Type="LinksControl" Name="links">
<LinksControlOptions>
<LinkFilters>
<ExternalLinkFilter Type="Build" />
<ExternalLinkFilter Type="Integrated in build" />
<ExternalLinkFilter Type="Pull Request" />
<ExternalLinkFilter Type="Branch" />
<ExternalLinkFilter Type="Fixed in Commit" />
<ExternalLinkFilter Type="Fixed in Changeset" />
<ExternalLinkFilter Type="Source Code File" />
<ExternalLinkFilter Type="Found in build" />
<ExternalLinkFilter Type="GitHub Pull Request" />
<ExternalLinkFilter Type="GitHub Commit" />
</LinkFilters>
<Columns>
<Column Name="System.State" />
<Column Name="System.ChangedDate" />
<Column Name="System.PullRequest.IsFork" />
</Columns>
</LinksControlOptions>
</Control>
</Group>
</Section>
</Page>
But the results still show only the original columns.
The problem is that the field/column you added (<Column Name="System.PullRequest.IsFork" />) is not a valid work item filed/column. The workaround is only available for work item types due to the columns depend on work item fields.
You need to add a valid work item field/column here. We can get all the available work item fields by calling the Get Work Item REST API with parameter $expand=Fields added in the URL from a specific work item.
GET https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?$expand=Fields&api-version=4.1
For example, the following screenshots shows all the available fields for my Task work item. (It depends on how you defined the fields, if you defined a custom field, you can also see it from the response body.):
After that, we can add the columns (System.CreatedBy and Microsoft.VSTS.Common.Priority for example in this sample)
Then check the behavior in a Task work item:
Please note that, Pull Requests is not a work item type. We cannot get valid work item fields by calling the Pull Requests REST API. In this case, I don't think we can customize the columns like the common work item types.

Qlikview REST connector pagination namespaced XML

We have a XML file that is on somewebsite and looks in a way like this (confidential parts stripped)
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="https://somewebsite.com/crm/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Accounts</title>
<id></id>
<updated>2016-02-04T08:36:56Z</updated>
<link rel="self" title="Accounts" href="Accounts" />
<entry>
<title type="text"></title>
<updated>2016-02-04T08:36:56Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Type>A</d:Type>
<d:UniqueTaxpayerReference m:null="true" />
<d:VATLiability m:null="true" />
<d:VATNumber m:null="true" />
<d:Website m:null="true" />
</m:properties>
</content>
</entry>
<link rel="next" href="https://somewebsite.com/Accounts?$skiptoken=guid'ee6bc390-a8ac-4bbd-8a4d-0a1f04ab9bd3'" />
</feed>
We use the new Rest connector to get the data out of this XML file.
The XML has pagination and every 60 entries you can load the next 60 with the link at the bottom of this xml file.
The problem i have is when, in the REST connector, we want to enable pagination with these setting:
Pagination Type: Next URL
Next URL field path:
/*[name()="feed"]/*[name()="link"][contains(#rel,"next")]/#href
It doesn't seem to work...
side note: the XML file has namespaces so i need to target the elements this way instead of /feed/link/...
I'm using Xpath syntax to target the link href, but maybe this is not the way to go? Or maybe the REST connector isn't using Xpath syntax?
Really hope someone can help me!
Actually it turns out that this seems to be due to a "bug" in the "Qlik REST Connector 1.0" so the pagination doesn't work.
But there is a fix for it:
1) Make sure that the Qlik REST Connector 1.0 connect dialog box has the NextUrl set to:
feed/link/attr:href
2) When the SQL has been generated after using the SELECT-button and going through the wizard you have to modify the sub-SELECT that reads like this:
.....
(SELECT
"attr:rel" AS "rel",
"attr:title" AS "title",
"attr:href" AS href,
"__FK_link"
FROM "link" FK "__FK_link"),
.....
On line 05 you will have to remove the text AS href.
So it should look like this:
.....
(SELECT
"attr:rel" AS "rel",
"attr:title" AS "title",
"attr:href",
"__FK_link"
FROM "link" FK "__FK_link"),
....
3) Find the LOAD statement that loads from this sub-select with a RESIDENT [MasterREST further down in the load script and make sure that the reference to href is changed to [attr:href] - or else you will get an error message while loading.
Should look like this after the change:
[link]:
LOAD [rel],
[title],
[attr:href],
[__FK_link] AS [__KEY_feed]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_link]);
This worked for me:
/*[name()='feed']/*[name()='link'][#rel='next']/#href
Yours should also work actually, maybe whatever you are using does not agree with double quotes instead of single quotes.

Same XACML request different response when I use wso2is and Java application

Hi I’m having problem understand why I get different response when I use the (org.xacmlinfo.xacml.pep.agent.PEPAgent.java) and the tryit function in WSO2IS 5.0.0. They are querying the same policy.
<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="OfficeHours" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides" Version="1.0">
<Description>denyOutsideOfficeHours</Description>
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">foo.com</AttributeValue>
<AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Permit" RuleId="PermitInOfficeHours">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">12:00:00</AttributeValue>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">17:00:00</AttributeValue>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
<AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" DataType="http://www.w3.org/2001/XMLSchema#time"></AttributeDesignator>
</Apply>
</Apply>
</Condition>
</Rule>
</Policy>
PEPAgent
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" IncludeInResult="false"><AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">foo.com</AttributeValue>
</Attribute>
</Attributes>
</Request>
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<Result>
<Decision>Indeterminate</Decision><Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:processing-error"/>
<StatusMessage>urn:oasis:names:tc:xacml:1.0:function:time-one-and-only expects a bag that contains a single element, got a bag with 0 elements</StatusMessage>
</Status>
</Result>
</Response>
Tryit
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">foo.com</AttributeValue>
</Attribute></Attributes></Request>
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<Result><Decision>Permit</Decision><Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</Status><PolicyIdentifierList>
<PolicyIdReference>OfficeHours</PolicyIdReference>
</PolicyIdentifierList>
</Result>
</Response>
First of all here are a few comments regarding your policy and rule:
the policy description doesn't match the rule description. In one case you say deny, in the other you say Permit.
you use a Condition where in fact a Target would be enough.
Now, as for the different responses: in one case your code (PEPAgent) doesn't send the current time value and the server (is that the PDP?) doesn't add the time either. In the second case, the Tryit client still doesn't send time but obviously the receiving end (another PDP?) fills in the missing time value.
If you look more closely at your first response, you will notice the following error message:
<StatusMessage>urn:oasis:names:tc:xacml:1.0:function:time-one-and-only expects a bag that contains a single element, got a bag with 0 elements</StatusMessage>
This means that you didn't pass in any value for current-time.
I tested this using the Axiomatics Policy Server and I received the expected behavior.

action-state not accept evaluate tags Spring Web Flow 2.3

Eclipse marks this error
cvc-complex-type.2.4.a: Invalid content was found starting with element 'action-state'. One of '{"http://www.springframework.org/schema/webflow":on-end, "http://www.springframework.org/schema/webflow":output, "http://www.springframework.org/schema/webflow":exception-handler, "http://www.springframework.org/schema/webflow":bean-import}' is expected.
on this flow code
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
abstract="true">
<global-transitions>
<transition on="logIn" to ="login" />
<transition on="signup" to="signup"/>
<transition on="logOut" to="logout"/>
</global-transitions>
<action-state id="logout">
<evaluate expression="login.logout(currentUser)" />
<transition on="successLogout" to="main" />
<transition on="failLogout" to="error" />
</action-state>
I only find action-state samples and everyone are writting like my code and people use the same XSD. Either, I have read XSD file and on action-state section tag evaluate is missing. Why eclipse marks this error?
Thanks in advance!
I think there has to be an order in which the elements are defined. Try defining the action-state before the global-transitions. If you hover your mouse pointer over the "flow" xml definition in your xml file this info appears (among others):
Content Model : (attribute*, secured?, persistence-context?, var*, input*, on-start?, (action-state | view-state | decision-state | subflow-state | end-state)*, global-transitions?, on-end?, output*, exception-handler*, bean-import*)
So, there is a strict sequence.

Default route is matched instead specific route

<routes>
<www type="Zend_Controller_Router_Route_Hostname">
<route>www.domain.com</route>
<chains>
<index type="Zend_Controller_Router_Route">
<route></route>
<defaults module="default" controller="index" action="index" />
</index>
<community>
<route>community</route>
<defaults module="community" />
<chains>
<index type="Zend_Controller_Router_Route">
<route>:action/*</route>
<defaults controller="index" action="index" />
</index>
<member type="Zend_Controller_Router_Route_Regex">
<route>member/profile-(\d+)-(.+)</route>
<reverse>member/profile-%d-%s</reverse>
<map>
<id>1</id>
<nom>2</nom>
</map>
<defaults action="viewmember" />
</member>
</chains>
</community>
</chains>
</www>
As you can see, I use a route with :action/* in to cover the homepages and the basics actions on index controller.
domain.com/community/random_action => works good.
domain.com/community/ doesn't work. The whole homepage is displayed.
I checked, and the default route is matched.
I tried assemble() on route "www-community-index" and it gives well www.domain.com/community
I don't see from where comes the problem :(
The first thing you should check is if you deleted the default route.
The second one is....remember that the routes are checked in reverse order. This means that the most specific should be the first and the default the last one.