use of com.peterphi.std.guice.database.annotation.Transactional in project stdlib by petergeneric.
the class AzureInstanceActionDaemon method handle.
@Transactional
public void handle(final int id) {
ResourceInstanceEntity instance = dao.getById(id);
handle(instance);
dao.update(instance);
}
use of com.peterphi.std.guice.database.annotation.Transactional in project stdlib by petergeneric.
the class ServiceManagerResourceUIServiceImpl method getResource.
/**
* N.B. transaction may be read-write because this read operation may result in reading a new template (or discovering an
* update was made to the template)
*
* @param id
*
* @return
*/
@Override
@Transactional
public String getResource(String id) {
final TemplateCall call = templater.template("resource_template");
final ResourceTemplateEntity entity = resourceProvisionService.getOrCreateTemplate(id);
if (entity == null)
throw new RestException(404, "No such resource with id: " + id);
call.set("entity", entity);
call.set("nonce", nonceStore.getValue());
return call.process();
}
use of com.peterphi.std.guice.database.annotation.Transactional in project stdlib by petergeneric.
the class LetsEncryptCertificateDaoImpl method getEligibleForRenewal.
@Transactional(readOnly = true)
public List<String> getEligibleForRenewal(int renewDays) {
final Criteria criteria = createCriteria();
criteria.add(Restrictions.lt("expires", DateTime.now().plusDays(renewDays)));
criteria.addOrder(Order.asc("expires"));
return getIdList(criteria);
}
use of com.peterphi.std.guice.database.annotation.Transactional in project stdlib by petergeneric.
the class OAuthSessionDaoImpl method exchangeCodeForToken.
@Transactional
public OAuthSessionEntity exchangeCodeForToken(final OAuthServiceEntity service, final String authorisationCode) {
final OAuthSessionEntity session = uniqueResult(new WebQuery().eq("authorisationCode", authorisationCode).isNull("token").eq("alive", true).eq("context.service.id", service.getId()));
if (session == null)
return null;
session.setToken(SimpleId.alphanumeric("tok-", 36));
session.setAuthorisationCode(null);
update(session);
return session;
}
use of com.peterphi.std.guice.database.annotation.Transactional in project stdlib by petergeneric.
the class OAuthSessionDaoImpl method exchangeRefreshTokenForNewToken.
@Transactional
public OAuthSessionEntity exchangeRefreshTokenForNewToken(final OAuthServiceEntity service, final String refreshToken, final DateTime newExpires) {
final OAuthSessionEntity session = uniqueResult(new WebQuery().eq("id", refreshToken).isNotNull("token").eq("alive", true).eq("context.service.id", service.getId()));
if (session == null)
return null;
session.setToken(SimpleId.alphanumeric("tok-", 36));
session.setExpires(newExpires);
update(session);
return session;
}
Aggregations