Removing collaborations from a user's account - box-api

We have a use case where we would like to remove a user's account in our enterprise. As part of the removal process we want to uncolloborate all of the folders the user owns but is sharing with others. I"m able to remove the user successfully but am stuck trying to uncolloborate all of the folders before removing their account. I've tried the following code but it doesn't seem to work. This is the code I'm using
List<BoxCollaboration> collabs = client.getFoldersManager()
.getFolderCollaborations(entry.getId(),
new BoxDefaultRequestObject());
for (BoxCollaboration collab : collabs) {
BoxUser collaboratorid = (BoxUser) collab.getAccessibleBy();
BoxDefaultRequestObject requestObject = new BoxDefaultRequestObject();
requestObject.getRequestExtras().addHeader("As-User", userwhoisgettingremived.getId());
client.getCollaborationsManager().deleteCollaboration(collaboratorid , requestObject);
}
Anyone have a suggestion of what else I can try.
Thanks in advance
Bill.

You don't need to use "As-User" header as now you are not acting as this user. So the code can be:
for (BoxCollaboration collab : collabs) {
String collaboratorid = collab.getId();
client.getCollaborationsManager().deleteCollaboration(collaboratorid , null);
}

OK I fixed this by adding the id of the Collaboration instead of the id of the user associated with the collaboration. so the deleteCollaboration line of code needed to be changed to
client.getCollaborationsManager().deleteCollaboration(collab.getId() , requestObject);

Related

I am not able to redirect registered user to dashboard page with link

if (response.success) {
this.redirectURL = response.data.loginUrl;
// this.URL='http://'+location.host+'/login'+'/'+this.redirectURL;
this.router.navigate(['/login?token=', this.redirectURL]);}
Here is the code ,it should move me to cognito page but its moving to login page in angular I am not sure where I am wrong
use +(plus) instead of ,(comma)
this.router.navigate(['/login?token='+this.redirectURL]);}
If you want to use query params, you can also adopt this approach.
this.router.navigate(['login'], { queryParams: { token: 20 } });
Most likely the reason behind the issue you are facing is that the comma-separated navigation turns to slash-separated one, e.g.
let redirectURL = '1234'
this.router.navigate(['/login?token=', redirectURL])
// this line above results to /login?token=/1234'
So in order to avoid that you should either use the solution that I suggest or the one mentioned by abhishek sahu, where the usage of + for concatenation is encouraged.

OWA Signature Update with Exchange Web Services

We're using Exchange Web Services to set user signature in Outlook Web Access. It works great, we see the signature under Options>Settings and the "Automatically include my signature on messages I send" check box is checked. We also set this programmatically.
However, when the user creates a new e-mail message in OWA the signature does not show up. A work around for this is to go to Options>Setting, uncheck the "Automatically include my signature on messages I send" check box , Save, check the check box again and save.
The code we use to set the signature looks something like this:
Folder rootFolder;
UserConfiguration OWAConfig;
rootFolder = Folder.Bind(service, WellKnownFolderName.Root);
OWAConfig = UserConfiguration.Bind(service, "OWA.UserOptions",rootFolder.ParentFolderId, UserConfigurationProperties.All);
OWAConfig.Dictionary["signaturehtml"] = "Hello World";
OWAConfig.Dictionary["autoaddsignature"] = "True";
OWAConfig.Update();
Any idea how to get around this problem?
I have some old code that does the same thing which is working fine. I have pasted the code below. There are a few minor differences between my code and yours. I am not sure if they make a difference but you may want to try it out. Here is an extract of my code with the differences highlighted with a comment:
private void SetSettingValue(UserConfiguration owaConfig, string propName, object propValue)
{
if (owaConfig.Dictionary.ContainsKey(propName))
{
owaConfig.Dictionary[propName] = propValue;
}
else
{
// Adds a key if it does not explicitly exist.
// I am not sure if it makes a difference.
owaConfig.Dictionary.Add(propName, propValue);
}
}
public void AddSignature()
{
// Extract
UserConfiguration OWAConfig = UserConfiguration.Bind(
service,
"OWA.UserOptions",
WellKnownFolderName.Root, // Binding to Root and not Root.ParentFolderId.
UserConfigurationProperties.Dictionary // Binds to Dictionary and not to All.
);
SetSettingValue(OWAConfig, "autoaddsignature", true);
SetSettingValue(OWAConfig, "signaturehtml", html);
OWAConfig.Update();
}

programatically creating a folder in ssrs using SOAP

I am using the SSRS 2008r API to create and manage SSRS from a webform application. When creating a folder I see where I can add a folder name as well as specify additional meta data (custom properties) that can be a part of the folder. My question is how do I populate additional fields in the catalog database via the api. When I look at the CreateFolder method the only properties I can add at the insert are folder name, path, and custom properties:
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form
However I would also like to set at this time the description, and hidden value.
I'd appreciate any suggestions on how this is accomplished. Every example I have seen within MSDN only shows setting the folder name, path, and custom properties.
thanks in advance
Set the item properties (Description and Hidden) by initializing a Property class for each. Never done it before, but I'm guessing it would look something like this (assuming C#):
...
// description property
Property description = new Property();
description.Name = "Description";
description.Value = "Your description here.";
// hidden property
Property hidden = new Property();
hidden.Name = "Hidden";
hidden.Value = "True"; // not sure on value here, may be True/False, Yes/No
// build properties array
props[0] = description;
props[1] = hidden;
// create folder
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form

Spotify List objects created from localStorage data come up blank

I'm working on a Spotify app and trying to create a views.List object from some stored information in our database. On initial load, a POST is made to get the necessary info. I store this in localstorage so each subsequent request can avoid hitting the database and retrieve the object locally. What's happening though is the List objects I create from localstorage data come up blank, while the POST requests work just fine.
Here is the snippet I'm using to create the list:
var temp_playlist = models.Playlist.fromURI(playlist.uri);
var tempList = new views.List(temp_playlist, function (track) {
return new views.Track(track, views.Track.FIELD.STAR |
views.Track.FIELD.NAME |
views.Track.FIELD.ARTIST |
views.Track.FIELD.DURATION);
});
document.getElementById("tracklist").appendChild(tempList.node);
playlist.uri in the first line is what I'm retrieving either from a POST or from localstorage. The resulting views.List object (tempList) looks identical in both cases except for tempList.node. The one retrieved from localstorage shows these values for innerHTML, innerText, outerHTML, and outerText in console.log:
innerHTML: "<div style="height: 400px; "></div>"
innerText: ""
outerHTML: "<div style="height: 400px; "></div>"
outerText: ""
Whereas the one retrieved via POST has the full data:
innerHTML: "<div style="height: 400px; "><a href="spotify:track:07CnMloaACYeFpwgZ9ihfg" class="sp-item sp-track sp-track-availability-0" title="Boss On The Boat by Tosca" data-itemindex="0" data-viewindex="0" style="-webkit-transform: translateY(0px); ">....
innerText: "3Boss On The BoatTosca6:082....
and so forth..
Any help would be greatly appreciated
Solved this.
I am using hide() and show() to render the tabs in my app. I was constructing the tracklist and then show()ing the div which led to a blank tracklist. If I simply show() the div and then construct the tracklist it works fine.
The reason (I think) it was working for POSTs is because the tracklist was retrieved from the database and the slightly longer loading time probably meant the tracklist was constructed after the div's show() executed. With localStorage I guess the tracklist was constructed before the div was even shown, leading to the error.
Using, the local storage, I did it this way :
sp = getSpotifyApi(1);
var m = sp.require("sp://import/scripts/api/models");
var v = sp.require("sp://import/scripts/api/views");
var pl;
pl = m.Playlist.fromURI(uri);
var player = new v.Player();
player.track = pl.get(0);
player.context = pl;
var list = new v.List(pl);
XXXXX.append($(list.node));
Hope, it will help, as it's working for me
I think I've actually managed to solve this and I think it's bulletproof.
Basically I was trying to solve this by trying to convince the API that it needed to redraw the playlist by hiding things/scrolling things/moving things which worked occasionally but never consistently. It never occurred to me to change the playlist itself. Or at least make the API think the playlist has changed.
You can do so by firing an event on the Playlist object.
var models = sp.require('$api/models');
...
// playlist is your Playlist object. Usually retrieved from models.Playlist.fromURI
playlist.notify(models.EVENT.CHANGE, playlist);
These are just standard Spotify functions and the list updates because it thinks something has changed in the playlist. Hope this helps someone!

Adding Contacts Android 2.3 rawContactId

I'm new to java and developing apps, I can't figure out how to add a contact. I'm taking right from the android development website:
ContentValues values = new ContentValues();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER, "1-800-GOOG-411");
values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
values.put(Phone.LABEL, "free directory assistance");
Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
My question is: what do you put in the place of rawContactId? Is it supposed to be the name of the contact? I want to move on to the newer way to add contacts below, but I can't even get the "traditional" way to work. Help?
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
.withValue(Data.RAW_CONTACT_ID, rawContactId)
.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
.withValue(Phone.NUMBER, "1-800-GOOG-411")
.withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
.withValue(Phone.LABEL, "free directory assistance")
.build());
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);