/*
Implementation
482439
private boolean hasPermission(IPerson person, String permission, String target) {
        EntityIdentifier ei = person.getEntityIdentifier();
        IAuthorizationPrincipal ap =
                AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
        return ap.hasPermission(IPermission.PORTAL_GROUPS, permission, target);
    }
1266307
@Override
    public void visitCode(Code obj) {
        try {
            userValues = new HashMap<>();
            super.visitCode(obj);
        } finally {
            userValues = null;
        }
    }
672273
@Override
    public T data(Object... values) {
        if (values == null || values.length == 0) {
            return (T) this;
        }
        for (Object value : values) {
            this.data().add(value);
        }
        return (T) this;
    }
679552
private void initValues() throws VarExploderException
    {

        Class<?> c = source.getClass();
        if (c.isAnnotation() || c.isArray() || c.isEnum() || c.isPrimitive())
        {
            throw new IllegalArgumentException("The value must an object");
        }

        if(source instanceof Map )
        {
            this.pairs = (Map<String,Object>) source;
            return;
        }
        Method[] methods = c.getMethods();
        for (Method method : methods)
        {
            inspectGetters(method);
        }
        scanFields(c);
    }
557471
public void init(final MultivaluedMap<String, String> queryParameters) {
        final String scopeCompileParam = queryParameters.getFirst(ServerAPI.SCOPE_COMPILE_PARAM);
        if(scopeCompileParam != null){
            this.scopeComp = Boolean.valueOf(scopeCompileParam);
        }
        final String scopeProvidedParam = queryParameters.getFirst(ServerAPI.SCOPE_PROVIDED_PARAM);
        if(scopeProvidedParam != null){
            this.scopePro = Boolean.valueOf(scopeProvidedParam);
        }
        final String scopeRuntimeParam = queryParameters.getFirst(ServerAPI.SCOPE_RUNTIME_PARAM);
        if(scopeRuntimeParam != null){
            this.scopeRun = Boolean.valueOf(scopeRuntimeParam);
        }
        final String scopeTestParam = queryParameters.getFirst(ServerAPI.SCOPE_TEST_PARAM);
        if(scopeTestParam != null){
            this.scopeTest = Boolean.valueOf(scopeTestParam);
        }
    }
507142
@Override
  @SuppressWarnings("unchecked")
  public void initialize() {
    LOG.initializeExecution(this);

    ScopeImpl scope = getScopeActivity();
    ensureParentInitialized();

    List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS);
    if (variableDeclarations != null) {
      for (VariableDeclaration variableDeclaration : variableDeclarations) {
        variableDeclaration.initialize(this, parent);
      }
    }

    if (isProcessInstanceExecution()) {
      String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
      if (initiatorVariableName != null) {
        String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId();
        setVariable(initiatorVariableName, authenticatedUserId);
      }
    }

    // create event subscriptions for the current scope
    for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) {
      if(!declaration.isStartEvent()) {
        declaration.createSubscriptionForExecution(this);
      }
    }
  }
950742
@Override
	public void visitClassContext(ClassContext classContext) {
		try {
			stack = new OpcodeStack();
			localMethodCalls = new HashMap<>();
			fieldMethodCalls = new HashMap<>();
			staticMethodCalls = new HashMap<>();
			branchTargets = new BitSet();
			super.visitClassContext(classContext);
		} finally {
			stack = null;
			localMethodCalls = null;
			fieldMethodCalls = null;
			staticMethodCalls = null;
			branchTargets = null;
		}
	}
101193
@PostLoad
    @PostPersist
    @PostUpdate
    @PostRemove
    private void init() {
        if (this.internalPortletDefinitionId != -1
                && (this.portletDefinitionId == null
                        || this.portletDefinitionId.getLongId()
                                != this.internalPortletDefinitionId)) {
            this.portletDefinitionId =
                    PortletDefinitionIdImpl.create(this.internalPortletDefinitionId);
        }
    }
379374
@Override
	public Element execute(Context context) {

		assert (ops.length == 2 || ops.length == 3);

		// Pop the condition from the data stack.
		boolean condition = false;
		try {
			condition = ((BooleanProperty) ops[0].execute(context)).getValue();
		} catch (ClassCastException cce) {
			throw new EvaluationException(MessageUtils
					.format(MSG_INVALID_IF_ELSE_TEST), sourceRange);
		}

		// Choose the correct operation and execute it.
		Operation op = null;
		if (condition) {
			op = ops[1];
		} else if (ops.length > 2) {
			op = ops[2];
		} else {
			op = Undef.VALUE;
		}
		return op.execute(context);
	}
329908
@Override
    public <O> void set(String key, O value) {
        set(key,value,null,false);
    }
625769
public void init() {
        final String string = getString();
        final int bpos = string.indexOf('/');
        if (bpos == -1) {
            prefix = string;
            surname = "";
            suffix = "";
        } else {
            final int epos = string.indexOf('/', bpos + 1);
            prefix = string.substring(0, bpos);
            surname = string.substring(bpos + 1, epos);
            suffix = string.substring(epos + 1);
        }
    }
1004627
function(object, properties) {
        if (!object.__isInterfaceImplemented('properties')) {
            object.__implementInterface('properties', this.interface);
        }

        object.__initProperties();

        var processor = this.get();

        _.each(properties, function(data, property) {
             processor.process(object, data, property);
        });
    }
333289
@Override
  public final synchronized void init() throws Exception {
    FactoryBldServices<ResultSet> factoryBldServices =
      new FactoryBldServices<ResultSet>();
    factoryBldServices.setFactoryAppBeans(this);
    setFactoryBldServices(factoryBldServices);
    FactoryReplicatorXmlHttps<ResultSet> factoryReplicatorXmlHttps =
      new FactoryReplicatorXmlHttps<ResultSet>();
    factoryReplicatorXmlHttps.setFactoryAppBeans(this);
    setFactoryReplicatorXmlHttps(factoryReplicatorXmlHttps);
    FactoryDatabaseWriterXml<ResultSet> factoryDatabaseWriterXml =
      new FactoryDatabaseWriterXml<ResultSet>();
    factoryDatabaseWriterXml.setFactoryAppBeans(this);
    setFactoryDatabaseWriterXml(factoryDatabaseWriterXml);
  }
908734
@Override
    public V get(String s, int offset, int len) {
        int t = 0;
        for (int i = 0; i < len; ) {
            char c = s.charAt(offset + i++);
            if (isCaseInsensitive() && c < 128)
                c = StringUtils.lowercases[c];

            while (true) {
                int row = ROW_SIZE * t;
                char n = _tree[row];
                int diff = n - c;

                if (diff == 0) {
                    t = _tree[row + EQ];
                    if (t == 0)
                        return null;
                    break;
                }

                t = _tree[row + hilo(diff)];
                if (t == 0)
                    return null;
            }
        }

        return _value[t];
    }
1089612
@Override
    protected void prepare() throws JspTagException {
        if (items instanceof ValueExpression) {
            deferredExpression = (ValueExpression) items;
            itemsValueIteratedExpression = new IteratedExpression(deferredExpression, getDelims());
            currentIndex = 0;

            Object originalValue = deferredExpression.getValue(pageContext.getELContext());
            if (originalValue instanceof String) {
                st = new StringTokenizer((String) originalValue, delims);
            } else {
                throw new JspTagException();
            }
        } else {
            st = new StringTokenizer((String) items, delims);
        }
    }
776184
@Override
    public IPromise then(Callback resultCB) {
        // FIXME: this can be implemented more efficient
        while( !lock.compareAndSet(false,true) ) {}
        try {
            if (resultReceiver != null)
                throw new RuntimeException("Double register of promise listener");
            resultReceiver = resultCB;
            if (hadResult) {
                hasFired = true;
                if (nextFuture == null) {
                    nextFuture = new Promise(result, error);
                    lock.set(false);
                    resultCB.complete(result, error);
                } else {
                    lock.set(false);
                    resultCB.complete(result, error);
                    nextFuture.complete(result, error);
                    return nextFuture;
                }
            }
            if (resultCB instanceof IPromise) {
                return (IPromise) resultCB;
            }
            lock.set(false);
            while( !lock.compareAndSet(false,true) ) {}
            if (nextFuture == null) {
                return nextFuture = new Promise();
            } else {
                return nextFuture;
            }
        } finally {
            lock.set(false);
        }
    }
1179120
public void perform() {
		log.info(toString());

		WebElement element = finder.find();

		switch (stepMode) {
			case CHECK_VALUE:
				String checkValue = retrieveValue();
				if (checkTrafo != null) {
					checkValue = checkTrafo.trafo(checkValue);
				}
				checkValue(element, checkValue);
				break;

			case CHECK_DEFAULT:
				checkState(defaultsProvider != null, "No DefaultsProvider set when StepMode is CHECK_DEFAULT.");
				checkValue(element, defaultsProvider.get(element, dataSet, dataKey, dataIndex));
				break;

			case SET_VALUE:
				String setValue = retrieveValue();
				if (setTrafo != null) {
					setValue = setTrafo.trafo(setValue);
				}

				if (element.getTagName().equalsIgnoreCase(WebConstants.SELECT)) {

					Select select = new Select(element);
					// First check if a matching value can be found
					List<WebElement> options = select.getOptions();
					boolean found = false;
					for (WebElement option : options) {
						String optionValue = option.getAttribute(WebConstants.VALUE);
						if (StringUtils.equals(optionValue, setValue)) {
							/*
							 * WebElement with matching value could be found --> we are finished
							 */
							found = true;
							select.selectByValue(setValue);
							break;
						}
					}

					if (!found) {
						/*
						 * Fallback: look for a WebElement with a matching visible text
						 */
						for (WebElement option : options) {
							String visibleText = option.getText();
							if (StringUtils.equals(visibleText, setValue)) {
								/*
								 * WebElement with matching value could be found --> we are finished
								 */
								found = true;
								select.selectByVisibleText(setValue);
								break;
							}
						}
					}

					if (!found) {
						throw new JFunkException("Could not find a matching option element in " + element + " , By: "
								+ finder.getBy());
					}

				} else if (WebConstants.INPUT.equalsIgnoreCase(element.getTagName())
						&& WebConstants.RADIO.equals(element.getAttribute(WebConstants.TYPE))) {

					List<WebElement> elements = finder.findAll();
					for (WebElement webElement : elements) {
						String elVal = webElement.getAttribute(WebConstants.VALUE);
						if (elVal.equals(setValue) && !webElement.isSelected()) {
							webElement.click();
						}
					}

				} else if (WebConstants.CHECKBOX.equals(element.getAttribute(WebConstants.TYPE))) {

					if (Boolean.valueOf(setValue) && !element.isSelected() || !Boolean.valueOf(setValue) && element.isSelected()) {
						element.click();
					}

				} else {

					if (element.getAttribute("readonly") == null || element.getAttribute("readonly").equals("false")) {
						element.clear();
						element.sendKeys(setValue);
					} else {
						log.warn("Element is invisible or disabled, value cannot be set");
					}

				}
				break;

			case NONE:
				// do nothing
				break;

			default:
				throw new IllegalArgumentException("Unhandled StepMode=" + stepMode);
		}
	}