Impersonate in Tridion 2011 without using core service - tridion

I'm trying to impersonate a user in a C# TBB. is it possible to know who initiated the publish action of a component in the TBB which is a part of the component template rendering with the component?

As mentioned in below article
http://yatb.mitza.net/2012/05/publishing-from-template-code-using.html
Once you will get the Current Publish transaction you can use the properties .Creator to get the user.
To get the Current Publish Transaction you can refer
http://yatb.mitza.net/2012/05/publishing-from-template-code-using.html

In your TBB you have access to the engine.GetSession(), which returns a Session object, containing the User information, I'm sure via that you can do in your code, what you are trying to achieve.
It would be interesting to know a little more about what you are trying to archive.

Related

Get property of object Alfresco

I'm using Alfresco 5.1 Community, and i'm trying to get a property of an object for example, in the user we have:
"{http://www.alfresco.org/model/content/1.0}companytelephone"
If I want to get the value of this property, how can I obtain this in javascript?
It depends where you're trying to do this, if you're doing this in a JavaScript controller for a WebScript on the Repository then you will be able to find most of the information in this Wiki page: https://wiki.alfresco.com/wiki/JavaScript_API_Cookbook
If you're doing it in the JavaScript controller of a WebScript running on Share then for most objects you'll need to request the full metadata for the node by calling a REST API on the Repository.
In the case of the user, there is a "user" object available in WebScripts running on the Share tier.
There is lots of information on getting this kind of data with some basic Googling, I'd also recommend launching the Rhino debugger via the WebScripts index page so you can try evaluating JavaScript code (this works for both the Repository and for Share).

Tridion 2011 SP1 HR1 - which extension to use?

We have a requirement that on a page publish, we need to:
Find a component presentation that has a component based upon a particular schema.
Extract certain field vales from that component and store them in a custom database table that's available to our .NET application (on the Content Delivery side).
I think this is a good candidate for either a Deployer extension or a Storage extension - but I'm a little unclear which and why having never written either?
I've ruled out the Event System as this kind of code would be located on the CM, which seems like the wrong "side" to me - my focus is on extending what happens on the CD-side after a page is published.
Read a few articles on Tridion World (this, this, this and this) and I think a storage extension would be the better choice?
Mihai's article seems to be very close to what we need, where he uses a new item type mapping:
<ItemTypes defaultStorageId="brokerdb" cached="true">
<Item typeMapping="PublishAction" cached="false" storageId="searchdb" /></ItemTypes>
But how does Tridion "know" to use this new item type when content is published, (its not one of the defined TYPE_NAMEs, which is kind of the point)?
I should clarify I'm a .NET/C# dev not a Java dev so this is probably really obvious to Java people - apologies if it is!
Cheers
Tridion will not know by default how to deploy your new entity. My advise is to create a Deployer Module (your links should give you enough information about how you can do that) that executes in post-processing phase (of the deployment process), that processes all components from the deployment/transport package, extracts the needed information and uses a custom Storage Extension to store the needed information.
Be careful: you need to set-up in config your new type but you also need to use it yourself from that Deployer Module.
Hope this helps.

GetItemByWebDavUrl in anguilla

I'm writing an SDL Tridion Anguilla extension and need to pull a config component using a webdav url. The config also has a set of webdav urls and I need to fetch item Objects for these.
Frank - May be I ate a few words in my question.. I'm writing a CMS GUI extension and writing javascript. So is there something like $models.getItem(); which gives me the component or xml of the component?
In most Tridion Content Manager APIs you can read an item by either its TCM URI or its WebDAV URL.
So if you're using the Core Service, you can simply do:
var item = client.Read(webdavURL, null);
Then you can iterate over the fields (if you're using the Core Service this Fields helper class will come in handy) and do the same for each value in there.
If you need to have the mapping available to the client, you'll need to create a custom web service to make it available. Although not trivial at first, creating a WCF service is not as daunting as some people make it out to be. Especially not when you start with this example of a minimal WCF service for Tridion.
There is no functionality on the client to resolve items by WebDAVUrl. The only functionality we have is:
var item = $models.getItem(tcmUri);
item.getWebDavUrl(); // will return you WebDAVUrl, if it was loaded before
item.loadWebDavUrl(); // will make async call to load WebDAVUrl. "loadwebdavurl" or "loadwebdavurlfailed" will be fired on the item afterwards

Tridion 2011 - Publish Unpublish while writing custom resolver

Needed to understand your inputs on: Is there a way in Tridion 2011 to Publish or Unpublish components/pages/templates in a custom resolver code. I understand we can play with the list of resolved items. (By giving a CP,etc). But is there a way to push an item in the publishing Q from a custom resolver code.
You can add or remove any number of items to be part of the existing package / transaction.
If you want it to be part of a new entry in the Publishing Queue instead, the event system seems more appropriate than a resolver. But the items you are publishing automatically won't show up in the "Items to Publish" screen if you Publish them separately, so you need to decide if that's a good thing or not.
Peter (and Nuno) have really answered your question in the best way. You should use a resolver to add the Pages or Component Presentations to the package rather than making new publish transactions. However you can publish items using the core service, so there is no reason you could not call the core service from a resolver and initiate your new publish actions that way.
However it does not sound like a good idea, perhaps you can update you question to explain why you need to do this.
I used to use the PublishEngine object in my templates to add items to the Publish Queue (see http://www.tridiondeveloper.com/the-story-of-sdl-tridion-2011-custom-resolver-and-the-allowwriteoperationsintemplates-attribute), but custom resolvers and other techniques are far superior.

Event handler for Tridion workflow automatic decision

Having trouble with automatic decisions in Tridion 2011 SP1.
I have an auto-decision item that go down one of two paths (one to a manual decision and the other to a manual activity). Screenshot attached.
What I need to do is analyse the permissions of the user that submits the first step in the workflow and automatically move the workflow down the correct path.
I am using an event handler for the AutomaticAssignActivity (tested successfully with event log writes) and have found in the API how to finish the activity but there's not overload for assigning the next activity.
I found this post an interesting read and tried to implement the CoreServiceSession and SessionAwareCoreServiceClient but each time the code tries to load the core service I receive the following error: Could not load file or assembly 'Tridion.ContentManager.CoreService.Client, Version=6.1.0.996, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b' or one of its dependencies. The system cannot find the file specified.
I am using the core service in my web layer for some minor content generation but it doesn't want to work from within the events system. What am I doing wrong? My events system DLL is in the Tridion bin folder where Tridion.ContentManager.CoreService.Client.dll sits.
Any help appreciated :)
Note that if you are developing an Event handler, you should better use the TOM.NET API (it is the preferred API for Event System and templating developments)
For all the rest, use Core Service
If you want to use core service, you can create a .NET DLL and then call it from your automated activity. This thread has some good information about it:
Which API can I use for writing SDL Tridion workflow activities?

Resources