Posts

Showing posts with the label organization

Getting the Organization name.

We know we can get the Organization details from the OrganizationLocalServiceUtil. Also we have another option to get those details. It is from the GroupLocalServiceUtil. As we know that whenever we create the Organization it will be created in the " Group " table only. Here I am getting the " Test Organization" Organization Getting the Organization name from the group String defaultOrganizationGroupName = "Test Organization"; defaultOrganizationGroupName +=GroupLocalServiceImpl.ORGANIZATION_NAME_SUFFIX; Group group = GroupLocalServiceUtil.getGroup(companyId,defaultOrganizationGroupName);

Adding Default Roles, sites and userGroup

If we want add the default "UserGroups" , "Groups" and "Roles" to the users, we can use the following methods to add. This will ensure, when user is creating it will assign these "UserGroups" , "Groups" and "Roles" to the users If we look into this " admin.default.role.names " in the portal.properties , it has User and PowerUser added, So whenever user is created, these 2 roles are assigned. Here for admin.default.user.group.names , we have added as CoffeGroup , so this group will be assigned automatically to the newly created user. Note: Whatever value we assign to the property , this should exists in the Portal. i.e  CoffeGroup (user group)should be exist in the portal, before creation of user. 1. UserGroup     #     # Input a list of default user group names separated by \n characters that     # are associated with newly created users.     #     admin.default.user.group.names=CoffeGroup UserLoca...

Adding address for Organization

Image
1.Adding Address List<ListType> addressTypes = ListTypeServiceUtil.getListTypes(Organization.class.getName()+ ListTypeConstants.ADDRESS); Here retrieving the all the address for the organization. Below screen is the available address for the organization. ( 1.Billing, 2.Other, 3.P.O.Box, 4.Shipping ) .Hence " addressTypes " contains all these address As an example we will add address as "Billing" type. so we will iterate all for the listtypes to get Billing type. for (ListType addressType : addressTypes) { String addressTypeName = addressType.getName(); if(addressTypeName.equalsIgnoreCase("Billing")) { personalAddressTypeId = addressType.getListTypeId(); } } Then adding the adddress AddressLocalServiceUtil.addAddress(userId, Organization.class.getName(), organization.getOrganizationId(), street1, street2, street3, city, zip,regionId, countryId, personalAddressTypeId, true, true); Here we need to add the country and region also,...

Checking weather the user has the role Organization Administrator.

Whenever we are creating the Organization we can assign the user to the Organization also we can assign the Organization role to the User. As of now we have 2 roles. 1.Organization Owner. 2. Organization Administrator. User who created the Organization will have the role "Organization Owner". But we need to manually assign the "Organization Administrator" to the user. In programmatically to check weather user has roles or not here is the code. ThemeDisplay  themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY); try {         Role role = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),RoleConstants.ORGANIZATION_ADMINISTRATOR);  //Get the Role List<UserGroupRole> userGroupList = UserGroupRoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId()); //Getting the Roles of the User for(UserGroupRole userGroupRole :userGroupList) { //Iterating the loop      if...