Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2005-2016 The Kuali Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ecl2.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kuali.rice.kim.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.kuali.rice.core.api.membership.MemberType;
import org.kuali.rice.kim.api.KimConstants;
import org.kuali.rice.kim.api.group.Group;
import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
import org.kuali.rice.kim.api.identity.email.EntityEmail;
import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
import org.kuali.rice.kim.api.identity.entity.Entity;
import org.kuali.rice.kim.api.identity.name.EntityName;
import org.kuali.rice.kim.api.identity.phone.EntityPhone;
import org.kuali.rice.kim.api.identity.principal.Principal;
import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
import org.kuali.rice.kim.api.role.Role;
import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation;
import org.kuali.rice.kim.bo.ui.PersonDocumentEmail;
import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo;
import org.kuali.rice.kim.bo.ui.PersonDocumentName;
import org.kuali.rice.kim.bo.ui.PersonDocumentPhone;
import org.kuali.rice.kim.document.IdentityManagementPersonDocument;
import org.kuali.rice.kim.impl.common.delegate.DelegateTypeBo;
import org.kuali.rice.kim.impl.group.GroupBo;
import org.kuali.rice.kim.impl.group.GroupMemberBo;
import org.kuali.rice.kim.impl.identity.entity.EntityBo;
import org.kuali.rice.kim.impl.identity.principal.PrincipalBo;
import org.kuali.rice.kim.impl.role.RoleBo;
import org.kuali.rice.kim.impl.role.RoleMemberAttributeDataBo;
import org.kuali.rice.kim.impl.role.RoleMemberBo;
import org.kuali.rice.kim.impl.role.RoleResponsibilityActionBo;
import org.kuali.rice.kim.impl.services.KimImplServiceLocator;
import org.kuali.rice.krad.document.Document;
import org.kuali.rice.krad.util.KRADUtils;
/**
* Customized version of the UiDocumentServiceImpl to support LDAP communcation
*
* @author Leo Przybylski ([email protected])
*/
public class LdapUiDocumentServiceImpl extends org.kuali.rice.kim.service.impl.UiDocumentServiceImpl {
/**
*
* @see org.kuali.rice.kim.service.UiDocumentService#loadEntityToPersonDoc(IdentityManagementPersonDocument, String)
*/
@Override
public void loadEntityToPersonDoc(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId) {
Principal principal = this.getIdentityService().getPrincipal(principalId);
if(principal==null) {
throw new RuntimeException("Principal does not exist for principal id:"+principalId);
}
identityManagementPersonDocument.setPrincipalId(principal.getPrincipalId());
identityManagementPersonDocument.setPrincipalName(principal.getPrincipalName());
//identityManagementPersonDocument.setPassword(principal.getPassword());
identityManagementPersonDocument.setActive(principal.isActive());
Entity kimEntity = this.getIdentityService().getEntity(principal.getEntityId());
identityManagementPersonDocument.setEntityId(kimEntity.getId());
if ( KRADUtils.isNotNull( kimEntity.getPrivacyPreferences() ) ) {
identityManagementPersonDocument.setPrivacy(loadPrivacyReferences(kimEntity.getPrivacyPreferences()));
}
//identityManagementPersonDocument.setActive(kimEntity.isActive());
identityManagementPersonDocument.setAffiliations(loadAffiliations(kimEntity.getAffiliations(),kimEntity.getEmploymentInformation()));
identityManagementPersonDocument.setNames(loadNames( identityManagementPersonDocument, principalId, kimEntity.getNames(), identityManagementPersonDocument.getPrivacy().isSuppressName() ));
EntityTypeContactInfo entityType = null;
for (EntityTypeContactInfo type : kimEntity.getEntityTypeContactInfos()) {
if (KimConstants.EntityTypes.PERSON.equals(type.getEntityTypeCode())) {
entityType = EntityTypeContactInfo.Builder.create(type).build();
}
}
if(entityType!=null){
identityManagementPersonDocument.setEmails(loadEmails(identityManagementPersonDocument, principalId, entityType.getEmailAddresses(), identityManagementPersonDocument.getPrivacy().isSuppressEmail()));
identityManagementPersonDocument.setPhones(loadPhones(identityManagementPersonDocument, principalId, entityType.getPhoneNumbers(), identityManagementPersonDocument.getPrivacy().isSuppressPhone()));
identityManagementPersonDocument.setAddrs(loadAddresses(identityManagementPersonDocument, principalId, entityType.getAddresses(), identityManagementPersonDocument.getPrivacy().isSuppressAddress()));
}
List groups = getGroupService().getGroups(getGroupService().getDirectGroupIdsByPrincipalId(
identityManagementPersonDocument.getPrincipalId()));
loadGroupToPersonDoc(identityManagementPersonDocument, groups);
loadRoleToPersonDoc(identityManagementPersonDocument);
loadDelegationsToPersonDoc(identityManagementPersonDocument);
}
protected String getInitiatorPrincipalId(Document document){
try{
return document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
} catch(Exception ex){
return null;
}
}
/**
* @see org.kuali.rice.kim.service.UiDocumentService#saveEntityPerson(IdentityManagementPersonDocument)
*/
@Override
public void saveEntityPerson(IdentityManagementPersonDocument identityManagementPersonDocument) {
boolean inactivatingPrincipal = false;
List groupPrincipals = populateGroupMembers(identityManagementPersonDocument);
List rolePrincipals = populateRoleMembers(identityManagementPersonDocument);
List personDelegations = populateDelegations(identityManagementPersonDocument);
List