Search in sources :

Example 6 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class SymmetricEncryptionServiceImpl method encrypt.

public String encrypt(Object valueToHide) throws GeneralSecurityException {
    if (valueToHide == null) {
        return "";
    }
    try {
        byte[] input = valueToHide.toString().getBytes(CHARSET);
        byte[] encrypted = encryptBytes(input);
        byte[] encoded = Base64.encodeBase64(encrypted);
        return new String(encoded, CHARSET);
    } catch (UnsupportedEncodingException uee) {
        throw new WorkflowRuntimeException(uee);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException)

Example 7 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class SymmetricEncryptionServiceImpl method decrypt.

public String decrypt(String ciphertext) throws GeneralSecurityException {
    if (StringUtils.isBlank(ciphertext)) {
        return "";
    }
    try {
        // un-Base64 encode the encrypted data
        byte[] input = ciphertext.getBytes(CHARSET);
        byte[] decoded = Base64.decodeBase64(input);
        byte[] cleartext = decryptBytes(decoded);
        return new String(cleartext, CHARSET);
    } catch (UnsupportedEncodingException e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException)

Example 8 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class ActionListDAOOjbImpl method getMaxActionItemDateAssignedAndCountForUser.

/**
 * Gets the max action item id and count doe a given user.
 *
 * @return A List with the first value being the maxActionItemId and the second value being the count
 */
public List<Object> getMaxActionItemDateAssignedAndCountForUser(final String principalId) {
    return (List<Object>) getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() {

        public Object doInPersistenceBroker(PersistenceBroker broker) {
            PreparedStatement statement = null;
            ResultSet resultSet = null;
            List<Object> result = new ArrayList<Object>();
            try {
                Connection connection = broker.serviceConnectionManager().getConnection();
                statement = connection.prepareStatement(MAX_ACTION_ITEM_DATE_ASSIGNED_AND_ACTION_LIST_COUNT_AND_QUERY);
                statement.setString(1, principalId);
                resultSet = statement.executeQuery();
                if (!resultSet.next()) {
                    throw new WorkflowRuntimeException("Error determining Action List Count and Max Action Item Id.");
                } else {
                    result.add(resultSet.getTimestamp(1));
                    result.add(resultSet.getInt(2));
                }
                return result;
            } catch (SQLException e) {
                throw new WorkflowRuntimeException("Error determining Action List Count and Max Action Item Id.", e);
            } catch (LookupException e) {
                throw new WorkflowRuntimeException("Error determining Action List Count and Max Action Item Id.", e);
            } finally {
                if (statement != null) {
                    try {
                        statement.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
            }
        }
    });
}
Also used : PersistenceBroker(org.apache.ojb.broker.PersistenceBroker) LookupException(org.apache.ojb.broker.accesslayer.LookupException) SQLException(java.sql.SQLException) PersistenceBrokerCallback(org.springmodules.orm.ojb.PersistenceBrokerCallback) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) List(java.util.List) PreparedStatement(java.sql.PreparedStatement) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException)

Example 9 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class ActionTakenDAOOjbImpl method getLastModifiedDate.

@Override
public Timestamp getLastModifiedDate(String documentId) {
    return (Timestamp) getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() {

        public Object doInPersistenceBroker(PersistenceBroker broker) {
            PreparedStatement statement = null;
            ResultSet resultSet = null;
            try {
                Connection connection = broker.serviceConnectionManager().getConnection();
                statement = connection.prepareStatement(LAST_MODIFIED_DATE_QUERY);
                statement.setString(1, documentId);
                resultSet = statement.executeQuery();
                if (!resultSet.next()) {
                    return null;
                } else {
                    return resultSet.getTimestamp(1);
                }
            } catch (Exception e) {
                throw new WorkflowRuntimeException("Error determining Last Modified Date.", e);
            } finally {
                if (statement != null) {
                    try {
                        statement.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
            }
        }
    });
}
Also used : PersistenceBroker(org.apache.ojb.broker.PersistenceBroker) SQLException(java.sql.SQLException) PersistenceBrokerCallback(org.springmodules.orm.ojb.PersistenceBrokerCallback) ResultSet(java.sql.ResultSet) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) Timestamp(java.sql.Timestamp) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) SQLException(java.sql.SQLException)

Example 10 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class ActionTakenDAOOjbImpl method getLastActionTakenDate.

public Timestamp getLastActionTakenDate(final String documentId, final ActionType actionType) {
    return (Timestamp) getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() {

        public Object doInPersistenceBroker(PersistenceBroker broker) {
            PreparedStatement statement = null;
            ResultSet resultSet = null;
            try {
                Connection connection = broker.serviceConnectionManager().getConnection();
                statement = connection.prepareStatement(LAST_ACTION_TAKEN_DATE_QUERY);
                statement.setString(1, documentId);
                statement.setString(2, actionType.getCode());
                resultSet = statement.executeQuery();
                if (!resultSet.next()) {
                    return null;
                } else {
                    return resultSet.getTimestamp(1);
                }
            } catch (Exception e) {
                throw new WorkflowRuntimeException("Error determining Last Action Taken Date.", e);
            } finally {
                if (statement != null) {
                    try {
                        statement.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
            }
        }
    });
}
Also used : PersistenceBroker(org.apache.ojb.broker.PersistenceBroker) SQLException(java.sql.SQLException) PersistenceBrokerCallback(org.springmodules.orm.ojb.PersistenceBrokerCallback) ResultSet(java.sql.ResultSet) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) Timestamp(java.sql.Timestamp) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) SQLException(java.sql.SQLException)

Aggregations

WorkflowRuntimeException (org.kuali.kfs.kew.api.WorkflowRuntimeException)12 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)6 PersistenceBroker (org.apache.ojb.broker.PersistenceBroker)6 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 ServletException (javax.servlet.ServletException)4 LookupException (org.apache.ojb.broker.accesslayer.LookupException)4 ActionMessage (org.apache.struts.action.ActionMessage)4 ActionMessages (org.apache.struts.action.ActionMessages)4 WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)4 DocumentRouteHeaderValue (org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue)4 PersistenceBrokerCallback (org.springmodules.orm.ojb.PersistenceBrokerCallback)4 ArrayList (java.util.ArrayList)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Timestamp (java.sql.Timestamp)2 HashSet (java.util.HashSet)2 OptimisticLockException (org.apache.ojb.broker.OptimisticLockException)2