Displaying jpegPhoto attribute from LDAP in Websphere Portal - ldap

I have a requirement wherein I need to display details of users after searching from LDAP using PUMA API.
I'm having troubling displaying the jpegPhoto of the user.
Here's what I'm doing:
First I'm querying the user by using:
PumaLocator.findUsersByAttribute(uid, user);
After that we get a User list Object.
For each user, we fetch all the attributes which is in the form of a Map.
I'm getting the following value for while retrieving the jpegPhoto:
map.get("jpegPhoto") --> [B#7a2f8a54
It seems that the Puma API returns a Binary string. Does anyone know how to display this in the portlet?
Any help would be greatly appreciated. Thank you

I think it more likely this is a byte[] array than a string.
You can probably base64 encode this binary into an encoded string and use it in an HTML image tag.
byte[] photoBytes = (byte[]) map.get("jpegPhoto");
String encodedPhoto = org.apache.commons.codec.binary.Base64.encodeBase64(photoBytes);
Then later, perhaps in a JSP (example assumes JSTL variable in scope named encodedPhoto):
<img src="data:image/jpeg;base64,${encodedPhoto}"/>

A way of doing this is to access the image through the portal service servlet instead of using your own servlet: /wps/um/secure/users/profiles/[oid]/jpegPhoto, in which you replace [oid] with the ObjectID of the user. This ID string can be obtained using IdentificationMgr.getIdentification().serialize(user.getObjectID())
The photo of the current user you can access using: /wps/um/secure/currentuser/profile/jpegPhoto

Portal is giving you data as byte array. It will never give you as URL.
You can write a servlet which will write this byte array to output stream.
Use that servlet URL as src of tag. It will start rendering on browser.
FYI, you can't print byte array to browser and expect it to treat as image.
Image or any other files has to come as a resource not as content.

Related

Is it possible to call a URL in a Splunk dashboard and get the response as a string?

I have a Splunk dashboard where you have a table with selected encoded identifiers.
You can click on a row and select an identifier as a token which fills additional fields with data. Now on the intranet of my company we have a url where you can enter the encoded identifier and get back the decoded data in a GET request.
Right now I have a single-value field which displays the encoded identifier and when you click on it it makes a call to the decoder and opens the decoded result in a new tab. That's a standard Splunk link.
Is it possible to make Splunk call the URL automatically (do a GET request) when the identifier is selected (the token is set) and retrieve the response data as a string and extract (using regex) and display the decoded data automatically in the single value field?
If not, is it at least possible for Splunk to get the response data as a string instead of opening the result in a new tab when you click on the encoded identifier?
If I understand you correctly, you want to have the drilldown target be an external link.
If that is correct, just put the external URL in the drilldown:
If you want some value from an external link to be pulled-into Splunk, then you'll need to setup another mechanism.
For example, you might have a scripted input that will query an external endpoint, and add results to an index or lookup table.
Or you might utilize a REST endpoint app to achieve something similar.

How to obtain the media-id from an instagram image url

I am trying to obtain the media id of an image so I can use this to gather insight information from a new API call: GET /{ig-media-id}/insights?metric={metric}
I have tried retrieving the media id using this request: http://api.instagram.com/oembed?callback=&url={image url} ... however, the media_id in the response is not valid for the insights API call.
Does anyone know how to get a valid media id or how to use the one returned in the above request?
<meta property="al:ios:url" content=
found in the meta property of the page view-source
adding to the earlier answer
inspect element >> search for "al:ios:url" >> it's in the string followed by content =
-> instagram://media?id=2905947356079086246

How to get all the data from a DICOM file with Imebra

I am working on a project that integrates Imebra inside an android application. The application is supposed to extract all the data from a given DICOM file and put them into a .xml file. I need a little bit of help with it. For example, I don't know how to get all the VR tags that the given DICOM has, instead of getting them one by one using tag ids.
Thank you for your help.
Load the file using CodecFactory.load(filename).
Then you can use DataSet.getTags() to retrieve a list of tags stored into the DICOM structure.
The returned class TagsIds is a list containing all the TagId: scan each tag ID and retrieve it via DataSet.getString() (to retrieve the value as string) and DataSet.getDataType() to retrieve its VR.
When DataSet.getString() fails then you are dealing with a sequence (an embedded DICOM structure) which can be retrieved with DataSet.getSequenceItem().
You can use the static method DicomDictionary.getTagName() to get a description of a particular tag.

Remove extra ASCII symbol rendering in PDF

I have a user that is storing a 'registered trademark' symbol in her name in our database and when we retrieve it when the database it renders correctly, but when we actually place it onto the website itself in HTML it renders with an extra 'A' symbol in front of it:
You can see above the database value compared to what is rendered in the PDF file. I can access the database value in the backend and edit it through vb code but I am really not sure how or what the code would be to do that as I don't want to remove all ASCII characters just the extra symbol being generated and rendered in the PDF.
Any idea how to do this would be great.
I think the Main-Problem is that you generate wrong HTML-Code by just inserting your Database-Result-Strings into your Website
You can encode your Database String to HTML by using the HtmlEncode-Function from HttpUtility in .NET
Here is an Example from vb.net
myEncodedString = HttpUtility.HtmlEncode(myString)
If you use "myEncodedString" inside your WebPage you'll get no additional Characters and a valid HTML-Code.

Trouble inserting fbml into database

Hi I am working with the facebook javascript sdk and I am having succcess using fbml to list the logged in users name like so...
<fb:name uid="loggedinuser" useyou="false"></fb:name>
What I would like to do next is assign this value to a php variable and insert it into my database. The problem I'm having is when I assign this value to a php variable like so...
$first_name = ('<fb:name uid="loggedinuser" useyou="false"></fb:name>');
What gets inserted into the data base is the literal expression of
<fb:name uid="loggedinuser" useyou="false"></fb:name>
instead of the users real name. Is there anyway to do this with the javascript sdk? Thanks!
You need to get the variable of
<fb:name uid="loggedinuser" useyou="false"></fb:name>
before assigning it to
$first_name
FBML data is generated on the fly, there isn't a way to transfer data over like this since FBML would load later after PHP code is completed. In addition
$first_name = ('<fb:name uid="loggedinuser" useyou="false"></fb:name>');
Would never evaluate to anything other than a string, this is just how PHP works. This one line of code cannot possibly determine the nature within based on a string.
The JavaScript SDK offers a way to do this already
FB.api('/me', function(response) {
alert('Your name is ' + response.name);
});
Though this in JavaScript so you need to send the data in a AJAX call to your PHP application. It would be much easier if you just retrieved the session information after JS SDK login and let the PHP SDK take care of the rest.