use of org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO in project entando-core by entando.
the class ConsumerAction method validate.
public void validate() {
super.validate();
try {
ConsumerRecordVO consumer = this.getOauthConsumerManager().getConsumerRecord(this.getConsumerKey());
if (this.getStrutsAction() == ApsAdminSystemConstants.ADD && null != consumer) {
String[] args = { this.getConsumerKey() };
this.addFieldError("consumerKey", this.getText("error.consumer.duplicated", args));
} else if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT && null == consumer) {
this.addActionError(this.getText("error.consumer.notExist"));
}
} catch (Throwable t) {
_logger.error("Error validating consumer", t);
this.addActionError(this.getText("error.consumer.systemError"));
}
}
use of org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO in project entando-core by entando.
the class ConsumerAction method save.
public String save() {
ConsumerRecordVO consumer = null;
try {
if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
consumer = new ConsumerRecordVO();
consumer.setKey(this.getConsumerKey());
} else if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
consumer = this.getOauthConsumerManager().getConsumerRecord(this.getConsumerKey());
}
consumer.setCallbackUrl(this.getCallbackUrl());
consumer.setDescription(this.getDescription());
consumer.setName(this.getName());
consumer.setExpirationDate(this.getExpirationDate());
consumer.setIssuedDate(Calendar.getInstance().getTime());
consumer.setScope(this.getScope());
consumer.setAuthorizedGrantTypes(this.getAuthorizedGrantTyped());
consumer.setSecret(this.getSecret());
if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
this.getOauthConsumerManager().addConsumer(consumer);
} else if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
this.getOauthConsumerManager().updateConsumer(consumer);
}
} catch (Throwable t) {
_logger.error("error in save", t);
return FAILURE;
}
return SUCCESS;
}
Aggregations