its working fine for me
private Organization CreateRegularOrg(String name, long companyId,ActionRequest actionRequest) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
serviceContext.setCompanyId(companyId);
Organization org = null;
try {
List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest);
List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(
actionRequest);
List<OrgLabor> orgLabors = UsersAdminUtil.getOrgLabors(actionRequest);
List<Phone> phones = UsersAdminUtil.getPhones(actionRequest);
List<Website> websites = UsersAdminUtil.getWebsites(actionRequest);
org = OrganizationServiceUtil.addOrganization(
0, tenantName, "regular-organization", 19014, 19, 12017,
StringPool.BLANK, true, addresses, emailAddresses, orgLabors, phones,
websites, serviceContext);
System.out.println("org=======11111111============"+org);
/*org = OrganizationServiceUtil.addOrganization(0, tenantName,"regular-organization", true, 19014, 19, 12017,StringPool.BLANK, true, serviceContext);*/
org.setCompanyId(companyId);
org = OrganizationLocalServiceUtil.updateOrganization(org);
//Group group = GroupLocalServiceUtil.getCompanyGroup(themeDisplay.getCompanyId());
Group group = GroupLocalServiceUtil.getOrganizationGroup(themeDisplay.getCompanyId(), org.getOrganizationId());
System.out.println("Company ID from Theme Display -> "+themeDisplay.getCompanyId());
System.out.println("Company ID from Group -> "+group.getCompanyId());
System.out.println("Org ID from Group -> "+group.getOrganizationId());
group.setCompanyId(companyId);
GroupLocalServiceUtil.updateGroup(group);
System.out.println("org===========22222222222========"+org);
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
return org;
}
private Organization CreateRegularOrg(String name, long companyId,ActionRequest actionRequest) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
serviceContext.setCompanyId(companyId);
Organization org = null;
try {
List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest);
List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(
actionRequest);
List<OrgLabor> orgLabors = UsersAdminUtil.getOrgLabors(actionRequest);
List<Phone> phones = UsersAdminUtil.getPhones(actionRequest);
List<Website> websites = UsersAdminUtil.getWebsites(actionRequest);
org = OrganizationServiceUtil.addOrganization(
0, tenantName, "regular-organization", 19014, 19, 12017,
StringPool.BLANK, true, addresses, emailAddresses, orgLabors, phones,
websites, serviceContext);
System.out.println("org=======11111111============"+org);
/*org = OrganizationServiceUtil.addOrganization(0, tenantName,"regular-organization", true, 19014, 19, 12017,StringPool.BLANK, true, serviceContext);*/
org.setCompanyId(companyId);
org = OrganizationLocalServiceUtil.updateOrganization(org);
//Group group = GroupLocalServiceUtil.getCompanyGroup(themeDisplay.getCompanyId());
Group group = GroupLocalServiceUtil.getOrganizationGroup(themeDisplay.getCompanyId(), org.getOrganizationId());
System.out.println("Company ID from Theme Display -> "+themeDisplay.getCompanyId());
System.out.println("Company ID from Group -> "+group.getCompanyId());
System.out.println("Org ID from Group -> "+group.getOrganizationId());
group.setCompanyId(companyId);
GroupLocalServiceUtil.updateGroup(group);
System.out.println("org===========22222222222========"+org);
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
return org;
}
No comments:
Post a Comment