Search in sources :

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

use of org.wso2.carbon.humantask.client.api.types in project core-util by WSO2Telco.

the class UserAuthorizationValidator method isAuthorizedRole.

public boolean isAuthorizedRole(String userName, Set<String> allowedRolesSet) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class, null);
    try {
        RealmConfiguration realmConfiguration = new RealmConfiguration();
        String[] currentUserRoles = realmService.getUserRealm(realmConfiguration).getUserStoreManager().getRoleListOfUser(userName);
        List<String> currentUserRolesList = Arrays.asList(currentUserRoles);
        Iterator<String> iterator = allowedRolesSet.iterator();
        while (iterator.hasNext()) {
            String allowedRole = iterator.next();
            if (currentUserRolesList.contains(allowedRole)) {
                return true;
            }
        }
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        log.error("authorization failed for user : " + userName, e);
        return false;
    }
    log.error("authorization failed for user : " + userName);
    return false;
}
Also used : RealmConfiguration(org.wso2.carbon.user.api.RealmConfiguration) RealmService(org.wso2.carbon.user.core.service.RealmService) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext)

Example 67 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 AttachmentManagerService method add.

/**
 * {@inheritDoc}
 */
@Override
public String add(final TAttachment attachment) throws AttachmentMgtException {
    if (log.isDebugEnabled() && attachment != null) {
        log.debug("Saving the attachment with id " + attachment.getId());
    }
    try {
        Attachment att = TransformerUtil.convertAttachment(attachment);
        // 1. get Att-Mgt DAO Conn factory
        // 2. get Att-Mgt DAO Connection
        // 3. addAttachment
        // getDaoConnectionFactory().getDAOConnection().addAttachment(att);
        AttachmentDAO daoImpl = getDaoConnectionFactory().getDAOConnection().getAttachmentMgtDAOFactory().addAttachment(att);
        return daoImpl.getID().toString();
    } catch (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException ex) {
        String errMsg = "org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService.add " + "operation failed. Reason:" + ex.getLocalizedMessage();
        log.error(errMsg, ex);
        throw new AttachmentMgtException(errMsg, ex);
    }
}
Also used : AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException) AttachmentDAO(org.wso2.carbon.attachment.mgt.core.dao.AttachmentDAO) TAttachment(org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment) Attachment(org.wso2.carbon.attachment.mgt.api.attachment.Attachment)

Example 68 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 Database method createActivitiMetaDataTable.

/**
 * during the start up of the server this method will create BPS_BPMN_DEPLOYMENT_METADATA table
 * if it doesn't exist in the activiti database.
 *
 * @throws org.wso2.carbon.bpmn.core.exception.BPMNMetaDataTableCreationException
 */
private void createActivitiMetaDataTable() throws BPMNMetaDataTableCreationException {
    BPMNDatabaseCreator bpmnDatabaseCreator = new BPMNDatabaseCreator(getDataSource());
    String bpmnDeploymentMetaDataQuery = "SELECT * FROM " + BPMNConstants.BPS_BPMN_DEPLOYMENT_METADATA_TABLE;
    if (!bpmnDatabaseCreator.isDatabaseStructureCreated(bpmnDeploymentMetaDataQuery)) {
        try {
            bpmnDatabaseCreator.createRegistryDatabase();
        } catch (Exception e) {
            String errMsg = "Error creating BPS_BPMN_DEPLOYMENT_METADATA table";
            throw new BPMNMetaDataTableCreationException(errMsg, e);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("BPS_BPMN_DEPLOYMENT_METADATA table already exists. Using the old table.");
        }
    }
}
Also used : BPMNMetaDataTableCreationException(org.wso2.carbon.bpmn.core.exception.BPMNMetaDataTableCreationException) BPMNDatabaseCreator(org.wso2.carbon.bpmn.core.utils.BPMNDatabaseCreator) BPMNMetaDataTableCreationException(org.wso2.carbon.bpmn.core.exception.BPMNMetaDataTableCreationException) DatabaseConfigurationException(org.wso2.carbon.bpmn.core.exception.DatabaseConfigurationException) NamingException(javax.naming.NamingException)

Example 69 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 BPELServerImpl method registerMBeans.

public void registerMBeans() throws Exception, MBeanRegistrationException, InstanceAlreadyExistsException, NotCompliantMBeanException {
    log.info("Registering MBeans");
    Processes processMBean = new Processes();
    Instance instanceMBean = new Instance();
    InstanceStatusMonitor statusMonitorMBean = InstanceStatusMonitor.getInstanceStatusMonitor();
    // ObjectName instanceStatusObjectName= new ObjectName("org.wso2.carbon.bpel.core.ode.integration
    // .jmx:type=InstanceStatusMonitor");
    // ObjectName processObjectName= new ObjectName("org.wso2.carbon.bpel.core.ode.integration.jmx:type=Process");
    // ObjectName instanceObjectName= new ObjectName("org.wso2.carbon.bpel.core.ode.integration.jmx:type=Instance");
    MBeanRegistrar.registerMBean(processMBean, "org.wso2.carbon.bpel.core.ode.integration.jmx:type=Process");
    MBeanRegistrar.registerMBean(instanceMBean, "org.wso2.carbon.bpel.core.ode.integration.jmx:type=Instance");
    MBeanRegistrar.registerMBean(statusMonitorMBean, "org.wso2.carbon.bpel.core.ode.integration" + ".jmx:type=InstanceStatusMonitor");
}
Also used : InstanceStatusMonitor(org.wso2.carbon.bpel.core.ode.integration.jmx.InstanceStatusMonitor) Instance(org.wso2.carbon.bpel.core.ode.integration.jmx.Instance) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Processes(org.wso2.carbon.bpel.core.ode.integration.jmx.Processes)

Example 70 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 TenantProcessStoreImpl method reloadExistingVersionsOfBPELPackage.

/**
 * Reload old versions of BPEL package. This is used to handle restart of BPS server.
 * At restart based on the last modified time of the BPEL archives we'll reload all the versions
 * of that BPEL archive.
 *
 * @param deploymentContext information about current deployment
 * @throws RegistryException                                                                     on error loading
 * resources from registry.
 * @throws org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException
 */
private void reloadExistingVersionsOfBPELPackage(BPELDeploymentContext deploymentContext) throws RegistryException, ProcessManagementException {
    BPELPackageInfo bpelPackage = repository.getBPELPackageInfo(deploymentContext);
    String lastActivePackageName = null;
    for (String packageName : bpelPackage.getAvailableVersions()) {
        if (deploymentUnits.containsKey(packageName)) {
            lastActivePackageName = packageName;
        } else {
            // version of the package
            if (null != lastActivePackageName && isConfigRegistryReadOnly()) {
                loadExistingBPELPackage(lastActivePackageName);
            }
            loadExistingBPELPackage(packageName);
        }
    }
}
Also used : BPELPackageInfo(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)

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