Java Code Examples for org.wso2.carbon.apimgt.api.APIManagementException#getMessage()

The following examples show how to use org.wso2.carbon.apimgt.api.APIManagementException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIStateChangeApprovalWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Handle cleanup task for api state change workflow Approval executor.
 * Use workflow external reference  to delete the pending workflow request
 *
 * @param workflowExtRef External Workflow Reference of pending workflow process
 */
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {

    if (log.isDebugEnabled()) {
        log.debug("Starting cleanup task for APIStateChangeWSWorkflowExecutor for :" + workflowExtRef);
    }
    String errorMsg;
    super.cleanUpPendingTask(workflowExtRef);
    try {
        ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
        apiMgtDAO.deleteWorkflowRequest(workflowExtRef);
    } catch (APIManagementException axisFault) {
        errorMsg = "Error sending out cancel pending application approval process message. cause: " + axisFault
                .getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    }
}
 
Example 2
Source File: ApplicationRegistrationApprovalWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Handle cleanup task for application registration Approval workflow executor.
 * Use workflow external reference  to delete the pending workflow request
 *
 * @param workflowExtRef Workflow external reference of pending workflow request
 */
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {
    super.cleanUpPendingTask(workflowExtRef);
    String errorMsg = null;
    if (log.isDebugEnabled()) {
        log.debug("Starting cleanup task for ApplicationRegistrationApprovalWorkflowExecutor for :" + workflowExtRef);
    }
    try {
        ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
        apiMgtDAO.deleteWorkflowRequest(workflowExtRef);
    } catch (APIManagementException axisFault) {
        errorMsg = "Error sending out cancel pending registration approval process message. Cause: " + axisFault
                .getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    }
}
 
Example 3
Source File: ApplicationDeletionSimpleWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Override
public WorkflowResponse complete(WorkflowDTO workflowDTO) throws WorkflowException {
    ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
    ApplicationWorkflowDTO applicationWorkflowDTO = (ApplicationWorkflowDTO) workflowDTO;
    Application application = applicationWorkflowDTO.getApplication();
    String errorMsg = null;

    try {
        apiMgtDAO.deleteApplication(application);
    } catch (APIManagementException e) {
        if (e.getMessage() == null) {
            errorMsg = "Couldn't complete simple application deletion workflow for application: " + application
                    .getName();
        } else {
            errorMsg = e.getMessage();
        }
        throw new WorkflowException(errorMsg, e);
    }

    return new GeneralWorkflowResponse();
}
 
Example 4
Source File: UserSignUpApprovalWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Handle cleanup task for user self sign up Approval workflow executor.
 * Use workflow external reference  to delete the pending workflow request
 *
 * @param workflowExtRef Workflow external reference of pending workflow request
 */
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {
    String errorMsg = null;
    super.cleanUpPendingTask(workflowExtRef);
    if (log.isDebugEnabled()) {
        log.debug("Starting cleanup task for UserSignUpApprovalWorkflowExecutor for :" + workflowExtRef);
    }
    try {
        ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
        apiMgtDAO.deleteWorkflowRequest(workflowExtRef);
    } catch (APIManagementException axisFault) {
        errorMsg = "Error sending out cancel pending UserSelfSignUp approval process message. cause: " + axisFault
                .getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    }
}
 
Example 5
Source File: ApplicationCreationApprovalWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Handle cleanup task for application creation Approval workflow executor.
 * Use workflow external reference  to delete the pending workflow request
 *
 * @param workflowExtRef Workflow external reference of pending workflow request
 */
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {

    String errorMsg;
    if (log.isDebugEnabled()) {
        log.debug("Starting cleanup task for ApplicationCreationApprovalWorkflowExecutor for :" + workflowExtRef);
    }
    super.cleanUpPendingTask(workflowExtRef);
    try {
        ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
        apiMgtDAO.deleteWorkflowRequest(workflowExtRef);
    } catch (APIManagementException axisFault) {
        errorMsg = "Error sending out cancel pending application approval process message. cause: " + axisFault
                .getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    }
}
 
Example 6
Source File: ApplicationRegistrationSimpleWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Complete the external process status
 * Based on the workflow status we will update the status column of the
 * Application table
 * 
 * @param workFlowDTO - WorkflowDTO
 */
public WorkflowResponse complete(WorkflowDTO workFlowDTO) throws WorkflowException {
	if (log.isDebugEnabled()) {
		log.info("Complete  Application Registration Workflow..");
	}

       ApplicationRegistrationWorkflowDTO regWFDTO = (ApplicationRegistrationWorkflowDTO) workFlowDTO;
	

	ApiMgtDAO dao = ApiMgtDAO.getInstance();

	try {
           dao.createApplicationRegistrationEntry((ApplicationRegistrationWorkflowDTO)workFlowDTO,false);
           generateKeysForApplication(regWFDTO);
	} catch (APIManagementException e) {
		String msg = "Error occurred when updating the status of the Application creation process";
		log.error(msg, e);
		throw new WorkflowException(e.getMessage(), e);
	}
	return new GeneralWorkflowResponse();
}
 
Example 7
Source File: SubscriptionCreationApprovalWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Handle cleanup task for subscription creation Approval workflow executor.
 * Use workflow external reference  to delete the pending workflow request
 *
 * @param workflowExtRef Workflow external reference of pending workflow request
 */
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {
    String errorMsg = null;
    super.cleanUpPendingTask(workflowExtRef);
    if (log.isDebugEnabled()) {
        log.debug("Starting cleanup task for SubscriptionCreationApprovalWorkflowExecutor for :" + workflowExtRef);
    }
    try {
        ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
        apiMgtDAO.deleteWorkflowRequest(workflowExtRef);
    } catch (APIManagementException axisFault) {
        errorMsg = "Error sending out cancel pending subscription approval process message. cause: " + axisFault
                .getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    }
}
 
Example 8
Source File: APIGatewayAdmin.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * encrypt the plain text password
 *
 * @param plainTextPass plain text password
 * @return encrypted password
 * @throws APIManagementException
 */
public String doEncryption(String tenantDomain, String secureVaultAlias, String plainTextPass) throws AxisFault {

    MediationSecurityAdminServiceProxy client = getMediationSecurityAdminServiceProxy(tenantDomain);
    String encodedValue;
    try {
        encodedValue = client.doEncryption(plainTextPass);
        setRegistryProperty(tenantDomain, secureVaultAlias, encodedValue);
    } catch (APIManagementException e) {
        String msg = "Failed to encrypt and store the secured endpoint password, " + e.getMessage();
        throw new AxisFault(msg, e);
    }
    return encodedValue;
}
 
Example 9
Source File: MutualSSLAuthenticator.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public AuthenticationResponse authenticate(MessageContext messageContext) {
    org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) messageContext)
            .getAxis2MessageContext();
    // try to retrieve the certificate
    X509Certificate sslCertObject;
    try {
        sslCertObject = Utils.getClientCertificate(axis2MessageContext);
    } catch (APIManagementException e) {
        return new AuthenticationResponse(false, isMandatory, !isMandatory,
                APISecurityConstants.API_AUTH_GENERAL_ERROR, e.getMessage());
    }

    /* If the certificate cannot be retrieved from the axis2Message context, then mutual SSL authentication has
     not happened in transport level.*/
    if (sslCertObject == null) {
        if (log.isDebugEnabled()) {
            log.debug("Mutual SSL authentication has not happened in the transport level for the API "
                    + getAPIIdentifier(messageContext).toString() + ", hence API invocation is not allowed");
        }
        if (isMandatory) {
            log.error("Mutual SSL authentication failure");
        }
        return new AuthenticationResponse(false, isMandatory, !isMandatory,
                APISecurityConstants.API_AUTH_INVALID_CREDENTIALS, APISecurityConstants.API_AUTH_INVALID_CREDENTIALS_MESSAGE);
    } else {
        try {
            setAuthContext(messageContext, sslCertObject);
        } catch (APISecurityException ex) {
            return new AuthenticationResponse(false, isMandatory, !isMandatory, ex.getErrorCode(), ex.getMessage());
        }
    }
    return new AuthenticationResponse(true, isMandatory, true, 0, null);
}
 
Example 10
Source File: ApiCategoriesApiServiceImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public Response apiCategoriesApiCategoryIdDelete(String apiCategoryId, String ifMatch, String ifUnmodifiedSince,
                                                 MessageContext messageContext) {
    try {
        APIAdmin apiAdmin = new APIAdminImpl();
        String userName = RestApiUtil.getLoggedInUsername();
        apiAdmin.deleteCategory(apiCategoryId, userName);
        return Response.ok().build();
    } catch (APIManagementException e) {
        String errorMessage = "Error while deleting API Category '" + apiCategoryId + "' - " + e.getMessage();
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}
 
Example 11
Source File: ApiCategoriesApiServiceImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public Response apiCategoriesApiCategoryIdDelete(String apiCategoryId, String ifMatch,
        String ifUnmodifiedSince) {
    try {
        APIAdmin apiAdmin = new APIAdminImpl();
        String userName = RestApiUtil.getLoggedInUsername();
        apiAdmin.deleteCategory(apiCategoryId, userName);
        return Response.ok().build();
    } catch (APIManagementException e) {
        String errorMessage = "Error while deleting API Category '" + apiCategoryId + "' - " + e.getMessage() ;
        RestApiUtil.handleInternalServerError(errorMessage, e, log);
    }
    return null;
}