IBM Connections API - Adding Members to Wiki - wiki

I've been trying to add members to the wiki to no avail. Here's the link to the instructions on how to do so:
http://www-10.lotus.com/ldd/appdevwiki.nsf/xpDocViewer.xsp?lookupName=IBM+Connections+4.5+API+Documentation#action=openDocument&res_title=Updating_a_wiki_ic45&content=pdcontent
Basically, what I need to do is to retrieve the wiki first using this URL:
connectionsURL/wikis/basic/api/wiki/{wiki-label}/entry
And then append the information there and then send it back using a PUT request, Content-Type: application/atom+xml. The content passed should look like the one below based on the example:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<id>ignore</id>
<td:label xmlns:td="urn:ibm.com/td">Lake Champlain</td:label>
<category term="wiki" scheme="tag:ibm.com,2006:td/type" label="wiki">
</category>
<author>
<name>Bill Jones</name>
<snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
bf9117c0-f8f2-102c-97c4-ceb7f24c5708
</snx:userid>
<email>bjones#us.example.com</email>
</author>
<td:sharedWith xmlns:td="urn:ibm.com/td">
<ca:member
xmlns:ca="http://www.ibm.com/xmlns/prod/composite-applications/v1.0"
ca:id="new_user_id"
ca:type="user"
ca:role="editor" >
</ca:member>
<ca:member
xmlns:ca="http://www.ibm.com/xmlns/prod/composite-applications/v1.0"
ca:id="anonymous-user"
ca:type="virtual"
ca:role="reader" >
</ca:member>
</td:sharedWith>
<title type="text">Long Lake</title>
<summary type="text">
modification none
</summary>
</entry>
I tried that and I always keep getting this 400 Bad Request response:
<?xml version="1.0" encoding="UTF-8" ?>
<td:error>
<td:errorCode>InvalidRequest</td:errorCode>
<td:errorMessage>Atom entry is null</td:errorMessage>
</td:error>

Try this API - https://conServer.com/wikis/basic/api/wiki/{WIKI_LABEL}/members
Then do a PUT on that resource to change the entries (I think type should be atom/xml or atom+cat/xml
Thanks
paul

Related

extract value from an bad xml string

First of all i would like to big thanks to everyone in this forum.
I was trying to extract one xml tag value in the below given xml string.
Input String was :-
<?xml version="1.0" encoding="UTF-8"?>
<nonpublicExecutionReportAcknowledgement xmlns="http://www.fpml.org/FpML-5/recordkeeping" fpmlVersion="5-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/FpML-5/recordkeeping /../xmls/SDR/recordkeeping/fpml-main-5-5.xsd">
<header>
<inReplyTo messageIdScheme="www.abc.com/msg_id">sit:GDS:1644644:1442512894123:SRD0IFR119094084</inReplyTo>
<sentBy>DTCCEU</sentBy>
<sendTo>RRasdfjasdfasdkllkd4</sendTo>
<creationTimestamp>2015-10-14T16:47:30Z</creationTimestamp>
</header>
<originalMessage>
<nonpublicExecutionReport fpmlVersion="5-5" xmlns="http://www.fpml.org/FpML-5/recordkeeping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<messageId messageIdScheme="www.abc.com/msg_id">sit:GDS:1644644:1442512894123:SRD0IFR119094084</messageId>
<sentBy messageAddressScheme="http://www.fpml.org/coding-scheme/external/cftc/interim-compliant-identifier">RRasdfjasdfasdkllkd4</sentBy>
<sendTo>DTCCEU</sendTo>
<creationTimestamp>2015-10-14T05:54:38Z</creationTimestamp>
</header>
</nonpublicExecutionReport>
</originalMessage>
</nonpublicExecutionReportAcknowledgement>
Regex i was used to extract messageId was "(?<=>).*?.(?=\</messageId)" which is working fine. But when it comes as single xml string it was not working as expected.
Failing for the below input string.
<?xml version="1.0" encoding="UTF-8"?><nonpublicExecutionReportAcknowledgement xmlns="http://www.fpml.org/FpML-5/recordkeeping" fpmlVersion="5-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/FpML-5/recordkeeping /../xmls/SDR/recordkeeping/fpml-main-5-5.xsd"><header><inReplyTo messageIdScheme="www.abc.com/msg_id">sit:GDS:1644644:1442512894123:SRD0IFR119094084</inReplyTo><sentBy>DTCCEU</sentBy><sendTo>RRasdfjasdfasdkllkd4</sendTo> <creationTimestamp>2015-10-14T16:47:30Z</creationTimestamp></header><originalMessage><nonpublicExecutionReport fpmlVersion="5-5" xmlns="http://www.fpml.org/FpML-5/recordkeeping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><header> <messageId messageIdScheme="www.abc.com/msg_id">sit:GDS:1644644:1442512894123:SRD0IFR119094084</messageId><sentBy messageAddressScheme="http://www.fpml.org/coding-scheme/external/cftc/interim-compliant-identifier">RRasdfjasdfasdkllkd4</sentBy><sendTo>DTCCEU</sendTo><creationTimestamp>2015-10-14T05:54:38Z</creationTimestamp></header></nonpublicExecutionReport> </originalMessage></nonpublicExecutionReportAcknowledgement>
Output required was :- "sit:GDS:1644644:1442512894123:SRD0IFR119094084"
the value should get extracted between
<messageId messageIdScheme="www.abc.com/msg_id"> and </messageId>
Could you please help me to build the regex string for the above problem it will be a great help.
Cheers,
KS
How about:
<inReplyTo messageIdScheme="www.abc.com/msg_id">([a-zA-Z0-9:]+)</inReplyTo>

How to display localized date?

How do i have XSLT display a localized date to the user (in the locale of the user-agent).
For example, given an xml date in ISO format (2013-09-04T10:46:19.658):
<?xml version="1.0" encoding="utf-8"?>
<Stuff>
<Created>2013-09-04T10:46:19.658</Created>
</Stuff>
And the beginnings of a stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" version="5.0" doctype-system="about:legacy-compat"/>
<xsl:template match="/Stuff">
<html>
<body>
Created: <xsl:value-of select="format-date('Created')"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The desired output depends, of course, on the locale of the user-agent (e.g. the client's browser):
Created: 01/11/34
Created: 05.09.13
Created: 05.09.2013
Created: 05/09 2013
Created: 05/09/2013
Created: 05-09-13
Created: 05-09-2013
Created: 09.05.2013
Created: 09/05/2013
Created: 13.09.05
Created: 2013.09.05
Created: 2013.09.05.
Created: 2013/09/05
Created: 2013/9/5
Created: 2013-09-05
Created: 2013-9-5
Created: 29/10/34
Created: 5. 9. 2013
Created: 5.09.2013
Created: 5.9.2013
Created: 5.9.2013 г.
Created: 5.9.2013.
Created: 5//09//2013
Created: 5/09/2013
Created: 5/9/2013
Created: 5/9/2556
Created: 5-9-2013
Created: 9/5/2013
Does XSLT support localization?
It runs on the client
The transformation of XML into HTML happens on the client. Since the transformation happens on the client, the client (obviously) knows its own locale.
For example, the client is given some xml:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='/Styles/Contoso_Handheld.xslt' media='handheld'?>
<?xml-stylesheet type='text/xsl' href='/Styles/Contoso_iPhone.xslt' media='only screen and (max-device-width: 480px)'?>
<?xml-stylesheet type='text/xsl' href='/Styles/Contoso.xslt' media='all'?>
<Stuff>
<Created>2013-09-04T10:46:19.658</Created>
</Stuff>
Notice the lines where the client in instructed which XSLT to use.
<?xml-stylesheet type='text/xsl' href='/Styles/Contoso_Handheld.xslt' media='handheld'?>
<?xml-stylesheet type='text/xsl' href='/Styles/Contoso_iPhone.xslt' media='only screen and (max-device-width: 480px)'?>
<?xml-stylesheet type='text/xsl' href='/Styles/Contoso.xslt' media='all'?>
The User-Agent fetches the XSLT, transforms the XML, and displays it to the user. All this processing happens in the locale of the client.
Standard XSLT 1.0 does not have any function to localize dates.
XSLT 2.0 has date and date-time formatting functions supporting localizations: see here but the implementation can vary - for example Saxon seem not to implement the calendar / language part.
Specific XSLT implementation have extension function supporting date-time localization - see for example this.
Even if you have a formatting function supporting localization you will still have the problem of find and pass the correct locale - if the XSLT is running on the server and the result is rendered in a browser the locale of the server could be the wrong one, and so you'll need to extract the locale information from the HTTP headers or with some JavaScript and use it on the server.

XMLNS attribute removed by Slow Cheetah transformation

I'm trying to use Slow Cheetah to transform a Windows scheduled task config file. I'm simply trying to add "repetition" node information, like so:
ORIGINAL:
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2013-01-02T09:32:12.2196371</Date>
<Author>xxx</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2013-01-10T01:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
.....
</Task>
REQUIRED, ADDITIONAL XML
<CalendarTrigger>
<Repetition>
<Interval>PT300S</Interval>
</Repetition>
</CalendarTrigger>
To do this, I have the following transformation file:
<?xml version="1.0" encoding="utf-16" ?>
<Task version="1.2">
<Triggers>
<CalendarTrigger xdt:Transform="Insert">
<Repetition>
<Interval>PT300S</Interval>
</Repetition>
</CalendarTrigger>
</Triggers>
</Task>
The problem I'm having is that all attributes outside of the CalendarTrigger node are removed (and therefore making the resultant transformation config an invalid scheduled task format).
I have tried adding
xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="SetAttributes" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"
to the Task node, but the attribute is then generated at CalendarTrigger level (and I cannot put this attribute on the original, because I then get "No element in the source document matches '/Task/Triggers' ").
Any pointers?
UPDATE:
The problem seems to be isolated to the xmlns attribute; if I try to include this in the 'Task' node of the original, I get "No element in the source document matches '/Task/Triggers'" - BUT changing this attribute to 'xmlns2' works fine and produces exactly what I need (albeit with an 'xmlns2' attribute!). Is this a known limitation of Slow Cheetah? Anyone know of a potential work-around?
That's because your xdt:Transform="Insert" is one level to high.
This should work:
<?xml version="1.0" encoding="utf-16" ?>
<Task xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<Triggers>
<CalendarTrigger>
<Repetition xdt:Transform="Insert">
<Interval>PT300S</Interval>
</Repetition>
</CalendarTrigger>
</Triggers>
</Task>

What is the recommended approach to use Mule choice router with XSLT

I am using the below shown snippet of choice element in my Mule 3.3 flow. XSL Transformer feeds the choice element. XSL Transformer is supposed to return a String (name of an entity) and on the basis of string value, I use choice router to push it to different jms queues.
<flow name="ProcessOrder">
.
.
<xm:xslt-transformer xsl-file="xsl/getEntity.xslt" returnClass="java.lang.String"/>
<choice>
<when expression="payload.contains('ABC')">
<jms:outbound-endpoint queue="order.queue1" />
</when>
<when>
</when>
<otherwise>
</otherwise>
</choice>
</flow>
XSL Transformer returns this payload
<?xml version="1.0" encoding="UTF-8"?>ABC
My question is how do I compare the String returned. I don't think payload.contains() is the best way to do this, though it solves my purpose and also we won't have matching entities returned which are ever like ABCxy but still this is not a full proof solution.
Add the omit-xml-declaration part in your xslt as shown below. This will give you the raw string without the prolog.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/">
...
...
This will give
"ABC" as output instead of "<?xml version="1.0" encoding="UTF-8"?>ABC"
Then in the expression use it like
<when expression="#[message.payload.contains('ABC')]">
This way it should work.
Maybe this is what you are looking for:
<when evaluator="xpath" expression="/result/" ...
Obviously, your XSLT will need to retur a well-formed XML document with the desired result in an XML element that is neatly accessible by XPath.
On Mule website they suggest to use expression-splitter-router evaluator this is an example from mule website of how to use it:
FruitBowl containing an apple, an orange, and two bananas. When Mule receives this object, we want to route the fruit to different locations: the AppleService, BananaService, and OrangeService.
<service name="Distributor">
<inbound>
<jms:inbound-endpoint queue="distributor.queue"/>
</inbound>
<outbound>
<!-- FruitBowl.getFruit() List -->
<expression-splitter-router evaluator="bean" expression="fruit">
<vm:outbound-endpoint path="apple.service.queue">
<payload-type-filter expectedType="org.mule.tck.testmodels.fruit.Apple"/>
</vm:outbound-endpoint>
<vm:outbound-endpoint path="banana.service.queue">
<payload-type-filter expectedType="org.mule.tck.testmodels.fruit.Banana"/>
</vm:outbound-endpoint>
<vm:outbound-endpoint path="orange.service.queue">
<payload-type-filter expectedType="org.mule.tck.testmodels.fruit.Orange"/>
</vm:outbound-endpoint>
</expression-splitter-router>
</outbound>
</service>
Hope that helps

Translating itunes affiliate rss via xslt

I can't get this working for the life of me. Here is a snippet of the xml I get from an RSS feed from itunes affiliate. I want top print the values within tags but I cannot for some reason:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<id>http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/sf=143441/limit=100/genre=6014/xml</id><title>iTunes Store: Top Paid Applications</title><updated>2010-03-24T15:36:42-07:00</updated><link rel="alternate" type="text/html" href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?id=25180&popId=30"/><link rel="self" href="http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/sf=143441/limit=100/genre=6014/xml"/><icon>http://phobos.apple.com/favicon.ico</icon><author><name>iTunes Store</name><uri>http://www.apple.com/itunes/</uri></author><rights>Copyright 2008 Apple Inc.</rights>
<entry>
<updated>date</updated>
<id>someID</id>
<title>a</title>
<im:name>b</im:name>
</entry>
<entry>
<updated>date2/updated>
<id>someID2</id>
<title>a2</title>
<im:name>b2</im:name>
</entry>
</feed>
If I try <xsl:apply-templates match="entry"/> it spits out the entire contents of file. If I use <xsl:call-template name="entry"> it will show only one entry and I have to use <xsl:value-of select="//*[local-name(.)='name']"/> to get name but that's a hack. I've used xslt before for xml without namespaces and xml that has proper parent child relationships but not like this RSS feed. Notice entry is not wrapped in entries or anything.
Any help is appreciated. I want to use xslt because I want to alter the itunes link to go through my affiliate account - so something automated wouldn't work for me.
You are matching elements that are in no namespace, but the actual elements in the XML document do belong to a (deafult) namspace: xmlns="http://www.w3.org/2005/Atom".
Therefore, you need to declare the namespace in your stylesheet, let's say xmlns:atom="http://www.w3.org/2005/Atom". and then match not just on {elementName} but on {atom:elementName}, where {elementName} in your case is: "entry".