use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiI18nLabelInterface method getLabel.
public JAXBI18nLabel getLabel(Properties properties) throws ApiException, ApsSystemException {
JAXBI18nLabel jaxbI18nLabel = null;
try {
String key = properties.getProperty("key");
ApsProperties labelGroups = this.getI18nManager().getLabelGroup(key);
if (null == labelGroups) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label with key '" + key + "' does not exist", Response.Status.CONFLICT);
}
jaxbI18nLabel = new JAXBI18nLabel(key, labelGroups);
} catch (ApiException ae) {
throw ae;
} catch (ApsSystemException t) {
_logger.error("error loading labels", t);
throw new ApsSystemException("Error loading labels", t);
}
return jaxbI18nLabel;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiI18nLabelInterface method updateInlineLabel.
public void updateInlineLabel(JAXBI18nLabel jaxbI18nLabel) throws ApiException {
try {
this.checkLabels(jaxbI18nLabel);
String key = jaxbI18nLabel.getKey();
ApsProperties labelGroups = this.getI18nManager().getLabelGroup(key);
_logger.info("KEY -> {} ", key);
boolean isEdit = (null != labelGroups);
if (!isEdit) {
labelGroups = new ApsProperties();
} else {
//
}
ApsProperties labels = jaxbI18nLabel.extractLabels();
Iterator<Object> iterator = labels.keySet().iterator();
while (iterator.hasNext()) {
Object langKey = iterator.next();
labelGroups.put(langKey, labels.get(langKey));
}
if (isEdit) {
this.getI18nManager().updateLabelGroup(key, labelGroups);
_logger.info("*** EDIT DONE *** -> {}", labelGroups);
} else {
this.getI18nManager().addLabelGroup(key, labelGroups);
_logger.info("*** ADD DONE *** -> {}", labelGroups);
}
} catch (ApiException | ApsSystemException t) {
_logger.error("Error updating label {} ", t);
throw new ApiException("Error updating labels", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class LabelService method addLabelGroup.
@Override
public LabelDto addLabelGroup(LabelDto labelRequest) {
try {
BeanPropertyBindingResult validationResult = this.validateAddLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
String code = labelRequest.getKey();
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().addLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in add label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in add label group", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class LabelService method updateLabelGroup.
@Override
public LabelDto updateLabelGroup(LabelDto labelRequest) {
try {
String code = labelRequest.getKey();
ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
if (null == labelGroup) {
logger.warn("no label found with key {}", code);
throw new RestRourceNotFoundException(LabelValidator.ERRCODE_LABELGROUP_NOT_FOUND, "label", code);
}
BeanPropertyBindingResult validationResult = this.validateUpdateLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().updateLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in update label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in update label group", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class OAuth2TokenDAO method addAccessToken.
public synchronized void addAccessToken(final OAuth2Token accessToken, boolean isLocalUser) throws ApsSystemException {
Connection conn = null;
PreparedStatement stat = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
stat = isLocalUser ? conn.prepareStatement(INSERT_TOKEN_LOCAL_USER) : conn.prepareStatement(INSERT_TOKEN);
stat.setString(1, accessToken.getAccessToken());
stat.setString(2, accessToken.getClientId());
stat.setTimestamp(3, new Timestamp(accessToken.getExpiresIn().getTime()));
stat.setString(4, accessToken.getRefreshToken());
stat.setString(5, accessToken.getGrantType());
if (isLocalUser) {
stat.setString(6, accessToken.getLocalUser());
}
stat.executeUpdate();
conn.commit();
} catch (ApsSystemException | SQLException t) {
this.executeRollback(conn);
logger.error("Error while adding an access token", t);
throw new ApsSystemException("Error while adding an access token", t);
} finally {
closeDaoResources(null, stat, conn);
}
}
Aggregations