Liferay document library API - help required for a beginner - api

I am completely new to Liferay and unfortunately have limited knowledge of portlet, liferay APIs etc.
I have been asked to use liferay's document library API to add documents in one of our portlet.
We are using 5.2.3 version currently. I could find the javadocs which has methods like addFileEntry, addFile in classes such as DLFileEntryLocalServiceUtil, DLLocalServiceUtil etc, but having a very hard time to understand which method to use or which class to use.
Also, most of these APIs takes parameters such as userId, groupId, companyId etc etc. From where can I get that?
I know I am asking some very basic questions and should first try to understand the key concepts behind liferay, but unfortunately have been given very limited time :(. My bad luck.
It would be really helpful, if anyone can provide some sample code base with some explanation on it or guide me to any link.
Thanks,
Ashish

you can get userid,companyid,scope id from this method....
ThemeDisplay td = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
long userId = td.getUserId();
like wise you can get companyid,scopeid and all..
To add documents you can use...
DLFileEntry file=DLFileEntryLocalServiceUtil.addFileEntry(userId,
groupId,
folderId,
myfile.getName(),//name
myfile.getName(),//title
"",//description
"",//changelog
"",//extra seeting
myfile,
serviceContext);
Try this..

This approach suggested by Lucky Boy will not check permissions. If you want that the permissions will be checked use DLFileEntryServiceUtil instead of DLFileEntryLocalServiceUtil.
DLFileEntry file=DLFileEntryServiceUtil.addFileEntry(
folderId,
myfile.getName(),//name
myfile.getName(),//title
"",//description
"",//changelog
"",//extra seeting
myfile,
serviceContext);

Related

Multiple comment plugin loading on Blogger

on my blog I’m using from a long time the IntenseDebate pluging as commenting system in place of the default one.
I would replace it with Google+ comment system but I don’t want to lose all comments already left by the users via IntenseDebate, so I would figure out if there’s any way to load on the old posts the IntenseDebate pluging in place of the default Google+.
As possible solution, I’m thinking something like a tag in the html post code that (if defined) load the IntenseDebate pluging.
What do you think?
its not posible to migrate IntenseDebate comment on google plus. Their is one solution that you can use multiple comment system in your blogger blog. just few month ago i had written trick for the same. I hope that this will be useful to you.
http://www.tipsviablogging.com/multiple-comment-system-blogspot/

Umbraco: A/B testing, links in structure

I'm having a problem when trying to A/B test certain nodes in my node-tree in Umbraco.
What I want to do is to copy a node in the node-tree to a specific spot and use that B-structure to see which of the structures works best, using Google analytics.
For example we have two node structures, let's call them "Private" and "Sweden".
Their structure with childnodes and properties are exactly the same. The only difference between them is the propertyvalues (content). The "Private"-URL is www.mysite.com/Private and the "Sweden"-URL is www.mysite.com/Sweden.
What I would like to do is to change every link on the B-structure, so that it points to its match at the A-structure. The problem is that since it's two different structures, it will have two different alternative links.
With other words, it should be a coinsidence that it enters the B-structure, then be moved back to the A-structure in the next click.
We manage what page it should load (either the A-node or the B-node) with scripts, so that it has a 50% chance for each node, and if it lands on the B-node, Google analytics will save data. What we can't manage is that every link on that page will be to the A-node.
I'd appreciate any help I can get.
Regards,
David
There's a couple of ways that seem likely to give you a start at least.
The /config/urlrewriting.config file allows you to set up multiple redirect rules within umbraco so a section like the following might work in sending all requests (whether (/sweden/pagename/ or /private/pagename/) back to the private structure. Not sure how GA will handle it:
rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://www.mysite.com/private/$1" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
Secondly a simple httpmodule (http://support.microsoft.com/kb/307996) can process all page requests and redirect as required - you could do a gaq_push here directly or indirectly.
I'd be interested to know how you get on - it seems a good area for extension to Umbraco.
I'm not sure I have understood perfectly what you need to do, so please excuse any assumptions that may prove mistaken. Here's what I think:
Since A & B nodes should share the same html content (besides the links of course), why don't you make the link href attribute dynamic by using a bit of razor in the template or macro:
#{var isANode = CurrentPage.Parent.Name == "Sweden"; }
A similar approach would work if you are using web forms.
We finally came to the final decision to use the alternative template-solution. Since there seem to be no generic solution for my case of this problem we had to create an alternative template with specific macros to render the different information for every documenttype we're using.
Creating dynamic links for every page is a hell of a job in this stage in the project, since there are so many pages and links. Also some links are made in javascript, so there's another problem.
I copied the a-structure to another node, only for the reason to be able to change propertyvalues. There might be a problem logging and track the information with Google Analytics though, so that's the next step for us in this project. In our alternative templates we're getting the propertyvalues from the b-structure.
Still, if anyone have some better solution I'd highly appreciate it!
Regards,
David

Get FirstName, LastName and other from OpenId?

Here the relevant functions from the ASP.NET MVC template.
How do I get some additional attributes of the user such as FirstName etc? I don't mind using DotNetOpenAuth, if there is no other choice, I obviously prefer the in-box version.
I'm unsure what I have to change there to make it work, I don't want to mess it all up.
I think the answer is you can't. The ASP.MVC template makes login easy, but that's pretty much all it is. Just authentication. It provides little or no information about the user other than it's the same user that was here before.
If you want to get additional information for the user, I suggest you handle more of the login yourself. An example of how to do this is in the OpenIdRelyingParty MVC sample that you can download here.

VB .NET: Logged in user information

I'm writing software in VB .NET (2005) which uses the Windows user information as login credentials - just the username. I've found Environment.UserName which works for the username (as you would expect).
However, I need more information - I need the full name of the user (as shown on the Start Menu). It seems this information is stored... somewhere, as Windows is able to use it for things like permissions on file shares.
I've heard there's calls in user32.dll that can do this, but I'd like a .NET method if it's at all possible. I also have a SID for the user, if that helps at all.
Does anyone know the best way to get this additional information?
It seems the System.DirectoryServices namespace is exactly what I'm looking for.
Always seems that you find the answer right after you ask :)
For future reference:
Dim ent As New DirectoryServices.DirectoryEntry("WinNT://<Domain>/<Username>")
Dim props As DirectoryServices.PropertyCollection = ent.Properties
Debug.Print(props.Item("FullName").Value)

Lazy Registration on the Web: Best Practices

I first encountered the concept of lazy registration the Ajax Patterns site, where they define it as accumulating "bits of information about the user as they interact, with formal registration occurring later on." I'm looking at doing something similar for my website, but I'd like to know a little bit more about best practices before I start implementing it. My site is about web development, but general best practices are great too. How have you implemented lazy registration on your sites or projects? Where have you seen it in the wild? What do you like or dislike about it?
Have a look at this vid, a very good overview of the lazy registration pattern:
http://www.90percentofeverything.com/2009/03/16/signup-forms-must-die-heres-how-we-killed-ours/
I say this not as a person who has designed such a site before, but as a person that might visit that site. :)
With that said, the thing that I would be the most concerned about is knowing what kind of information is being collected about me. And I think that there should be an option to opt out of collecting the information and instead entering it all during formal registration.
But other than that, if it makes registering for a website easier, I'd be all for it. I leave 9 out of 10 sites that require me to register to do stuff.
One way that I was thinking about implementing this is when users leave blog comments. A common Wordpress format is to allow site visitors to comment as long as they leave a name and an email address. If I followed a similar pattern and then after they submit their comment, ask them if they would also like to register by having username and password inputs right there, with their email pre-filled in the email address input. There would also be a message saying that if they choose not to register at that time, their email address won't be saved (other than in association with the blog comment). If you think of something to add to this, leave a comment.
Use OpenID.
I hate it when I have to enter the same data over and over again, and to think of new passwords because you (read: the website) likely store them as plaintext.
Oh, and please don't require me to give you a fake email.
Like this way www.soup.io/signup or the email way www.posterous.com or www.tripit.com