Search in sources :

Example 96 with Condition

use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project charon by wso2.

the class GroupResourceManager method updateWithPATCH.

/**
 * Updates the group based on the operations defined in the patchRequest. The updated group information is not
 * sent back in the response.
 *
 * @param existingGroupId SCIM2 ID of the existing group
 * @param patchRequest    SCIM2 patch request
 * @param userManager     SCIM UserManager that handles the persistence layer.
 * @return
 */
@Override
public SCIMResponse updateWithPATCH(String existingGroupId, String patchRequest, UserManager userManager) {
    try {
        if (userManager == null) {
            String error = "Provided user manager handler is null.";
            throw new InternalErrorException(error);
        }
        SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
        Map<String, Boolean> requestAttributes = ResourceManagerUtil.getAllAttributeURIs(schema);
        Group oldGroup = userManager.getGroup(existingGroupId, requestAttributes);
        if (oldGroup == null) {
            throw new NotFoundException("No group with the id : " + existingGroupId + " exists in the user store.");
        }
        // Make a copy of original group. This will be used to restore to the original condition if failure occurs.
        Group originalGroup = (Group) CopyUtil.deepCopy(oldGroup);
        Group patchedGroup = doPatchGroup(oldGroup, schema, patchRequest);
        userManager.updateGroup(originalGroup, patchedGroup);
        // Build the 204 response.
        Map<String, String> httpHeaders = new HashMap<>();
        httpHeaders.put(SCIMConstants.CONTENT_TYPE_HEADER, SCIMConstants.APPLICATION_JSON);
        return new SCIMResponse(ResponseCodeConstants.CODE_NO_CONTENT, null, httpHeaders);
    } catch (NotFoundException | BadRequestException | NotImplementedException | CharonException | InternalErrorException e) {
        return AbstractResourceManager.encodeSCIMException(e);
    } catch (RuntimeException e) {
        CharonException ex = new CharonException("Error in performing the patch operation on group resource.", e);
        return AbstractResourceManager.encodeSCIMException(ex);
    }
}
Also used : Group(org.wso2.charon3.core.objects.Group) HashMap(java.util.HashMap) NotImplementedException(org.wso2.charon3.core.exceptions.NotImplementedException) NotFoundException(org.wso2.charon3.core.exceptions.NotFoundException) InternalErrorException(org.wso2.charon3.core.exceptions.InternalErrorException) BadRequestException(org.wso2.charon3.core.exceptions.BadRequestException) SCIMResourceTypeSchema(org.wso2.charon3.core.schema.SCIMResourceTypeSchema) CharonException(org.wso2.charon3.core.exceptions.CharonException) SCIMResponse(org.wso2.charon3.core.protocol.SCIMResponse)

Example 97 with Condition

use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-business-process by wso2.

the class IfImpl method isSimpleLayout.

/**
 * @return false- if the subActivities are instances of ElseIf or Else
 * true - otherwise
 */
private boolean isSimpleLayout() {
    boolean simple = true;
    ActivityInterface activity = null;
    // Iterates through the subActivities
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    while (itr.hasNext()) {
        activity = itr.next();
        // if the activity is an instance of ElseIf or Else, break the if condition
        if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
            simple = false;
            break;
        }
    }
    return simple;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Example 98 with Condition

use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-business-process by wso2.

the class IfImpl method getArrows.

/**
 * Get the arrow coordinates of the activities
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the activity
 * @return An element which contains the arrow coordinates of the If activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    if (subActivities != null) {
        ActivityInterface prevActivity = null;
        ActivityInterface prevElseActivity = null;
        ActivityInterface activity = null;
        ActivityInterface seqActivity = null;
        boolean throwOrNot = true;
        String id = null;
        // Coordinates of the start icon exit arrow
        SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
        // Coordinates of the end icon entry arrow
        SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
        // Coordinates of the Else activity start icon entry arrow
        SVGCoordinates myStartElseCoords = getStartIconElseArrowCoords();
        SVGCoordinates exitCoords = null;
        SVGCoordinates activityEntryCoords = null;
        SVGCoordinates activityExitCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        Element subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            // Gets the entry and exit coordinates of the iterated activity
            activityEntryCoords = activity.getEntryArrowCoords();
            activityExitCoords = activity.getExitArrowCoords();
            // Checks if the iterated activity is an instance of ElseIf or Else activity
            if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
                // Checks whether there is a  previous activity and if so whether that activity is an ElseIf
                if (prevActivity != null && prevActivity instanceof ElseIfImpl) {
                    // Get the exit arrow coordinates of the ElseIf activity
                    exitCoords = ((ElseIfInterface) prevActivity).getNextElseExitArrowCoords();
                    // id is assigned with the id of the previous activity + id of the current activity
                    id = prevActivity.getId() + "-" + activity.getId();
                    // Checks whether the activity is an instance of Else
                    if (activity instanceof ElseImpl) {
                        // Gets the boolean value assigned inside ElseImpl when a throw activity is in Else
                        boolean check = ((ElseImpl) activity).throwOrNot;
                        // Define the entry arrow flow coordinates for the activity
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft() - getEndIconWidth() / 2, exitCoords.getYTop(), id));
                        // If there is a Throw activity inside Else, no exit arrow from Throw activity
                        if (check != true) {
                            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                        }
                    } else if (activity instanceof ElseIfImpl) {
                        // Checks whether the activity is an instance of ElseIf
                        // Gets the boolean value assigned inside ElseIfImpl when a throw activity is in ElseIf
                        boolean check = ((ElseIfImpl) activity).throwOrNot;
                        // Define the entry arrow flow coordinates for the activity
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        // If there is a Throw activity inside ElseIf, no exit arrow from Throw activity
                        if (check != true) {
                            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                        }
                    } else {
                        // Entry and exit arrow flows defined for other activities except for instances of Elseif and
                        // Else
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                } else if (prevActivity instanceof ThrowImpl && activity instanceof ElseImpl) {
                    // IF conditon fifnished --> ELSE IF ( previous activity is null and its is not an instance of
                    // ElseIf)
                    /*Checks if the previous activity is a Throw and if the current activity an Else, if so no exit
                        arrow flows only entry arrow flows.
                        */
                    subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                } else if (activity instanceof ElseIfImpl) {
                    // Checks whether the activity is an instance of ElseIf
                    // Gets the boolean value assigned inside ElseIfImpl when a throw activity is in ElseIf
                    boolean check = ((ElseIfImpl) activity).throwOrNot;
                    // Define the entry arrow flow coordinates for the activity
                    subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    // If there is a Throw activity inside ElseIf, no exit arrow from Throw activity
                    if (check != true) {
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                } else if (activity instanceof ElseImpl) {
                    // Checks whether the activity is an instance of Else
                    // Gets the boolean value assigned inside ElseIfImpl when a throw activity is in Else
                    boolean check = ((ElseImpl) activity).throwOrNot;
                    // Define the entry arrow flow coordinates for the activity
                    subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    // If there is a Throw activity inside Else, no exit arrow from Throw activity
                    if (check != true) {
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                } else {
                    id = prevActivity.getId() + "-" + activity.getId();
                    // flows
                    if (activity instanceof ThrowImpl) {
                        subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    } else {
                        // Define both the entry and the exit arrow flows to the activity
                        subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                }
            } else if (activity instanceof ThrowImpl) {
                // Checks if the current activity a Throw activity, if so no exit arrow flows only entry arrow flows
                subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
            } else if (activity instanceof SourceImpl || activity instanceof TargetImpl || activity instanceof SourcesImpl || activity instanceof TargetsImpl) {
            // Checks if the current activity a Source/s or Target/s activity, if so no exit or entry arrow flows
            // as no icons are defined
            // No arrow flows for Sources or Targets..
            } else {
                if (prevActivity != null) {
                    // Gets the coordinates of the exit arrows of the previous activity
                    exitCoords = prevActivity.getExitArrowCoords();
                    id = prevActivity.getId() + "-" + activity.getId();
                    // arrow flows as no icons are defined
                    if (prevActivity instanceof SourceImpl || prevActivity instanceof TargetImpl || prevActivity instanceof SourcesImpl || prevActivity instanceof TargetsImpl) {
                    // No arrow flows for Sources or Targets..
                    } else {
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    }
                } else {
                    // Checks whether the activity is a Sequence
                    if (activity instanceof SequenceImpl) {
                        List<ActivityInterface> sub = activity.getSubActivities();
                        // Iterates through the subActivities
                        Iterator<ActivityInterface> as = sub.iterator();
                        while (as.hasNext()) {
                            seqActivity = as.next();
                            // Checks if the subActivity is a Throw activity
                            if (seqActivity instanceof ThrowImpl) {
                                throwOrNot = true;
                                // if condition breaks if the subActivity is a Throw activity
                                break;
                            } else {
                                throwOrNot = false;
                            }
                        }
                        // If its a Throw activity , no exit arrow flow only entry arrow flow to the activity
                        if (throwOrNot == true) {
                            subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        } else {
                            // If not, define both the entry and the exit arrow flows to the activity
                            subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                        }
                    } else {
                        // Define both the entry and the exit arrow flows to the activity
                        subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                }
            }
            // current activity is assigned to the previous activity
            prevActivity = activity;
        }
        return subGroup;
    }
    return null;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 99 with Condition

use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-business-process by wso2.

the class HumanTaskStore method deploy.

/**
 * This will simply deploy the new task and will not perform removal of existing tasks, which should be done prior to
 * deploying this task
 * @param humanTaskDU
 * @return List of task configuration Qnames deployed
 * @throws HumanTaskDeploymentException
 */
public List<QName> deploy(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException {
    List<QName> taskConfigsInPackage = new ArrayList<QName>();
    TTask[] tasks = humanTaskDU.getTasks();
    List<HumanTaskBaseConfiguration> configurations = new ArrayList<HumanTaskBaseConfiguration>();
    if (tasks != null) {
        for (TTask task : tasks) {
            QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
            if (log.isDebugEnabled()) {
                log.debug(" Adding task " + task.getName() + "to task configuration");
            }
            TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            taskConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(taskConf);
            if (!taskConf.isErroneous()) {
                createCallBackService(taskConf);
                if (taskConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(taskConf);
                // activeTaskConfigurationQNameMap.put(taskQName, taskConf.getName());
                }
            }
        }
    }
    TNotification[] notifications = humanTaskDU.getNotifications();
    if (notifications != null) {
        for (TNotification notification : notifications) {
            QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
            NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
            notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
            configurations.add(notificationConf);
            if (!notificationConf.isErroneous()) {
                // Deploy the axis2 service only for the active version of the task/notification
                if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
                    deploy(notificationConf);
                // activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
                }
            }
        }
    }
    // condition if a service name is deployed with same name outside of this task package
    for (HumanTaskBaseConfiguration configuration : configurations) {
        taskConfigurations.add(configuration);
        taskBaseConfigurationHashMap.put(configuration.getName(), configuration);
        taskConfigsInPackage.add(configuration.getName());
        if (configuration.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(configuration.getDefinitionName(), configuration.getName());
        }
    }
    for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
        QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
        NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
        notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
        taskConfigurations.add(notificationConf);
        taskConfigsInPackage.add(notificationConf.getName());
        taskBaseConfigurationHashMap.put(notificationConf.getName(), notificationConf);
        if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
            activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
        }
    }
    taskConfigurationsInTaskPackage.put(humanTaskDU.getName(), taskConfigsInPackage);
    return taskConfigsInPackage;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 100 with Condition

use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-identity-framework by wso2.

the class TestUtils method getSampleSearchCondition.

public static ComplexCondition getSampleSearchCondition() {
    PrimitiveCondition tenantDomainEqSuper = new PrimitiveCondition(RESOURCE_SEARCH_BEAN_FIELD_TENANT_DOMAIN, ConditionType.PrimitiveOperator.EQUALS, SUPER_TENANT_DOMAIN_NAME);
    PrimitiveCondition tenantDomainEqABC = new PrimitiveCondition(RESOURCE_SEARCH_BEAN_FIELD_TENANT_DOMAIN, ConditionType.PrimitiveOperator.EQUALS, SAMPLE_TENANT_DOMAIN_ABC);
    PrimitiveCondition attributeKeyEqFrom = new PrimitiveCondition(RESOURCE_SEARCH_BEAN_FIELD_ATTRIBUTE_KEY, ConditionType.PrimitiveOperator.EQUALS, SAMPLE_ATTRIBUTE_NAME1);
    List<Condition> tenantDomainConditions = new ArrayList<>();
    tenantDomainConditions.add(tenantDomainEqSuper);
    tenantDomainConditions.add(tenantDomainEqABC);
    ComplexCondition eitherTenantDomain = new ComplexCondition(ConditionType.ComplexOperator.OR, tenantDomainConditions);
    List<Condition> conditions = new ArrayList<>();
    conditions.add(eitherTenantDomain);
    conditions.add(attributeKeyEqFrom);
    return new ComplexCondition(ConditionType.ComplexOperator.AND, conditions);
}
Also used : PrimitiveCondition(org.wso2.carbon.identity.configuration.mgt.core.search.PrimitiveCondition) ComplexCondition(org.wso2.carbon.identity.configuration.mgt.core.search.ComplexCondition) Condition(org.wso2.carbon.identity.configuration.mgt.core.search.Condition) ArrayList(java.util.ArrayList) PrimitiveCondition(org.wso2.carbon.identity.configuration.mgt.core.search.PrimitiveCondition) ComplexCondition(org.wso2.carbon.identity.configuration.mgt.core.search.ComplexCondition)

Aggregations

ArrayList (java.util.ArrayList)43 HashMap (java.util.HashMap)40 Test (org.testng.annotations.Test)34 Test (org.junit.Test)32 PreparedStatement (java.sql.PreparedStatement)29 List (java.util.List)28 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)26 ConditionDto (org.wso2.carbon.apimgt.impl.dto.ConditionDto)26 MessageContext (org.apache.synapse.MessageContext)25 ResultSet (java.sql.ResultSet)24 Map (java.util.Map)24 SQLException (java.sql.SQLException)22 Connection (java.sql.Connection)21 BlockConditions (org.wso2.carbon.apimgt.core.models.BlockConditions)18 ThrottleProperties (org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)18 HeaderCondition (org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)15 JWTClaimsCondition (org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)15 QueryParameterCondition (org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)15 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)15 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)15