Search in sources :

Example 1 with STATE

use of org.wso2.carbon.identity.openidconnect.model.Constants.STATE in project carbon-identity-framework by wso2.

the class WorkflowRequestAssociationDAO method updateStatusOfRelationshipsOfPendingRequest.

/**
 * Update state of workflow of a request
 *
 * @param requestId requestId to update relationships of.
 * @throws InternalWorkflowException
 */
public void updateStatusOfRelationshipsOfPendingRequest(String requestId, String status) throws InternalWorkflowException {
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.UPDATE_STATUS_OF_RELATIONSHIPS_OF_REQUEST;
    try {
        Timestamp updatedDateStamp = new Timestamp(System.currentTimeMillis());
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, status);
        prepStmt.setTimestamp(2, updatedDateStamp);
        prepStmt.setString(3, requestId);
        prepStmt.setString(4, WFConstant.HT_STATE_PENDING);
        prepStmt.execute();
        IdentityDatabaseUtil.commitTransaction(connection);
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollbackTransaction(connection);
        throw new InternalWorkflowException("Error when executing the sql query:" + query, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
Also used : SQLException(java.sql.SQLException) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp)

Example 2 with STATE

use of org.wso2.carbon.identity.openidconnect.model.Constants.STATE in project carbon-identity-framework by wso2.

the class CarbonBasedTestListener method callInternalMethod.

private void callInternalMethod(Object target, String method, Class[] types, Object... values) {
    Class c = target.getClass();
    try {
        Method m = c.getDeclaredMethod(method, types);
        m.setAccessible(true);
        m.invoke(target, values);
    } catch (Exception e) {
        throw new RuntimeException("Unable to set internal state on a private field.", e);
    }
}
Also used : ITestClass(org.testng.ITestClass) Method(java.lang.reflect.Method) URISyntaxException(java.net.URISyntaxException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UserStoreException(org.wso2.carbon.user.api.UserStoreException) IOException(java.io.IOException)

Example 3 with STATE

use of org.wso2.carbon.identity.openidconnect.model.Constants.STATE in project carbon-identity-framework by wso2.

the class CarbonBasedTestListener method setInternalState.

public static void setInternalState(Class c, String field, Object value) {
    try {
        Field f = c.getDeclaredField(field);
        f.setAccessible(true);
        f.set(null, value);
    } catch (Exception e) {
        throw new RuntimeException("Unable to set internal state on a private field.", e);
    }
}
Also used : Field(java.lang.reflect.Field) URISyntaxException(java.net.URISyntaxException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UserStoreException(org.wso2.carbon.user.api.UserStoreException) IOException(java.io.IOException)

Example 4 with STATE

use of org.wso2.carbon.identity.openidconnect.model.Constants.STATE in project carbon-identity-framework by wso2.

the class CarbonBasedTestListener method setInternalState.

public static void setInternalState(Object target, String field, Object value) {
    Class c = target.getClass();
    try {
        Field f = c.getDeclaredField(field);
        f.setAccessible(true);
        f.set(target, value);
    } catch (Exception e) {
        throw new RuntimeException("Unable to set internal state on a private field.", e);
    }
}
Also used : Field(java.lang.reflect.Field) ITestClass(org.testng.ITestClass) URISyntaxException(java.net.URISyntaxException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UserStoreException(org.wso2.carbon.user.api.UserStoreException) IOException(java.io.IOException)

Example 5 with STATE

use of org.wso2.carbon.identity.openidconnect.model.Constants.STATE in project carbon-identity-framework by wso2.

the class UserStoreConfigAdminService method changeUserStoreState.

/**
 * Update a domain to be disabled/enabled in file repository.
 *
 * @param domain Name of the domain to be updated
 * @param isDisable Whether to disable/enable domain(true/false)
 * @throws IdentityUserStoreMgtException If error occurs during domain validation
 * @throws TransformerConfigurationException If error occurs during configuration transformation
 */
public void changeUserStoreState(String domain, Boolean isDisable) throws IdentityUserStoreMgtException, TransformerConfigurationException {
    validateDomain(domain, isDisable);
    try {
        triggerListenersOnUserStorePreStateChange(domain, isDisable);
    } catch (UserStoreException e) {
        throw new IdentityUserStoreMgtException("Error occurred while triggering the user store pre state change" + " listeners.");
    }
    UserStoreDTO userStoreDTO = getUserStoreDTO(domain, isDisable, null);
    updateStateInFileRepository(userStoreDTO);
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) UserStoreException(org.wso2.carbon.user.api.UserStoreException)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)66 HashMap (java.util.HashMap)38 ArrayList (java.util.ArrayList)32 Test (org.testng.annotations.Test)31 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)31 API (org.wso2.carbon.apimgt.api.model.API)24 SQLException (java.sql.SQLException)23 Map (java.util.Map)23 IOException (java.io.IOException)22 Connection (java.sql.Connection)22 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)22 PreparedStatement (java.sql.PreparedStatement)21 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)21 JSONObject (org.json.simple.JSONObject)20 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)20 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)18 APIInfo (org.wso2.carbon.apimgt.api.model.APIInfo)17 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)16 URISyntaxException (java.net.URISyntaxException)15 FaultGatewaysException (org.wso2.carbon.apimgt.api.FaultGatewaysException)15