public void cloneEndEntityProfile(final Admin admin, final String orgname, final String newname) throws EndEntityProfileExistsException {
if (newname.trim().equalsIgnoreCase(EMPTY_ENDENTITYPROFILENAME)) {
final String msg = INTRES.getLocalizedMessage("ra.errorcloneprofile", newname, orgname);
logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new Date(), null, null,
LogConstants.EVENT_ERROR_ENDENTITYPROFILE, msg);
throw new EndEntityProfileExistsException();
}
if (EndEntityProfileData.findByProfileName(entityManager, newname) == null) {
final EndEntityProfileData pdl = EndEntityProfileData.findByProfileName(entityManager, orgname);
boolean success = false;
if (pdl != null) {
try {
entityManager.persist(new EndEntityProfileData(Integer.valueOf(findFreeEndEntityProfileId()), newname, (EndEntityProfile) pdl.getProfile().clone()));
flushProfileCache();
final String msg = INTRES.getLocalizedMessage("ra.clonedprofile", newname, orgname);
logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new Date(), null, null,
LogConstants.EVENT_INFO_ENDENTITYPROFILE, msg);
success = true;
} catch (CloneNotSupportedException e) {
}
}
if (!success) {
final String msg = INTRES.getLocalizedMessage("ra.errorcloneprofile", newname, orgname);
logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new Date(), null, null,
LogConstants.EVENT_ERROR_ENDENTITYPROFILE, msg);
}
} else {
final String msg = INTRES.getLocalizedMessage("ra.errorcloneprofile", newname, orgname);
logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new Date(), null, null,
LogConstants.EVENT_ERROR_ENDENTITYPROFILE, msg);
throw new EndEntityProfileExistsException();
}
}