IBM Jazz Team Server: How to retrieve changes from a change set? - java

I use the REST API to retrieve the change set from a project. I get for example the following response:
{
"changes": [
{
"kind": 2,
"item": {
"uri": "itemOid\/com.ibm.team.filesystem.FileItem\/_2ItWACJKEeGAaaEbbqTtgw",
"itemId": "_2ItWACJKEeGAaaEbbqTtgw",
"com.ibm.team.repository.typeName": "com.ibm.team.filesystem.FileItem"
},
"before": "_Rx7-BCJaEeG25dOp_iUerQ",
"after": "_Ngn9BCJeEeG25dOp_iUerQ",
"internalId": "_NhCzwCJeEeG25dOp_iUerQ"
},
{
"kind": 1,
"item": {
"uri": "itemOid\/com.ibm.team.filesystem.FileItem\/_GWB-kCJeEeGAaaEbbqTtgw",
"itemId": "_GWB-kCJeEeGAaaEbbqTtgw",
"com.ibm.team.repository.typeName": "com.ibm.team.filesystem.FileItem"
},
"before": null,
"after": "_Ngn9CyJeEeG25dOp_iUerQ",
"internalId": "_NhCzwSJeEeG25dOp_iUerQ"
}
],
"comment": "",
"lastUpdatedDate": "2011-12-09T12:06:52.266Z",
"active": false,
"owner": {
"uri": "itemOid\/com.ibm.team.repository.Contributor\/_hhbosPC1EeCsJbI2ZgPDog",
"itemId": "_hhbosPC1EeCsJbI2ZgPDog",
"com.ibm.team.repository.typeName": "com.ibm.team.repository.Contributor"
},
"com.ibm.team.repository.typeName": "com.ibm.team.scm.ChangeSet",
"stateId": "_R7C54SJeEeG25dOp_iUerQ",
"component": {
"uri": "itemOid\/com.ibm.team.scm.Component\/_auolkPC9EeCek69P-ztT9w",
"itemId": "_auolkPC9EeCek69P-ztT9w",
"com.ibm.team.repository.typeName": "com.ibm.team.scm.Component"
},
"contextId": "_Dp6kMdwTEd2jUupDpQV1Rw",
"predecessor": "_NhCzwiJeEeG25dOp_iUerQ",
"modified": "2011-12-09T12:06:52.288Z",
"mergePredecessor": null,
"uri": "itemOid\/com.ibm.team.scm.ChangeSet\/_Nb_UoCJeEeG25dOp_iUerQ",
"itemId": "_Nb_UoCJeEeG25dOp_iUerQ",
"properties": [
],
"modifiedBy": {
"uri": "itemOid\/com.ibm.team.repository.Contributor\/_hhbosPC1EeCsJbI2ZgPDog",
"itemId": "_hhbosPC1EeCsJbI2ZgPDog",
"com.ibm.team.repository.typeName": "com.ibm.team.repository.Contributor"
},
"xComponentLink": null,
"etag": "_R7C54SJeEeG25dOp_iUerQ"
}
Now I want to find the source code files as well as the changes. But how can I do it? When i try to send a HTTP Get to the uri in the list changes, then I get a Bad Request 400 error. What can I do?

The rest call you are calling is probably not API - use it at your own risks. Format will most likely change in future.
I assume you found about that rest call while using the Source Control Web UI. You can go to the history view, look at a change, go to an after or before state. This takes you to the state view. Right click on the download link. This is one way to get the URI needed to fetch the content associated to a particular state referenced in a change in a change set. This should get you on the way.

Related

Is there an easy way to flatten a json:api response on Android?

I'm trying to flatten the below response without having to parse it into a class. The reason for this is that the server could add or remove fields at anytime so it needs to be dynamic. We also have another service that returns lookup paths that we use to get data out of the flattened response - like "$.detail.att_one" There is a library for iOS that does the exact thing I'm looking for but as far as I can find nothing similar for Android: https://github.com/infinum/Japx
{
"data": [
{
"type": "items",
"id": "14",
"attributes": {
"item_type": "shape_circle",
"code": null,
"size": "70"
},
"relationships": {
"detail": {
"data": {
"type": "circle",
"id": "90"
}
},
"metadata": {
"data": "metadata"
}
},
"links": {
"self": "http://url/item/14"
}
}
],
"included": [
{
"type": "circle",
"id": "90",
"attributes": {
"att_one": 4,
"att_two": "11111111111",
"att_three": "Bob"
}
}
]}
The result I'm looking for:
{
"data": [
{
"id": "14",
"type": "items",
"item_type": "shape_circle",
"code": null,
"size": "70",
"metadata": {
"data": "metadata"
},
"detail": {
"type": "circle",
"id": "90",
"att_one": 4,
"att_two": "11111111111",
"att_three": "Bob"
},
"links": {
"self": "http://url/item/14"
}
}
]}
There is a nice JSONAPI library that does the thing, but you have to define resource classes for it.
Check out jasminb/jsonapi-converter
It recursively flattens all the included relationships and handles inheritance.

how to sort and limit embeded arrays using spring data mongorepository

I am trying to sort and limit embeded arrays using pagination, is that possible to acheive this using MongoRepository. Below is my json, and i am trying to get top ten notifications
{
"id":"5d357ce265cb136751177aas",
"notifications": [
{
"id": "5d357ce743cb133241177aaa",
"owner": null,
"itemId": "5d357ce743cb11254584abg",
"type": null,
"createdOn": "2019-07-22T03:41:05.428+00:00",
"read": false
},
{
"id": "5d357d2b43cb133241177aaf",
"owner": null,
"itemId": "5d35745243cb11256954abg",
"type": null,
"createdOn": "2019-07-22T03:41:14.367+00:00",
"read": false
}
]
}
i expect the output like this
"notifications": [
{
"id": "5d357d2b43cb133241177aaf",
"owner": null,
"itemId": "5d35745243cb11256954abg",
"type": null,
"createdOn": "2019-07-22T03:41:14.367+00:00",
"read": false
},
{
"id": "5d357ce743cb133241177aaa",
"owner": null,
"itemId": "5d357ce743cb11254584abg",
"type": null,
"createdOn": "2019-07-22T03:41:05.428+00:00",
"read": false
}
]
This may help:
db.collection.update( { <query selector> }, { <update operator>: {
"array.$.field" : value } } )

Resolved url not working while posting a share in linkedin page

I am trying to post a share with entity location and resolved Url in content entities, Even though i am pointing resolvedUrl to a image, it is not considering that image instead fetching 'og:image' from entity location. I don't see any use of resolvedUrl.
Suggest on how to use resolvedUrl ie. image with custom url.
Body:
{
"owner": "urn:li:organization:xxxxxxx",
"distribution": {
"linkedInDistributionTarget": {}
},
"content": {
"contentEntities": [{
"entityLocation": "https://www.cricbuzz.com/cricket-news/107673/ipl-2019-rishabh-pant-shikhar-dhawan-propel-delhi-capitals-to-the-top-rr-vs-dc-rajasthan-royals",
"thumbnail": [{
"resolvedUrl": "https://www.cricbuzz.com/a/img/v1/595x396/i1/c168531/watson-led-csks-chase-of-176.jpg"
}]
}],
"description": "Description of attachment",
"title": "Title of the attachment"
},
"text": {
"text": "Hii Kaushik from builder"
}
}
Hello I think it might be because of a typo: It should be "thumbnails" instead of "thumbnail", see if it works.
Link: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api#post-shares
{
"owner": "urn:li:organization:xxxxxxx",
"distribution": {
"linkedInDistributionTarget": {}
},
"content": {
"contentEntities": [{
"entityLocation": "https://www.cricbuzz.com/cricket-news/107673/ipl-2019-rishabh-pant-shikhar-dhawan-propel-delhi-capitals-to-the-top-rr-vs-dc-rajasthan-royals",
"thumbnails": [{
"resolvedUrl": "https://www.cricbuzz.com/a/img/v1/595x396/i1/c168531/watson-led-csks-chase-of-176.jpg"
}]
}],
"description": "Description of attachment",
"title": "Title of the attachment"
},
"text": {
"text": "Hii Kaushik from builder"
}
}
Hope this helps.

how to send HTTP Post request using jersey with a complex parameter

I need to send a HTTP Post to a REST API with the following complex type as parameters. I looked at the documentation of jersey and it helps only to send a key value pair. How can i send a HTTP Post request with the below parameters using jersey.
{
"key": "example key",
"message": {
"html": "<p>Example HTML content</p>",
"text": "Example text content",
"subject": "example subject",
"from_email": "message.from_email#example.com",
"from_name": "Example Name",
"to": [
{
"email": "recipient.email#example.com",
"name": "Recipient Name"
}
],
"headers": {
"Reply-To": "message.reply#example.com"
},
"important": false,
"track_opens": null,
"track_clicks": null,
"auto_text": null,
"auto_html": null,
"inline_css": null,
"url_strip_qs": null,
"preserve_recipients": null,
"view_content_link": null,
"bcc_address": "message.bcc_address#example.com",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"global_merge_vars": [
{
"name": "merge1",
"content": "merge1 content"
}
],
"merge_vars": [
{
"rcpt": "recipient.email#example.com",
"vars": [
{
"name": "merge2",
"content": "merge2 content"
}
]
}
],
"tags": [
"password-resets"
],
"subaccount": "customer-123",
"google_analytics_domains": [
"example.com"
],
"google_analytics_campaign": "message.from_email#example.com",
"metadata": {
"website": "www.example.com"
},
"recipient_metadata": [
{
"rcpt": "recipient.email#example.com",
"values": {
"user_id": 123456
}
}
],
"attachments": [
{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl"
}
],
"images": [
{
"type": "image/png",
"name": "IMAGECID",
"content": "ZXhhbXBsZSBmaWxl"
}
]
},
"async": false,
"ip_pool": "Main Pool",
"send_at": "example send_at"
}
I looked at the other questions of sending HTTP Post using Jersey and all I could find was a way to only send a key\value pairs as parameters and not complex string types like above.
You should look at JAXB, it allows you to "automatically" build "complex parameters" out of "objects". Basically the procedure would be to define a class that represents the data structure you present as request message the REST API resource accepts, then populate it with the data your want to POST and send it. In this question you can find more details on how to exactly do that: Can jersey clients POST a JAXB object to the server using JSON?

How to get the author name of the document which is uploaded in Box using Box API?

My task is to get the Document informations which are uploaded in Box for the particular user using Java. I am using Box API for java for achieve this task. I can able to connect with the user's Box profile and get the documents. But I am not able to get the author name of the document. That is the name of the user who upload the file.
Anybody know how to get that information?
I'm not 100% sure what SDK you're using, but the 'author' of the document is listed in the created_by attribute of the `files object e.g.
{
"type": "file",
"id": "5000948880",
"sequence_id": "3",
"etag": "3",
"sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
"name": "tigers.jpeg",
"description": "a picture of tigers",
"size": 629644,
"path_collection": {
"total_count": 2,
"entries": [
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
{
"type": "folder",
"id": "11446498",
"sequence_id": "1",
"etag": "1",
"name": "Pictures"
}
]
},
"created_at": "2012-12-12T10:55:30-08:00",
"modified_at": "2012-12-12T11:04:26-08:00",
"created_by": {
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean#box.com"
},
"modified_by": {
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean#box.com"
},
"owned_by": {
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean#box.com"
},
"shared_link": {
"url": "https://www.box.com/s/rh935iit6ewrmw0unyul",
"download_url": "https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg",
"vanity_url": null,
"is_password_enabled": false,
"unshared_at": null,
"download_count": 0,
"preview_count": 0,
"access": "open",
"permissions": {
"can_download": true,
"can_preview": true
}
},
"parent": {
"type": "folder",
"id": "11446498",
"sequence_id": "1",
"etag": "1",
"name": "Pictures"
},
"item_status": "active"
}

Categories

Resources