use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class OAuth2TokenDAO method deleteAccessToken.
@Override
public void deleteAccessToken(final String accessToken) throws ApsSystemException {
Connection conn = null;
PreparedStatement stat = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
stat = conn.prepareStatement(DELETE_TOKEN);
stat.setString(1, accessToken);
stat.executeUpdate();
conn.commit();
} catch (ApsSystemException | SQLException t) {
this.executeRollback(conn);
logger.error(ERROR_REMOVE_ACCESS_TOKEN, t);
throw new ApsSystemException(ERROR_REMOVE_ACCESS_TOKEN, t);
} finally {
closeDaoResources(null, stat, conn);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class OAuth2TokenDAO method updateAccessToken.
public synchronized void updateAccessToken(final String accessToken, long seconds) throws ApsSystemException {
Connection conn = null;
PreparedStatement stat = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
stat = conn.prepareStatement(UPDATE_TOKEN);
Timestamp timestamp = new Timestamp(System.currentTimeMillis() + seconds * 1000);
stat.setTimestamp(1, timestamp);
stat.setString(2, accessToken);
stat.executeUpdate();
conn.commit();
} catch (ApsSystemException | SQLException t) {
this.executeRollback(conn);
logger.error("Error while update access token", t);
throw new ApsSystemException("Error while update access token", t);
} finally {
closeDaoResources(null, stat, conn);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class OAuth2TokenDAO method deleteExpiredToken.
@Override
public void deleteExpiredToken() throws ApsSystemException {
Connection conn = null;
PreparedStatement stat = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
stat = conn.prepareStatement(DELETE_EXPIRED_TOKENS);
stat.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
stat.executeUpdate();
conn.commit();
} catch (SQLException t) {
this.executeRollback(conn);
logger.error(ERROR_REMOVE_ACCESS_TOKEN, t);
throw new ApsSystemException(ERROR_REMOVE_ACCESS_TOKEN, t);
} finally {
closeDaoResources(null, stat, conn);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class OAuthConsumerDAO method deleteConsumer.
public void deleteConsumer(String clientId) {
Connection conn = null;
PreparedStatement stat = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
this.delete(clientId, DELETE_CONSUMER_TOKENS, conn);
this.delete(clientId, DELETE_CONSUMER, conn);
conn.commit();
} catch (SQLException | ApsSystemException t) {
this.executeRollback(conn);
_logger.error("Error while deleting consumer '{}' and its tokens", clientId, t);
throw new RuntimeException("Error while deleting a consumer and its tokens", t);
} finally {
closeDaoResources(null, stat, conn);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class PageService method movePage.
@Override
public PageDto movePage(String pageCode, PagePositionRequest pageRequest) {
IPage parent = this.getPageManager().getDraftPage(pageRequest.getParentCode()), page = this.getPageManager().getDraftPage(pageCode);
boolean moved = true;
int iterations = Math.abs(page.getPosition() - pageRequest.getPosition());
boolean moveUp = page.getPosition() > pageRequest.getPosition();
try {
if (page.getParentCode().equals(parent.getCode())) {
while (iterations-- > 0 && (moved = this.getPageManager().movePage(pageCode, moveUp))) ;
} else {
moved = this.getPageManager().movePage(page, parent);
}
page = this.getPageManager().getDraftPage(pageCode);
} catch (ApsSystemException e) {
logger.error("Error moving page {}", pageCode, e);
throw new RestServerError("error in moving page", e);
}
return this.getDtoBuilder().convert(page);
}
Aggregations