use of javax.transaction.Transactional in project ORCID-Source by ORCID.
the class AddressManagerImpl method deleteAddress.
@Override
@Transactional
public boolean deleteAddress(String orcid, Long putCode) {
AddressEntity entity = addressDao.getAddress(orcid, putCode);
orcidSecurityManager.checkSource(entity);
try {
addressDao.remove(entity);
} catch (Exception e) {
return false;
}
return true;
}
use of javax.transaction.Transactional in project zhcet-web by zhcet-amu.
the class EmailVerificationService method sendMail.
/**
* Sends mail to the user to be verified and saves the user with the email and status to be unverified
* Also, publishes an event notifying the same
* @param token {@link VerificationToken} token to be sent email with respect to
*/
@Transactional
public void sendMail(VerificationToken token) {
String relativeUrl = "/login/email/verify?auth=" + token.getToken();
log.debug("Verification link generated : {}", relativeUrl);
linkMailService.sendEmail(getPayLoad(token.getEmail(), token.getUser(), relativeUrl), false);
// Now we set the email to the user and disable email verified
User user = token.getUser();
log.debug("Saving user email {} -> {}", user.getUserId(), token.getEmail());
user.setEmail(token.getEmail());
user.setEmailVerified(false);
userService.save(user);
log.debug("Saved user email");
eventPublisher.publishEvent(new EmailVerifiedEvent(user));
}
use of javax.transaction.Transactional in project ORCID-Source by ORCID.
the class ManageMembersControllerTest method createMemberProfileWithInvalidEmailsTest.
@Test
@Transactional
public void createMemberProfileWithInvalidEmailsTest() throws Exception {
ProfileEntity profile = profileDao.find("5555-5555-5555-0000");
assertNotNull(profile);
assertNotNull(profile.getPrimaryEmail());
String existingEmail = profile.getPrimaryEmail().getId();
assertNotNull(existingEmail);
Member group = new Member();
group.setGroupName(Text.valueOf("Group Name"));
group.setType(Text.valueOf("basic"));
group.setSalesforceId(Text.valueOf(""));
// Validate already existing email address
group.setEmail(Text.valueOf(existingEmail));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.email.already_used", new ArrayList<String>()), group.getErrors().get(0));
// Validate empty email address
group.setEmail(Text.valueOf(""));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("NotBlank.group.email", new ArrayList<String>()), group.getErrors().get(0));
// Validate invalid email address
group.setEmail(Text.valueOf("invalidemail"));
group = manageMembers.createMember(group);
assertEquals(1, group.getErrors().size());
assertEquals(manageMembers.getMessage("group.email.invalid_email", new ArrayList<String>()), group.getErrors().get(0));
}
use of javax.transaction.Transactional in project ORCID-Source by ORCID.
the class AddressManagerImpl method deleteAddress.
@Override
@Transactional
public boolean deleteAddress(String orcid, Long putCode) {
AddressEntity entity = addressDao.getAddress(orcid, putCode);
orcidSecurityManager.checkSource(entity);
try {
addressDao.remove(entity);
} catch (Exception e) {
return false;
}
return true;
}
use of javax.transaction.Transactional in project ORCID-Source by ORCID.
the class ProfileKeywordManagerImpl method updateKeyword.
@Override
@Transactional
public Keyword updateKeyword(String orcid, Long putCode, Keyword keyword, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
ProfileKeywordEntity updatedEntity = profileKeywordDao.getProfileKeyword(orcid, putCode);
Visibility originalVisibility = Visibility.fromValue(updatedEntity.getVisibility().value());
// Save the original source
String existingSourceId = updatedEntity.getSourceId();
String existingClientSourceId = updatedEntity.getClientSourceId();
// Validate the keyword
PersonValidator.validateKeyword(keyword, sourceEntity, false, isApiRequest, originalVisibility);
// Validate it is not duplicated
List<ProfileKeywordEntity> existingKeywords = profileKeywordDao.getProfileKeywords(orcid, getLastModified(orcid));
for (ProfileKeywordEntity existing : existingKeywords) {
if (isDuplicated(existing, keyword, sourceEntity)) {
Map<String, String> params = new HashMap<String, String>();
params.put("type", "keyword");
params.put("value", keyword.getContent());
throw new OrcidDuplicatedElementException(params);
}
}
orcidSecurityManager.checkSource(updatedEntity);
adapter.toProfileKeywordEntity(keyword, updatedEntity);
updatedEntity.setLastModified(new Date());
// Be sure it doesn't overwrite the source
updatedEntity.setSourceId(existingSourceId);
updatedEntity.setClientSourceId(existingClientSourceId);
profileKeywordDao.merge(updatedEntity);
return adapter.toKeyword(updatedEntity);
}
Aggregations