Search in sources :

Example 41 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class AttachmentMgtDAOFactoryImpl method removeAttachment.

@Override
public boolean removeAttachment(final String id) throws AttachmentMgtException {
    try {
        boolean isRemoved = false;
        isRemoved = jobExecutor.execTransaction(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                Query query = entityManager.createQuery("DELETE FROM org.wso2.carbon.attachment.mgt.core.dao.impl" + ".jpa.openjpa.entity.AttachmentDAOImpl x WHERE x.id = " + ":attachmentID");
                query.setParameter("attachmentID", Long.parseLong(id));
                int noOfRowsUpdated = query.executeUpdate();
                // entityManager.remove(getAttachmentInfo(id));
                if (noOfRowsUpdated == 1) {
                    return true;
                } else {
                    return false;
                }
            }
        });
        return isRemoved;
    } catch (Exception e) {
        String errorMsg = "org.wso2.carbon.attachment.mgt.core.dao.impl.jpa.openjpa.AttachmentMgtDAOFactoryImpl.removeAttachment operation failed. " + "Reason: " + e.getLocalizedMessage();
        log.error(errorMsg, e);
        throw new AttachmentMgtException(errorMsg, e);
    }
}
Also used : AttachmentMgtException(org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException) Query(javax.persistence.Query) Callable(java.util.concurrent.Callable) AttachmentMgtException(org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException)

Example 42 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class HumanTaskJPQLQueryBuilder method buildRemoveTasksQuery.

private Query buildRemoveTasksQuery() {
    boolean hasStatus = false;
    List<TaskStatus> statuses = queryCriteria.getStatuses();
    if (statuses != null && !statuses.isEmpty()) {
        hasStatus = true;
    }
    boolean hasTaskName = false;
    if (!StringUtils.isEmpty(queryCriteria.getTaskName())) {
        hasTaskName = true;
    }
    Query removeTasksQuery = em.createQuery(" DELETE FROM  org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task t  " + " WHERE t.status in :removableStatuses" + (hasTaskName ? AND + FILTER_BY_TASKNAME : ""));
    removeTasksQuery.setParameter("removableStatuses", queryCriteria.getStatuses());
    if (hasTaskName) {
        removeTasksQuery.setParameter(TASK_NAME, queryCriteria.getTaskName());
    }
    return removeTasksQuery;
}
Also used : Query(javax.persistence.Query) TaskStatus(org.wso2.carbon.humantask.core.dao.TaskStatus)

Example 43 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class HumanTaskDAOConnectionImpl method getDeploymentUnitByName.

public DeploymentUnitDAO getDeploymentUnitByName(int tenantId, String packageName) {
    Query q = entityManager.createQuery("select hu from org.wso2.carbon.humantask.core.dao.jpa.openjpa.model" + ".DeploymentUnit hu WHERE hu.status=?1 and hu.tenantId=?2 and hu.packageName=?3");
    q.setParameter(1, TaskPackageStatus.ACTIVE);
    q.setParameter(2, tenantId);
    q.setParameter(3, packageName);
    List<DeploymentUnit> resultList = q.getResultList();
    DeploymentUnit deploymentUnit = null;
    if (resultList.size() != 0) {
        deploymentUnit = resultList.get(0);
    }
    return deploymentUnit;
}
Also used : Query(javax.persistence.Query) HumanTaskDeploymentUnit(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)

Example 44 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project jaggery by wso2.

the class RegistryHostObject method jsFunction_addComment.

public static void jsFunction_addComment(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws ScriptException {
    String functionName = "addComment";
    int argsCount = args.length;
    if (argsCount != 2) {
        HostObjectUtil.invalidNumberOfArgs(hostObjectName, functionName, argsCount, false);
    }
    if (!(args[0] instanceof String)) {
        HostObjectUtil.invalidArgsError(hostObjectName, functionName, "1", "string", args[0], false);
    }
    if (!(args[1] instanceof String)) {
        HostObjectUtil.invalidArgsError(hostObjectName, functionName, "2", "string", args[1], false);
    }
    RegistryHostObject registryHostObject = (RegistryHostObject) thisObj;
    try {
        registryHostObject.registry.addComment((String) args[0], new org.wso2.carbon.registry.core.Comment((String) args[1]));
    } catch (RegistryException e) {
        throw new ScriptException(e);
    }
}
Also used : org.wso2.carbon.registry.core(org.wso2.carbon.registry.core) ScriptException(org.jaggeryjs.scriptengine.exceptions.ScriptException) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 45 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project jaggery by wso2.

the class RegistryHostObject method isAuthorized.

private boolean isAuthorized(UserRegistry registry, String resourcePath, String action) throws RegistryException {
    UserRealm userRealm = registry.getUserRealm();
    String userName = registry.getUserName();
    try {
        if (!userRealm.getAuthorizationManager().isUserAuthorized(userName, resourcePath, action)) {
            return false;
        }
    } catch (UserStoreException e) {
        throw new org.wso2.carbon.registry.core.exceptions.RegistryException("Error at Authorizing " + resourcePath + " with user " + userName + ":" + e.getMessage(), e);
    }
    return true;
}
Also used : UserRealm(org.wso2.carbon.user.core.UserRealm) UserStoreException(org.wso2.carbon.user.core.UserStoreException)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)18 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)13 HashMap (java.util.HashMap)12 Query (javax.persistence.Query)9 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)9 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)5 TAttachment (org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)5 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)4 AttachmentDAO (org.wso2.carbon.attachment.mgt.core.dao.AttachmentDAO)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)4 Test (org.testng.annotations.Test)3 ConfigurationException (org.wso2.carbon.config.ConfigurationException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2 Connection (java.sql.Connection)2 List (java.util.List)2