Fórumok

Create a Community with the API

thumbnail
Christian Schulze, módosítva 12 év-val korábban

Create a Community with the API

Junior Member Bejegyzések: 87 Csatlakozás dátuma: 2009.11.19. Legújabb bejegyzések
I want to add a new Community with an UpgradeProcess inside a Hook.

I want to use this:


GroupLocalServiceUtil.addGroup(defaultUserId,
					Group.class.getName(), 1, "myCommunity",
					"myCummunity Desc",
					GroupConstants.TYPE_COMMUNITY_OPEN, "http://localhost:8080", true,
					serviceContext);


First question, what is arg2 classname and what mean classpk?
Second question, what is friendlyURL?

regards
Chris
Oliver Bayer, módosítva 12 év-val korábban

RE: Create a Community with the API

Liferay Master Bejegyzések: 894 Csatlakozás dátuma: 2009.02.18. Legújabb bejegyzések
Hi Chris,

classname is the name of the model while classpk is the same as the groupId (in case of a group model). The friendlyURL defines the part after /web or /group so if you name it "/my-community" (do not use http://localhost:8080) then you can access your created group with the following url:

public pages via http://localhost:8080/web/my-community
private pages vid http://localhost:8080/group/my-community

Take a look at "GroupLocalServiceImpl.addGroup(.....)" to see the implementation.

Greets Oli
thumbnail
Christian Schulze, módosítva 12 év-val korábban

RE: Create a Community with the API

Junior Member Bejegyzések: 87 Csatlakozás dátuma: 2009.11.19. Legújabb bejegyzések
ok, the following code works.

	
ServiceContext serviceContext = new ServiceContext();	
		String friendlyUrl = "/myCommunity";
		long classID = PortalUtil.getClassNameId(Group.class);		
		try {
			GroupLocalServiceUtil.addGroup(defaultUserId,
					Group.class.getName(), classID, "myCommunity",
					"myCommunity durch den Hook",
					GroupConstants.TYPE_COMMUNITY_OPEN, friendlyUrl, true,
					serviceContext);
		} catch (PortalException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SystemException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


But one question is remaining? How I get a correct classID, is this the right way with PortalUtil.getClassNameId(Group.class)?

regards
Chris
thumbnail
Sandeep Nair, módosítva 12 év-val korábban

RE: Create a Community with the API

Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
Yes thats correct or you can use the following

ClassNameLocalServiceUtil.getClassNameId(classObj)

PortalUtil.getClassNameId internally calls the above method

Regards,
Sandeep
Alagammai Kasi, módosítva 11 év-val korábban

RE: Create a Community with the API

Regular Member Bejegyzések: 149 Csatlakozás dátuma: 2012.08.01. Legújabb bejegyzések
Hi,

I know its an old thread, but I am looking for an API to create communities using it.

Would like to know on how to go about this?

Where do I run this code? at my database?

Please advice.

Thank You,
Alagu
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Create a Community with the API

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
Do you know the difference between community and group?
Alagammai Kasi, módosítva 11 év-val korábban

RE: Create a Community with the API

Regular Member Bejegyzések: 149 Csatlakozás dátuma: 2012.08.01. Legújabb bejegyzések
As far as I know a community is a group and a user is also a group.

Correct me if I am wrong.
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Create a Community with the API

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
As far as I know a community is a group


So, your question is answered in the earlier posts.
Alagammai Kasi, módosítva 11 év-val korábban

RE: Create a Community with the API

Regular Member Bejegyzések: 149 Csatlakozás dátuma: 2012.08.01. Legújabb bejegyzések
Dear Hitoshi,

Where should I be running that little script?

So far I have only worked with Liferay's drag and drop features.

Thanks in advance for your help.
Oliver Bayer, módosítva 11 év-val korábban

RE: Create a Community with the API

Liferay Master Bejegyzések: 894 Csatlakozás dátuma: 2009.02.18. Legújabb bejegyzések
Hi Alagammai,

you can put this code snippet into a custom portlet if you want to use it several times. If you only want to run it once you can use a workaround/ "hack" and add it to a jsp page, call the page and remove it afterwards. The much more cleaner solution would be to write a custom portlet e.g. by using the liferay sdk with the eclipse ide.

HTH Oli
Alagammai Kasi, módosítva 11 év-val korábban

RE: Create a Community with the API

Regular Member Bejegyzések: 149 Csatlakozás dátuma: 2012.08.01. Legújabb bejegyzések
Dear Oliver,

Thank you so much for your reply.

Any links that shows some examples on how to do scripting in Liferay?

Thank You so much!
Oliver Bayer, módosítva 11 év-val korábban

RE: Create a Community with the API

Liferay Master Bejegyzések: 894 Csatlakozás dátuma: 2009.02.18. Legújabb bejegyzések
Hi Algammai,

sorry for the late reply.
You can use the development wiki (wiki) as a starting point. Another good source is the "Liferay in Action" book.

Oli
Alagammai Kasi, módosítva 11 év-val korábban

RE: Create a Community with the API

Regular Member Bejegyzések: 149 Csatlakozás dátuma: 2012.08.01. Legújabb bejegyzések
Hi Oliver,

Thanks for your reply.

I will catch up with that.

Besides that, I just realised that I am not even able to create communities manually using Liferay, now.

I have opened another thread for this issue.

Please help....

Thank You,