use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method updateApplicationPolicy.
@Override
public void updateApplicationPolicy(ApplicationPolicy policy) throws APIManagementException {
try {
policyDAO.updateApplicationPolicy(policy);
PolicyValidationData policyValidationData = new PolicyValidationData(policy.getUuid(), policy.getPolicyName(), false);
apiGateway.updatePolicy(policyValidationData);
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't update Application policy for uuid: " + policy.getUuid();
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, e, e.getErrorHandler());
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method updateSubscriptionPolicy.
@Override
public void updateSubscriptionPolicy(SubscriptionPolicy policy) throws APIManagementException {
try {
policyDAO.updateSubscriptionPolicy(policy);
PolicyValidationData policyValidationData = new PolicyValidationData(policy.getUuid(), policy.getPolicyName(), policy.isStopOnQuotaReach());
apiGateway.updatePolicy(policyValidationData);
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't update Subscription policy for uuid: " + policy.getUuid();
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, e, e.getErrorHandler());
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method deletePolicyByUuid.
@Override
public void deletePolicyByUuid(String uuid, PolicyLevel policyLevel) throws APIManagementException {
try {
policyDAO.deletePolicyByUuid(policyLevel, uuid);
PolicyValidationData policyValidationData = new PolicyValidationData(uuid, "", false);
apiGateway.deletePolicy(policyValidationData);
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't delete policy with id: " + uuid + ", level: " + policyLevel;
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, e, e.getErrorHandler());
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method addSubscriptionPolicy.
@Override
public String addSubscriptionPolicy(SubscriptionPolicy policy) throws APIManagementException {
try {
String policyUuid = policy.getUuid();
if (policyUuid == null) {
if (log.isDebugEnabled()) {
log.debug("Policy id is null, hence generating a new UUID for the policy with name: " + policy.getPolicyName());
}
policyUuid = UUID.randomUUID().toString();
policy.setUuid(policyUuid);
}
policyDAO.addSubscriptionPolicy(policy);
PolicyValidationData policyValidationData = new PolicyValidationData(policyUuid, policy.getPolicyName(), policy.isStopOnQuotaReach());
apiGateway.addPolicy(policyValidationData);
return policyUuid;
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't add Subscription policy for uuid: " + policy.getUuid();
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, e, e.getErrorHandler());
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class BrokerUtil method publishToTopic.
/**
* Publish to broker topic
*
* @param topicName publishing topic name
* @param gatewayEvent topic message data object
*/
public static void publishToTopic(String topicName, GatewayEvent gatewayEvent) throws GatewayException {
TopicSession topicSession = null;
Topic topic = null;
TopicPublisher topicPublisher = null;
TopicConnection topicConnection = null;
try {
topicConnection = getTopicConnection();
topicConnection.start();
topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
topic = topicSession.createTopic(topicName);
topicPublisher = topicSession.createPublisher(topic);
TextMessage textMessage = topicSession.createTextMessage(new Gson().toJson(gatewayEvent));
topicPublisher.publish(textMessage);
} catch (JMSException e) {
String errorMessage = "Error occurred while publishing " + gatewayEvent.getEventType() + " event to JMS " + "topic :" + topicName;
log.error(errorMessage, e);
throw new GatewayException(errorMessage, ExceptionCodes.GATEWAY_EXCEPTION);
} catch (BrokerException e) {
String errorMessage = "Error occurred while obtaining broker topic connection for topic : " + topicName;
log.error(errorMessage, e);
throw new GatewayException(errorMessage, ExceptionCodes.GATEWAY_EXCEPTION);
} finally {
if (topicPublisher != null) {
try {
topicPublisher.close();
} catch (JMSException e) {
log.error("Error occurred while closing topic publisher for topic : " + topicName);
}
}
if (topicSession != null) {
try {
topicSession.close();
} catch (JMSException e) {
log.error("Error occurred while closing topic session for topic : " + topicName);
}
}
if (topicConnection != null) {
try {
topicConnection.close();
} catch (JMSException e) {
log.error("Error occurred while closing topic connection for topic : " + topicName);
}
}
}
}
Aggregations