Add Team From startup event in liferay 6.2 ga4 - liferay

i'm currently developing hook for user registration (jsp , action ,startup action)
i wont at startup time (application.startup.events) to create 2 teams using this code
but isn't work
Team team=TeamLocalServiceUtil.createTeam(CounterLocalServiceUtil.increment());
team.setCompanyId(companyId);
team.setName("individual");
team.setDescription("individual individual");
TeamLocalServiceUtil.addTeam(team);
could any one help me
and I've inspected team table in database there are 2 fields (companyid and groupid ) i can't see what is difference between them they are facing me any where what their benefit and how i can find them

companyId is what the UI calls "instance". Most likely you have only one. The technical name groupId typically refers to the site that you create the team in.
I'd rather advise to create the team in a single call:
Team team = TeamLocalServiceUtil.addTeam(ownerId, groupId, name, description)
If this doesn't help, please update your question with more information than "doesn't work". You can be a lot more specific.

companyId is the liferay portal instance id. If you setup liferay to be multi-tenant, this id is used to separate data between the virtual portal.
groupId is organizational or site id.It's used if you want to separate your data between organization or sites.
try below code to add team :-
Team team=teamPersistence.create(CounterLocalServiceUtil.increment(Team.class.toString()));
team.setCompanyId(companyId);
team.setName("individual");
team.setDescription("individual individual");
teamPersistence.update(team);

Related

Can we create a work item on behalf of others in TFS 2018?

We have an automation in place to move information from BUG to a customized ticket template (Infra Requests.xml) in case of infrastructural issues. Currently an AD account is being used to create tickets. I want to use the CreatedBy field from Bug to create Infra Requests. I know we have way to check-in behalf and queued-build behalf, wondering if we have similar for create-workitem.
You can create a work item and update the CreatedBy field with the bypassRules option. The same question was here: How to change the Created By field on a Work Item in TFS?
Link to rest api: Work Items - Create

What company means in Liferay

There are organizations, users, roles and groups in Liferay. But there are many methods in liferay API that returns company or need company id as argument. E.g. UserLocalServiceUtil.getUserByEmailAddress(long companyId, String emailAddress) or com.liferay.portal.model.User getCompanyId().
For what purpose the company is provided in Liferay? Why I have to provide company id to find user by email address?
Documentation does not say too much.
In short - you can have more than one portal instance in the same server (in the same database) and you need "companyId" to avoid db data conflicts between those instances. A single instance itself is a full portal with users,groups,roles and everything else. Having "companyId" you can save, for example, two users with same emailAddress for different instances.

Team Foundation Service won't let me add members

I have successfully set up a Team Foundation Service account and have been using it with Visual Studio 2012 for source code control, no problems. Note this is the online service, not the old TFS product. I now want to add another Live ID account so they can write and track bugs. Using the Manage Members link I have tried two different Live ID accounts as well as their name but it always says they are not a known user. I know the Live ID accounts are correct. Do I have to invite them or add them some other way first? All of the examples show it "just working".
Are you adding them via the web interface? You should be able to do this by clicking the cog icon in the yourproject.visualstudio.com site. This launches the admin site, you can go into a collection, or add from the Security tab. It really depends on where you want to add them (if they only need access to specific projects/collections it's done at that level), you can add a new user from the Overview or Security tabs by entering their Live ID/email address.

Is it always necessary to have companyID and groupID in Liferay Service Builder?

I'm developing a liferay portlet. I use Service Builder. The question is that do I have to use companyID and groupID in my entity fields? What should I do if I don't want to have these fields? If I don't use them how can I use resourceLocalService.addResources() method?
They are not required but they are convenient to have.
Liferay has many additional services available to you to use like permissions, users, document library. These services are almost always scoped to a portal instance, for example, Users are scoped to an instance which is tracked by companyId. Some are scoped to a group like document library.
So depending on what Liferay services you are planning to use and at what scope those services operate, it is convenient to have those values stored as well for easy lookup when you're calling those services you are using.
Notice that the DBA team didn’t specify these two foreign key fields in the tables, but you add them anyway. You do this because the DBAs didn’t know the internal workings of Liferay when they designed the table.
These fields are internal to Liferay and are used for context purposes in non-instanceable portlets.
CompanyId corresponds to the portal instance to which the user has navigated, and groupId corresponds to the community or organization to which the user has navigated.
Because you’ll use these field values as parameters in all your queries, the portlet will have different data in different portals, communities, and organizations.

Konakart seamless login on Liferay

I am trying to make a seamless login to Konakart customer portlet on Liferay, where I have two separate Konakart instances installed (with different .war-files and different database. This means these two do not know about each other in any way).
What I know is that I could probably make a hook to catch Liferay login event. What after that? I should write a code to access Konakart, but how to do that?
Special point is that there are on same Liferay two Konakart instances and I don't know how to make it in code to add the user to one of them.
Problems with Multi-Store Multiple Databases
You say you have multiple KonaKart deployments and multiples databases.
From the KonaKart documentation:
"KonaKart provides multi-store functionality to enable you to run your stores from a single KonaKart deployment and a single database."
later on it also says:
"In Multi-Store Multiple Databases Mode there is no support for shared customers
so the users created are only authorized to log in to their own stores."
If you wanted your portal users to be able to access all your stores and the customer details kept in sync between the stores then it is not recommended to install multiple database installations. However, if you want different sets of users to see different stores then you should be okay.
Integrating Liferay with KonaKart portlet
Liferay implements PortletRequestImpl getRemoteUser() so the portal should pass a userid between the portal and the KonaKart portlet which would be accessible in the portlet using request.getRemoteUser().
According to this thread you should also be able to get other details (including user e-mail) from Liferay's UserServiceUtil from inside your portlet.
KonaKart uses Apache Portal's Struts Bridge and this means that there almost nothing in the way of portlet specific code in the Java part of the application (for the most part this will appear to be a typical Struts 1.2.7 app ). You should be able to use requests and sessions as you usually would and let the bridge worry about the details. That said, special care has to be taken to ensure the JSPs work in the portal container by making use of the Struts Bridge version of the Struts tags (which are portal aware). Using Struts bridge also means that the same application could be run "standalone" (i.e. can be accessed directly outside of the portal container).
It looks like the common identifier between Liferay and KonaKart is going to be the customer e-mail address.
Looking at the KonaKart source code most of the internal processing uses a customer id (an int) and the customer id is acquired through a login method which takes the customer email and a password as arguments. You could set the password for all users to be some secret value known only to the portlet although this would mean you would only be able to access KonaKart via the portal (as the customer wouldn't know their password for the standalone mode).
I've had a little look at the source code for KonaKart-5.5.0.2. It looks like most of the interesting code is in one of two places:
~konakart\custom\appn\src\com\konakart\actions
~konakart\java_api_examples\src\com\konakart\apiexamples
I think you are likely to need to customize the loggedIn method in BaseAction to get your Liferay user details from the request and use the e-mail address to acquire a customer id.
You may also want to be able to do a certain amount of customer registration programmatically. Some of details will need to be set by the customer - e.g. Liferay doesn't usually hold the address details of the portal users. Some of the best places to look are the classes suffixed with "SubmitAction" as these are Struts actions which usually occur after a form submission, some classes worth investigating include:
com.konakart.actions.BaseAction : specifically the method "loggedIn" which checks to see whether we are logged in (and returns the customer id).
com.konakart.actions.EditCustomerSubmitAction : gets called after submitting the edit customer page and shows how to edit customer information.
com.konakart.actions.CustomerRegistrationSubmitAction : gets called after submitting the customer registration page and shows how to register customer information.
com.konakart.actions.ChangePasswordSubmitAction
com.konakart.apiexamples.GetCustomer : get KonaKart customer details if you have their email address
com.konakart.apiexamples.RegisterCustomer : another example of customer registration
I hope this helps
We recently implemented this . You will need to modify the BaseAction java file. You can read details at http://www.surekhatech.com/blog/-/blogs/konakart-integration-with-liferay.
Gaurav Shah

Resources