idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
10,200 | public String resolveExpressionOfEventName ( VariableScope scope ) { if ( isExpressionAvailable ( ) ) { return ( String ) eventName . getValue ( scope ) ; } else { return null ; } } | Resolves the event name within the given scope . |
10,201 | public static AttributeDefinition [ ] getValueTypes ( Object instance , Class clazz ) { try { if ( ObjectTypeAttributeDefinition . class . isAssignableFrom ( clazz ) ) { Field valueTypesField = clazz . getDeclaredField ( "valueTypes" ) ; valueTypesField . setAccessible ( true ) ; Object value = valueTypesField . get ( instance ) ; if ( value != null ) { if ( AttributeDefinition [ ] . class . isAssignableFrom ( value . getClass ( ) ) ) { return ( AttributeDefinition [ ] ) value ; } } return ( AttributeDefinition [ ] ) value ; } } catch ( Exception e ) { throw new RuntimeException ( "Unable to get valueTypes." , e ) ; } return null ; } | Obtain the valueTypes of the ObjectTypeAttributeDefinition through reflection because they are private in Wildfly 8 . |
10,202 | protected void cascadeDeleteProcessInstancesForProcessDefinition ( String processDefinitionId , boolean skipCustomListeners , boolean skipIoMappings ) { getProcessInstanceManager ( ) . deleteProcessInstancesByProcessDefinition ( processDefinitionId , "deleted process definition" , true , skipCustomListeners , skipIoMappings ) ; } | Cascades the deletion of the process definition to the process instances . Skips the custom listeners if the flag was set to true . |
10,203 | protected void cascadeDeleteHistoryForProcessDefinition ( String processDefinitionId ) { getHistoricIncidentManager ( ) . deleteHistoricIncidentsByProcessDefinitionId ( processDefinitionId ) ; getHistoricIdentityLinkManager ( ) . deleteHistoricIdentityLinksLogByProcessDefinitionId ( processDefinitionId ) ; getHistoricJobLogManager ( ) . deleteHistoricJobLogsByProcessDefinitionId ( processDefinitionId ) ; } | Cascades the deletion of a process definition to the history deletes the history . |
10,204 | protected void deleteTimerStartEventsForProcessDefinition ( ProcessDefinition processDefinition ) { List < JobEntity > timerStartJobs = getJobManager ( ) . findJobsByConfiguration ( TimerStartEventJobHandler . TYPE , processDefinition . getKey ( ) , processDefinition . getTenantId ( ) ) ; ProcessDefinitionEntity latestVersion = getProcessDefinitionManager ( ) . findLatestProcessDefinitionByKeyAndTenantId ( processDefinition . getKey ( ) , processDefinition . getTenantId ( ) ) ; if ( latestVersion != null && latestVersion . getId ( ) . equals ( processDefinition . getId ( ) ) ) { for ( Job job : timerStartJobs ) { ( ( JobEntity ) job ) . delete ( ) ; } } } | Deletes the timer start events for the given process definition . |
10,205 | public void deleteSubscriptionsForProcessDefinition ( String processDefinitionId ) { List < EventSubscriptionEntity > eventSubscriptionsToRemove = new ArrayList < EventSubscriptionEntity > ( ) ; List < EventSubscriptionEntity > messageEventSubscriptions = getEventSubscriptionManager ( ) . findEventSubscriptionsByConfiguration ( EventType . MESSAGE . name ( ) , processDefinitionId ) ; eventSubscriptionsToRemove . addAll ( messageEventSubscriptions ) ; List < EventSubscriptionEntity > signalEventSubscriptions = getEventSubscriptionManager ( ) . findEventSubscriptionsByConfiguration ( EventType . SIGNAL . name ( ) , processDefinitionId ) ; eventSubscriptionsToRemove . addAll ( signalEventSubscriptions ) ; List < EventSubscriptionEntity > conditionalEventSubscriptions = getEventSubscriptionManager ( ) . findEventSubscriptionsByConfiguration ( EventType . CONDITONAL . name ( ) , processDefinitionId ) ; eventSubscriptionsToRemove . addAll ( conditionalEventSubscriptions ) ; for ( EventSubscriptionEntity eventSubscriptionEntity : eventSubscriptionsToRemove ) { eventSubscriptionEntity . delete ( ) ; } } | Deletes the subscriptions for the process definition which is identified by the given process definition id . |
10,206 | public void deleteProcessDefinition ( ProcessDefinition processDefinition , String processDefinitionId , boolean cascadeToHistory , boolean cascadeToInstances , boolean skipCustomListeners , boolean skipIoMappings ) { if ( cascadeToHistory ) { cascadeDeleteHistoryForProcessDefinition ( processDefinitionId ) ; if ( cascadeToInstances ) { cascadeDeleteProcessInstancesForProcessDefinition ( processDefinitionId , skipCustomListeners , skipIoMappings ) ; } } else { ProcessInstanceQueryImpl procInstQuery = new ProcessInstanceQueryImpl ( ) . processDefinitionId ( processDefinitionId ) ; long processInstanceCount = getProcessInstanceManager ( ) . findProcessInstanceCountByQueryCriteria ( procInstQuery ) ; if ( processInstanceCount != 0 ) { throw LOG . deleteProcessDefinitionWithProcessInstancesException ( processDefinitionId , processInstanceCount ) ; } } getIdentityLinkManager ( ) . deleteIdentityLinksByProcDef ( processDefinitionId ) ; deleteTimerStartEventsForProcessDefinition ( processDefinition ) ; getDbEntityManager ( ) . delete ( ProcessDefinitionEntity . class , "deleteProcessDefinitionsById" , processDefinitionId ) ; Context . getProcessEngineConfiguration ( ) . getDeploymentCache ( ) . removeProcessDefinition ( processDefinitionId ) ; deleteSubscriptionsForProcessDefinition ( processDefinitionId ) ; getJobDefinitionManager ( ) . deleteJobDefinitionsByProcessDefinitionId ( processDefinition . getId ( ) ) ; } | Deletes the given process definition from the database and cache . If cascadeToHistory and cascadeToInstances is set to true it deletes the history and the process instances . |
10,207 | public void deleteHistoricTaskInstancesByProcessInstanceIds ( List < String > processInstanceIds , boolean deleteVariableInstances ) { CommandContext commandContext = Context . getCommandContext ( ) ; if ( deleteVariableInstances ) { getHistoricVariableInstanceManager ( ) . deleteHistoricVariableInstancesByTaskProcessInstanceIds ( processInstanceIds ) ; } getHistoricDetailManager ( ) . deleteHistoricDetailsByTaskProcessInstanceIds ( processInstanceIds ) ; commandContext . getCommentManager ( ) . deleteCommentsByTaskProcessInstanceIds ( processInstanceIds ) ; getAttachmentManager ( ) . deleteAttachmentsByTaskProcessInstanceIds ( processInstanceIds ) ; getHistoricIdentityLinkManager ( ) . deleteHistoricIdentityLinksLogByTaskProcessInstanceIds ( processInstanceIds ) ; getDbEntityManager ( ) . deletePreserveOrder ( HistoricTaskInstanceEntity . class , "deleteHistoricTaskInstanceByProcessInstanceIds" , processInstanceIds ) ; } | Deletes all data related with tasks which belongs to specified process instance ids . |
10,208 | protected void initCommandExecutorDbSchemaOperations ( ) { if ( commandExecutorSchemaOperations == null ) { List < CommandInterceptor > commandInterceptorsDbSchemaOperations = new ArrayList < CommandInterceptor > ( ) ; commandInterceptorsDbSchemaOperations . add ( new LogInterceptor ( ) ) ; commandInterceptorsDbSchemaOperations . add ( new CommandContextInterceptor ( dbSchemaOperationsCommandContextFactory , this ) ) ; commandInterceptorsDbSchemaOperations . add ( actualCommandExecutor ) ; commandExecutorSchemaOperations = initInterceptorChain ( commandInterceptorsDbSchemaOperations ) ; } } | provide custom command executor that uses NON - JTA transactions |
10,209 | public ScriptEngine getScriptEngineForLanguage ( String language ) { if ( language != null ) { language = language . toLowerCase ( ) ; } ProcessApplicationReference pa = Context . getCurrentProcessApplication ( ) ; ProcessEngineConfigurationImpl config = Context . getProcessEngineConfiguration ( ) ; ScriptEngine engine = null ; if ( config . isEnableFetchScriptEngineFromProcessApplication ( ) ) { if ( pa != null ) { engine = getPaScriptEngine ( language , pa ) ; } } if ( engine == null ) { engine = getGlobalScriptEngine ( language ) ; } return engine ; } | Loads the given script engine by language name . Will throw an exception if no script engine can be loaded for the given language name . |
10,210 | public Bindings createBindings ( ScriptEngine scriptEngine , VariableScope variableScope ) { return scriptBindingsFactory . createBindings ( variableScope , scriptEngine . createBindings ( ) ) ; } | override to build a spring aware ScriptingEngines |
10,211 | public void destroy ( ) { ensureParentInitialized ( ) ; ensureActivityInitialized ( ) ; if ( activity != null && activity . getIoMapping ( ) != null && ! skipIoMapping ) { activity . getIoMapping ( ) . executeOutputParameters ( this ) ; } clearExecution ( ) ; super . destroy ( ) ; removeEventSubscriptionsExceptCompensation ( ) ; } | Method used for destroying a scope in a way that the execution can be removed afterwards . |
10,212 | protected void ensureProcessDefinitionInitialized ( ) { if ( ( processDefinition == null ) && ( processDefinitionId != null ) ) { ProcessDefinitionEntity deployedProcessDefinition = Context . getProcessEngineConfiguration ( ) . getDeploymentCache ( ) . findDeployedProcessDefinitionById ( processDefinitionId ) ; setProcessDefinition ( deployedProcessDefinition ) ; } } | for setting the process definition this setter must be used as subclasses can override |
10,213 | protected void ensureExecutionTreeInitialized ( ) { List < ExecutionEntity > executions = Context . getCommandContext ( ) . getExecutionManager ( ) . findExecutionsByProcessInstanceId ( processInstanceId ) ; ExecutionEntity processInstance = isProcessInstanceExecution ( ) ? this : null ; if ( processInstance == null ) { for ( ExecutionEntity execution : executions ) { if ( execution . isProcessInstanceExecution ( ) ) { processInstance = execution ; } } } processInstance . restoreProcessInstance ( executions , null , null , null , null , null , null ) ; } | Fetch all the executions inside the same process instance as list and then reconstruct the complete execution tree . |
10,214 | @ SuppressWarnings ( "unchecked" ) public < T > List < T > get ( PropertyListKey < T > property ) { if ( contains ( property ) ) { return ( List < T > ) properties . get ( property . getName ( ) ) ; } else { return new ArrayList < T > ( ) ; } } | Returns the list to which the specified property key is mapped or an empty list if this properties contains no mapping for the property key . Note that the empty list is not mapped to the property key . |
10,215 | @ SuppressWarnings ( "unchecked" ) public < K , V > Map < K , V > get ( PropertyMapKey < K , V > property ) { if ( contains ( property ) ) { return ( Map < K , V > ) properties . get ( property . getName ( ) ) ; } else { return new HashMap < K , V > ( ) ; } } | Returns the map to which the specified property key is mapped or an empty map if this properties contains no mapping for the property key . Note that the empty map is not mapped to the property key . |
10,216 | public < T > void set ( PropertyKey < T > property , T value ) { properties . put ( property . getName ( ) , value ) ; } | Associates the specified value with the specified property key . If the properties previously contained a mapping for the property key the old value is replaced by the specified value . |
10,217 | public < T > void set ( PropertyListKey < T > property , List < T > value ) { properties . put ( property . getName ( ) , value ) ; } | Associates the specified list with the specified property key . If the properties previously contained a mapping for the property key the old value is replaced by the specified list . |
10,218 | public < K , V > void set ( PropertyMapKey < K , V > property , Map < K , V > value ) { properties . put ( property . getName ( ) , value ) ; } | Associates the specified map with the specified property key . If the properties previously contained a mapping for the property key the old value is replaced by the specified map . |
10,219 | public < T > void addListItem ( PropertyListKey < T > property , T value ) { List < T > list = get ( property ) ; list . add ( value ) ; if ( ! contains ( property ) ) { set ( property , list ) ; } } | Append the value to the list to which the specified property key is mapped . If this properties contains no mapping for the property key the value append to a new list witch is associate the the specified property key . |
10,220 | public < K , V > void putMapEntry ( PropertyMapKey < K , V > property , K key , V value ) { Map < K , V > map = get ( property ) ; if ( ! property . allowsOverwrite ( ) && map . containsKey ( key ) ) { throw new ProcessEngineException ( "Cannot overwrite property key " + key + ". Key already exists" ) ; } map . put ( key , value ) ; if ( ! contains ( property ) ) { set ( property , map ) ; } } | Insert the value to the map to which the specified property key is mapped . If this properties contains no mapping for the property key the value insert to a new map witch is associate the the specified property key . |
10,221 | protected void checkJavaSerialization ( String variableName , TypedValue value ) { ProcessEngineConfigurationImpl processEngineConfiguration = Context . getProcessEngineConfiguration ( ) ; if ( value instanceof SerializableValue && ! processEngineConfiguration . isJavaSerializationFormatEnabled ( ) ) { SerializableValue serializableValue = ( SerializableValue ) value ; if ( ! serializableValue . isDeserialized ( ) ) { String javaSerializationDataFormat = Variables . SerializationDataFormats . JAVA . getName ( ) ; String requestedDataFormat = serializableValue . getSerializationDataFormat ( ) ; if ( requestedDataFormat == null ) { final TypedValueSerializer serializerForValue = TypedValueField . getSerializers ( ) . findSerializerForValue ( serializableValue , processEngineConfiguration . getFallbackSerializerFactory ( ) ) ; if ( serializerForValue != null ) { requestedDataFormat = serializerForValue . getSerializationDataformat ( ) ; } } if ( javaSerializationDataFormat . equals ( requestedDataFormat ) ) { throw ProcessEngineLogger . CORE_LOGGER . javaSerializationProhibitedException ( variableName ) ; } } } } | Checks if Java serialization will be used and if it is allowed to be used . |
10,222 | public static boolean isArrayByteBase64 ( byte [ ] arrayOctet ) { for ( int i = 0 ; i < arrayOctet . length ; i ++ ) { if ( ! isBase64 ( arrayOctet [ i ] ) && ! isWhiteSpace ( arrayOctet [ i ] ) ) { return false ; } } return true ; } | Tests a given byte array to see if it contains only valid characters within the Base64 alphabet . Currently the method treats whitespace as valid . |
10,223 | protected ProcessApplicationInterface lookupSelfReference ( ) { try { InitialContext ic = new InitialContext ( ) ; SessionContext sctxLookup = ( SessionContext ) ic . lookup ( EJB_CONTEXT_PATH ) ; return sctxLookup . getBusinessObject ( getBusinessInterface ( ) ) ; } catch ( NamingException e ) { throw LOG . ejbPaCannotLookupSelfReference ( e ) ; } } | lookup a proxy object representing the invoked business view of this component . |
10,224 | protected String lookupEeApplicationName ( ) { try { InitialContext initialContext = new InitialContext ( ) ; String appName = ( String ) initialContext . lookup ( JAVA_APP_APP_NAME_PATH ) ; String moduleName = ( String ) initialContext . lookup ( MODULE_NAME_PATH ) ; if ( moduleName != null && ! moduleName . equals ( appName ) ) { return appName + "/" + moduleName ; } else { return appName ; } } catch ( NamingException e ) { throw LOG . ejbPaCannotAutodetectName ( e ) ; } } | determine the ee application name based on information obtained from JNDI . |
10,225 | public CoreActivity findActivity ( String activityId ) { CoreActivity localActivity = getChildActivity ( activityId ) ; if ( localActivity != null ) { return localActivity ; } for ( CoreActivity activity : getActivities ( ) ) { CoreActivity nestedActivity = activity . findActivity ( activityId ) ; if ( nestedActivity != null ) { return nestedActivity ; } } return null ; } | searches for the activity recursively |
10,226 | protected static boolean checkDiagram ( String fileName , String modelFileName , String [ ] diagramSuffixes , String [ ] modelSuffixes ) { for ( String modelSuffix : modelSuffixes ) { if ( modelFileName . endsWith ( modelSuffix ) ) { String caseFilePrefix = modelFileName . substring ( 0 , modelFileName . length ( ) - modelSuffix . length ( ) ) ; if ( fileName . startsWith ( caseFilePrefix ) ) { for ( String diagramResourceSuffix : diagramSuffixes ) { if ( fileName . endsWith ( diagramResourceSuffix ) ) { return true ; } } } } } return false ; } | Checks whether a filename is a diagram for the given modelFileName . |
10,227 | protected String extractEngineName ( String requestUrl ) { Matcher matcher = ENGINE_REQUEST_URL_PATTERN . matcher ( requestUrl ) ; if ( matcher . find ( ) ) { return matcher . group ( 1 ) ; } else { return DEFAULT_ENGINE_NAME ; } } | May not return null |
10,228 | public static Element findCamundaExtensionElement ( Element element , String extensionElementName ) { Element extensionElements = element . element ( "extensionElements" ) ; if ( extensionElements != null ) { return extensionElements . elementNS ( BpmnParse . CAMUNDA_BPMN_EXTENSIONS_NS , extensionElementName ) ; } else { return null ; } } | Returns the camunda extension element in the camunda namespace and the given name . |
10,229 | public static ExecutableScript parseCamundaScript ( Element scriptElement ) { String scriptLanguage = scriptElement . attribute ( "scriptFormat" ) ; if ( scriptLanguage == null || scriptLanguage . isEmpty ( ) ) { throw new BpmnParseException ( "Missing attribute 'scriptFormatAttribute' for 'script' element" , scriptElement ) ; } else { String scriptResource = scriptElement . attribute ( "resource" ) ; String scriptSource = scriptElement . getText ( ) ; try { return ScriptUtil . getScript ( scriptLanguage , scriptSource , scriptResource , getExpressionManager ( ) ) ; } catch ( ProcessEngineException e ) { throw new BpmnParseException ( "Unable to process script" , scriptElement , e ) ; } } } | Parses a camunda script element . |
10,230 | protected List < EventSubscriptionEntity > filterSubscriptionsOfDifferentType ( EventSubscriptionDeclaration eventSubscription , List < EventSubscriptionEntity > subscriptionsForSameMessageName ) { ArrayList < EventSubscriptionEntity > filteredSubscriptions = new ArrayList < EventSubscriptionEntity > ( subscriptionsForSameMessageName ) ; for ( EventSubscriptionEntity subscriptionEntity : new ArrayList < EventSubscriptionEntity > ( subscriptionsForSameMessageName ) ) { if ( isSubscriptionOfDifferentTypeAsDeclaration ( subscriptionEntity , eventSubscription ) ) { filteredSubscriptions . remove ( subscriptionEntity ) ; } } return filteredSubscriptions ; } | It is possible to deploy a process containing a start and intermediate message event that wait for the same message or to have two processes one with a message start event and the other one with a message intermediate event that subscribe for the same message . Therefore we have to find out if there are subscriptions for the other type of event and remove those . |
10,231 | public void setFunction ( String prefix , String localName , Method method ) { if ( functions == null ) { functions = new Functions ( ) ; } functions . setFunction ( prefix , localName , method ) ; } | Define a function . |
10,232 | public ValueExpression setVariable ( String name , ValueExpression expression ) { if ( variables == null ) { variables = new Variables ( ) ; } return variables . setVariable ( name , expression ) ; } | Define a variable . |
10,233 | public boolean isCompensationHandler ( ) { Boolean isForCompensation = ( Boolean ) getProperty ( BpmnParse . PROPERTYNAME_IS_FOR_COMPENSATION ) ; return Boolean . TRUE . equals ( isForCompensation ) ; } | Indicates whether activity is for compensation . |
10,234 | public ActivityImpl findCompensationHandler ( ) { String compensationHandlerId = ( String ) getProperty ( BpmnParse . PROPERTYNAME_COMPENSATION_HANDLER_ID ) ; if ( compensationHandlerId != null ) { return getProcessDefinition ( ) . findActivity ( compensationHandlerId ) ; } else { return null ; } } | Find the compensation handler of this activity . |
10,235 | public boolean isMultiInstance ( ) { Boolean isMultiInstance = ( Boolean ) getProperty ( BpmnParse . PROPERTYNAME_IS_MULTI_INSTANCE ) ; return Boolean . TRUE . equals ( isMultiInstance ) ; } | Indicates whether activity is a multi instance activity . |
10,236 | protected DbEntity cacheFilter ( DbEntity persistentObject ) { DbEntity cachedPersistentObject = dbEntityCache . get ( persistentObject . getClass ( ) , persistentObject . getId ( ) ) ; if ( cachedPersistentObject != null ) { return cachedPersistentObject ; } else { return persistentObject ; } } | returns the object in the cache . if this object was loaded before then the original object is returned . |
10,237 | private DbOperation hasOptimisticLockingException ( List < DbOperation > operationsToFlush , Throwable cause ) { BatchExecutorException batchExecutorException = ExceptionUtil . findBatchExecutorException ( cause ) ; if ( batchExecutorException != null ) { int failedOperationIndex = batchExecutorException . getSuccessfulBatchResults ( ) . size ( ) ; if ( failedOperationIndex < operationsToFlush . size ( ) ) { DbOperation failedOperation = operationsToFlush . get ( failedOperationIndex ) ; if ( isOptimisticLockingException ( failedOperation , cause ) ) { return failedOperation ; } } } return null ; } | An OptimisticLockingException check for batch processing |
10,238 | public Object getValue ( ELContext context , Object base , Object property ) { if ( context == null ) { throw new NullPointerException ( ) ; } Object result = null ; if ( isResolvable ( base ) ) { Method method = toBeanProperty ( base , property ) . getReadMethod ( ) ; if ( method == null ) { throw new PropertyNotFoundException ( "Cannot read property " + property ) ; } try { result = method . invoke ( base ) ; } catch ( InvocationTargetException e ) { throw new ELException ( e . getCause ( ) ) ; } catch ( Exception e ) { throw new ELException ( e ) ; } context . setPropertyResolved ( true ) ; } return result ; } | If the base object is not null returns the current value of the given property on this bean . If the base is not null the propertyResolved property of the ELContext object must be set to true by this resolver before returning . If this property is not true after this method is called the caller should ignore the return value . The provided property name will first be coerced to a String . If the property is a readable property of the base object as per the JavaBeans specification then return the result of the getter call . If the getter throws an exception it is propagated to the caller . If the property is not found or is not readable a PropertyNotFoundException is thrown . |
10,239 | protected boolean supportsConcurrentChildInstantiation ( ScopeImpl flowScope ) { CoreActivityBehavior < ? > behavior = flowScope . getActivityBehavior ( ) ; return behavior == null || ! ( behavior instanceof SequentialMultiInstanceActivityBehavior ) ; } | Cannot create more than inner instance in a sequential MI construct |
10,240 | public void startTaskForm ( ) { Map < String , String > requestParameterMap = FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getRequestParameterMap ( ) ; String taskId = requestParameterMap . get ( "taskId" ) ; String callbackUrl = requestParameterMap . get ( "callbackUrl" ) ; if ( taskId == null || callbackUrl == null ) { if ( FacesContext . getCurrentInstance ( ) . isPostback ( ) ) { return ; } log . log ( Level . INFO , "Called startTask method without proper parameter (taskId='" + taskId + "'; callbackUrl='" + callbackUrl + "') even if it seems we are not called by an AJAX Postback. Are you using the camundaTaskForm bean correctly?" ) ; return ; } this . url = callbackUrl ; businessProcess . startTask ( taskId , true ) ; } | Get taskId and callBackUrl from request and start a conversation to start the form |
10,241 | public void startProcessInstanceByIdForm ( ) { if ( FacesContext . getCurrentInstance ( ) . isPostback ( ) ) { return ; } Map < String , String > requestParameterMap = FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getRequestParameterMap ( ) ; String processDefinitionId = requestParameterMap . get ( "processDefinitionId" ) ; String callbackUrl = requestParameterMap . get ( "callbackUrl" ) ; this . url = callbackUrl ; this . processDefinitionId = processDefinitionId ; beginConversation ( ) ; } | Get processDefinitionId and callbackUrl from request and start a conversation to start the form |
10,242 | public void startProcessInstanceByKeyForm ( ) { if ( FacesContext . getCurrentInstance ( ) . isPostback ( ) ) { return ; } Map < String , String > requestParameterMap = FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getRequestParameterMap ( ) ; String processDefinitionKey = requestParameterMap . get ( "processDefinitionKey" ) ; String callbackUrl = requestParameterMap . get ( "callbackUrl" ) ; this . url = callbackUrl ; this . processDefinitionKey = processDefinitionKey ; beginConversation ( ) ; } | Get processDefinitionKey and callbackUrl from request and start a conversation to start the form |
10,243 | public Object getValue ( ELContext context , Object base , Object property ) { if ( context == null ) { throw new NullPointerException ( "context is null" ) ; } Object result = null ; if ( isResolvable ( base ) ) { if ( property != null ) { try { result = ( ( ResourceBundle ) base ) . getObject ( property . toString ( ) ) ; } catch ( MissingResourceException e ) { result = "???" + property + "???" ; } } context . setPropertyResolved ( true ) ; } return result ; } | If the base object is an instance of ResourceBundle the provided property will first be coerced to a String . The Object returned by getObject on the base ResourceBundle will be returned . If the base is ResourceBundle the propertyResolved property of the ELContext object must be set to true by this resolver before returning . If this property is not true after this method is called the caller should ignore the return value . |
10,244 | @ SuppressWarnings ( "unchecked" ) public < T extends DbEntity > T get ( Class < T > type , String id ) { Class < ? > cacheKey = cacheKeyMapping . getEntityCacheKey ( type ) ; CachedDbEntity cachedDbEntity = getCachedEntity ( cacheKey , id ) ; if ( cachedDbEntity != null ) { DbEntity dbEntity = cachedDbEntity . getEntity ( ) ; try { return ( T ) dbEntity ; } catch ( ClassCastException e ) { throw LOG . entityCacheLookupException ( type , id , dbEntity . getClass ( ) , e ) ; } } else { return null ; } } | get an object from the cache |
10,245 | public CachedDbEntity getCachedEntity ( Class < ? > type , String id ) { Class < ? > cacheKey = cacheKeyMapping . getEntityCacheKey ( type ) ; Map < String , CachedDbEntity > entitiesByType = cachedEntites . get ( cacheKey ) ; if ( entitiesByType != null ) { return entitiesByType . get ( id ) ; } else { return null ; } } | Looks up an entity in the cache . |
10,246 | public boolean remove ( DbEntity e ) { Class < ? > cacheKey = cacheKeyMapping . getEntityCacheKey ( e . getClass ( ) ) ; Map < String , CachedDbEntity > typeMap = cachedEntites . get ( cacheKey ) ; if ( typeMap != null ) { return typeMap . remove ( e . getId ( ) ) != null ; } else { return false ; } } | Remove an entity from the cache |
10,247 | public boolean isDeleted ( DbEntity dbEntity ) { CachedDbEntity cachedDbEntity = getCachedEntity ( dbEntity ) ; if ( cachedDbEntity == null ) { return false ; } else { return cachedDbEntity . getEntityState ( ) == DELETED_MERGED || cachedDbEntity . getEntityState ( ) == DELETED_PERSISTENT || cachedDbEntity . getEntityState ( ) == DELETED_TRANSIENT ; } } | Allows checking whether the provided entity is present in the cache and is marked to be deleted . |
10,248 | public void setDeleted ( DbEntity dbEntity ) { CachedDbEntity cachedEntity = getCachedEntity ( dbEntity ) ; if ( cachedEntity != null ) { if ( cachedEntity . getEntityState ( ) == TRANSIENT ) { cachedEntity . setEntityState ( DELETED_TRANSIENT ) ; } else if ( cachedEntity . getEntityState ( ) == PERSISTENT ) { cachedEntity . setEntityState ( DELETED_PERSISTENT ) ; } else if ( cachedEntity . getEntityState ( ) == MERGED ) { cachedEntity . setEntityState ( DELETED_MERGED ) ; } } else { CachedDbEntity cachedDbEntity = new CachedDbEntity ( ) ; cachedDbEntity . setEntity ( dbEntity ) ; cachedDbEntity . setEntityState ( DELETED_MERGED ) ; putInternal ( cachedDbEntity ) ; } } | Sets an object to a deleted state . It will not be removed from the cache but transition to one of the DELETED states depending on it s current state . |
10,249 | @ SuppressWarnings ( "unchecked" ) public List < EventSubscriptionEntity > findSignalEventSubscriptionsByEventName ( String eventName ) { final String query = "selectSignalEventSubscriptionsByEventName" ; Set < EventSubscriptionEntity > eventSubscriptions = new HashSet < EventSubscriptionEntity > ( getDbEntityManager ( ) . selectList ( query , configureParameterizedQuery ( eventName ) ) ) ; for ( EventSubscriptionEntity entity : createdSignalSubscriptions ) { if ( eventName . equals ( entity . getEventName ( ) ) ) { eventSubscriptions . add ( entity ) ; } } return new ArrayList < EventSubscriptionEntity > ( eventSubscriptions ) ; } | Find all signal event subscriptions with the given event name for any tenant . |
10,250 | @ SuppressWarnings ( "unchecked" ) public List < EventSubscriptionEntity > findSignalEventSubscriptionsByEventNameAndTenantId ( String eventName , String tenantId ) { final String query = "selectSignalEventSubscriptionsByEventNameAndTenantId" ; Map < String , Object > parameter = new HashMap < String , Object > ( ) ; parameter . put ( "eventName" , eventName ) ; parameter . put ( "tenantId" , tenantId ) ; Set < EventSubscriptionEntity > eventSubscriptions = new HashSet < EventSubscriptionEntity > ( getDbEntityManager ( ) . selectList ( query , parameter ) ) ; for ( EventSubscriptionEntity entity : createdSignalSubscriptions ) { if ( eventName . equals ( entity . getEventName ( ) ) && hasTenantId ( entity , tenantId ) ) { eventSubscriptions . add ( entity ) ; } } return new ArrayList < EventSubscriptionEntity > ( eventSubscriptions ) ; } | Find all signal event subscriptions with the given event name and tenant . |
10,251 | public static URI urlToURI ( URL url ) { try { return url . toURI ( ) ; } catch ( URISyntaxException e ) { throw LOG . cannotConvertUrlToUri ( url , e ) ; } } | Converts an url to an uri . Escapes whitespaces if needed . |
10,252 | public static Field getField ( String fieldName , Class < ? > clazz ) { Field field = null ; try { field = clazz . getDeclaredField ( fieldName ) ; } catch ( SecurityException e ) { throw LOG . unableToAccessField ( field , clazz . getName ( ) ) ; } catch ( NoSuchFieldException e ) { Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null ) { return getField ( fieldName , superClass ) ; } } return field ; } | Returns the field of the given class or null if it doesnt exist . |
10,253 | public static Method getSingleSetter ( String fieldName , Class < ? > clazz ) { String setterName = buildSetterName ( fieldName ) ; try { Method [ ] methods = clazz . getMethods ( ) ; List < Method > candidates = new ArrayList < Method > ( ) ; Set < Class < ? > > parameterTypes = new HashSet < Class < ? > > ( ) ; for ( Method method : methods ) { if ( method . getName ( ) . equals ( setterName ) ) { Class < ? > [ ] paramTypes = method . getParameterTypes ( ) ; if ( paramTypes != null && paramTypes . length == 1 ) { candidates . add ( method ) ; parameterTypes . add ( paramTypes [ 0 ] ) ; } } } if ( parameterTypes . size ( ) > 1 ) { throw LOG . ambiguousSetterMethod ( setterName , clazz . getName ( ) ) ; } if ( candidates . size ( ) >= 1 ) { return candidates . get ( 0 ) ; } return null ; } catch ( SecurityException e ) { throw LOG . unableToAccessMethod ( setterName , clazz . getName ( ) ) ; } } | Returns a setter method based on the fieldName and the java beans setter naming convention or null if none exists . If multiple setters with different parameter types are present an exception is thrown . If they have the same parameter type one of those methods is returned . |
10,254 | public static Method getMethod ( Class < ? > declaringType , String methodName , Class < ? > ... parameterTypes ) { return findMethod ( declaringType , methodName , parameterTypes ) ; } | Finds a method by name and parameter types . |
10,255 | public static LockedExternalTaskImpl fromEntity ( ExternalTaskEntity externalTaskEntity , List < String > variablesToFetch , boolean isLocal , boolean deserializeVariables ) { LockedExternalTaskImpl result = new LockedExternalTaskImpl ( ) ; result . id = externalTaskEntity . getId ( ) ; result . topicName = externalTaskEntity . getTopicName ( ) ; result . workerId = externalTaskEntity . getWorkerId ( ) ; result . lockExpirationTime = externalTaskEntity . getLockExpirationTime ( ) ; result . retries = externalTaskEntity . getRetries ( ) ; result . errorMessage = externalTaskEntity . getErrorMessage ( ) ; result . errorDetails = externalTaskEntity . getErrorDetails ( ) ; result . processInstanceId = externalTaskEntity . getProcessInstanceId ( ) ; result . executionId = externalTaskEntity . getExecutionId ( ) ; result . activityId = externalTaskEntity . getActivityId ( ) ; result . activityInstanceId = externalTaskEntity . getActivityInstanceId ( ) ; result . processDefinitionId = externalTaskEntity . getProcessDefinitionId ( ) ; result . processDefinitionKey = externalTaskEntity . getProcessDefinitionKey ( ) ; result . tenantId = externalTaskEntity . getTenantId ( ) ; result . priority = externalTaskEntity . getPriority ( ) ; result . businessKey = externalTaskEntity . getBusinessKey ( ) ; ExecutionEntity execution = externalTaskEntity . getExecution ( ) ; result . variables = new VariableMapImpl ( ) ; execution . collectVariables ( result . variables , variablesToFetch , isLocal , deserializeVariables ) ; return result ; } | Construct representation of locked ExternalTask from corresponding entity . During mapping variables will be collected during collection variables will not be deserialized and scope will not be set to local . |
10,256 | public static void addServerExecutorDependency ( ServiceBuilder < ? > serviceBuilder , InjectedValue < ExecutorService > injector , boolean optional ) { ServiceBuilder . DependencyType type = optional ? ServiceBuilder . DependencyType . OPTIONAL : ServiceBuilder . DependencyType . REQUIRED ; serviceBuilder . addDependency ( type , JBOSS_SERVER_EXECUTOR , ExecutorService . class , injector ) ; } | Adds the JBoss server executor as a dependency to the given service . Copied from org . jboss . as . server . Services - JBoss 7 . 2 . 0 . Final |
10,257 | protected String checkForMariaDb ( DatabaseMetaData databaseMetaData , String databaseName ) { try { String databaseProductVersion = databaseMetaData . getDatabaseProductVersion ( ) ; if ( databaseProductVersion != null && databaseProductVersion . toLowerCase ( ) . contains ( "mariadb" ) ) { return MARIA_DB_PRODUCT_NAME ; } } catch ( SQLException ignore ) { } try { String driverName = databaseMetaData . getDriverName ( ) ; if ( driverName != null && driverName . toLowerCase ( ) . contains ( "mariadb" ) ) { return MARIA_DB_PRODUCT_NAME ; } } catch ( SQLException ignore ) { } String metaDataClassName = databaseMetaData . getClass ( ) . getName ( ) ; if ( metaDataClassName != null && metaDataClassName . toLowerCase ( ) . contains ( "mariadb" ) ) { return MARIA_DB_PRODUCT_NAME ; } return databaseName ; } | The product name of mariadb is still MySQL . This method tries if it can find some evidence for mariadb . If it is successful it will return MariaDB otherwise the provided database name . |
10,258 | protected void ensurePrefixAndSchemaFitToegether ( String prefix , String schema ) { if ( schema == null ) { return ; } else if ( prefix == null || ( prefix != null && ! prefix . startsWith ( schema + "." ) ) ) { throw new ProcessEngineException ( "When setting a schema the prefix has to be schema + '.'. Received schema: " + schema + " prefix: " + prefix ) ; } } | When providing a schema and a prefix the prefix has to be the schema ending with a dot . |
10,259 | public void propagateBpmnError ( BpmnError error , ActivityExecution execution ) throws Exception { super . propagateBpmnError ( error , execution ) ; } | Overrides the propagateBpmnError method to made it public . Is used to propagate the bpmn error from an external task . |
10,260 | public void associateExecutionById ( String executionId ) { Execution execution = processEngine . getRuntimeService ( ) . createExecutionQuery ( ) . executionId ( executionId ) . singleResult ( ) ; if ( execution == null ) { throw new ProcessEngineCdiException ( "Cannot associate execution by id: no execution with id '" + executionId + "' found." ) ; } associationManager . setExecution ( execution ) ; } | Associate with the provided execution . This starts a unit of work . |
10,261 | public void saveTask ( ) { assertCommandContextNotActive ( ) ; assertTaskAssociated ( ) ; final Task task = getTask ( ) ; processEngine . getTaskService ( ) . saveTask ( task ) ; } | Save the currently associated task . |
10,262 | public String getProcessInstanceId ( ) { Execution execution = associationManager . getExecution ( ) ; return execution != null ? execution . getProcessInstanceId ( ) : null ; } | Returns the id of the currently associated process instance or null |
10,263 | public String getTaskId ( ) { Task task = getTask ( ) ; return task != null ? task . getId ( ) : null ; } | Returns the id of the task associated with the current conversation or null . |
10,264 | protected Task getTaskById ( String id ) { return engine . getTaskService ( ) . createTaskQuery ( ) . taskId ( id ) . initializeFormKeys ( ) . singleResult ( ) ; } | Returns the task with the given id |
10,265 | public void failed ( String errorMessage , String errorDetails , int retries , long retryDuration ) { ensureActive ( ) ; this . setErrorMessage ( errorMessage ) ; if ( errorDetails != null ) { setErrorDetails ( errorDetails ) ; } this . lockExpirationTime = new Date ( ClockUtil . getCurrentTime ( ) . getTime ( ) + retryDuration ) ; setRetriesAndManageIncidents ( retries ) ; produceHistoricExternalTaskFailedEvent ( ) ; } | process failed state make sure that binary entity is created for the errorMessage shortError message does not exceed limit handle properly retry counts and incidents |
10,266 | protected void addSortedModifications ( List < DbOperation > flush ) { SortedSet < Class < ? > > modifiedEntityTypes = new TreeSet < Class < ? > > ( MODIFICATION_TYPE_COMPARATOR ) ; modifiedEntityTypes . addAll ( updates . keySet ( ) ) ; modifiedEntityTypes . addAll ( deletes . keySet ( ) ) ; modifiedEntityTypes . addAll ( bulkOperations . keySet ( ) ) ; for ( Class < ? > type : modifiedEntityTypes ) { addSortedModificationsForType ( type , updates . get ( type ) , flush ) ; addSortedModificationsForType ( type , deletes . get ( type ) , flush ) ; SortedSet < DbBulkOperation > bulkOperationsForType = bulkOperations . get ( type ) ; if ( bulkOperationsForType != null ) { flush . addAll ( bulkOperationsForType ) ; } } if ( bulkOperationsInsertionOrder != null ) { flush . addAll ( bulkOperationsInsertionOrder ) ; } } | Adds a correctly ordered list of UPDATE and DELETE operations to the flush . |
10,267 | public void createLink ( HalRelation rel , String ... pathParams ) { if ( pathParams != null && pathParams . length > 0 && pathParams [ 0 ] != null ) { Set < String > linkedResourceIds = linkedResources . get ( rel ) ; if ( linkedResourceIds == null ) { linkedResourceIds = new HashSet < String > ( ) ; linkedResources . put ( rel , linkedResourceIds ) ; } linkedResourceIds . add ( pathParams [ pathParams . length - 1 ] ) ; resource . addLink ( rel . relName , rel . uriTemplate . build ( ( Object [ ] ) pathParams ) ) ; } } | Creates a link in a given relation . |
10,268 | public List < HalResource < ? > > resolve ( HalRelation relation , ProcessEngine processEngine ) { HalLinkResolver linkResolver = hal . getLinkResolver ( relation . resourceType ) ; if ( linkResolver != null ) { Set < String > linkedIds = getLinkedResourceIdsByRelation ( relation ) ; if ( ! linkedIds . isEmpty ( ) ) { return linkResolver . resolveLinks ( linkedIds . toArray ( new String [ linkedIds . size ( ) ] ) , processEngine ) ; } else { return Collections . emptyList ( ) ; } } else { throw new RuntimeException ( "Cannot find HAL link resolver for resource type '" + relation . resourceType + "'." ) ; } } | Resolves a relation . Locates a HalLinkResolver for resolving the set of all linked resources in the relation . |
10,269 | public void mergeLinks ( HalResource < ? > embedded ) { for ( Entry < HalRelation , Set < String > > linkentry : embedded . linker . linkedResources . entrySet ( ) ) { Set < String > linkedIdSet = linkedResources . get ( linkentry . getKey ( ) ) ; if ( linkedIdSet != null ) { linkedIdSet . addAll ( linkentry . getValue ( ) ) ; } else { linkedResources . put ( linkentry . getKey ( ) , linkentry . getValue ( ) ) ; } } } | merge the links of an embedded resource into this linker . This is useful when building resources which are actually resource collections . You can then merge the relations of all resources in the collection and the unique the set of linked resources to embed . |
10,270 | protected boolean isLeaf ( ExecutionEntity execution ) { if ( CompensationBehavior . isCompensationThrowing ( execution ) ) { return true ; } else { return ! execution . isEventScope ( ) && execution . getNonEventScopeExecutions ( ) . isEmpty ( ) ; } } | event - scope executions are not considered in this mapping and must be ignored |
10,271 | public static byte [ ] toByteArray ( String string ) { EnsureUtil . ensureActiveCommandContext ( "StringUtil.toByteArray" ) ; ProcessEngineConfigurationImpl processEngineConfiguration = Context . getProcessEngineConfiguration ( ) ; return toByteArray ( string , processEngineConfiguration . getProcessEngine ( ) ) ; } | Gets the bytes from a string using the current process engine s default charset |
10,272 | public static byte [ ] toByteArray ( String string , ProcessEngine processEngine ) { ProcessEngineConfigurationImpl processEngineConfiguration = ( ( ProcessEngineImpl ) processEngine ) . getProcessEngineConfiguration ( ) ; Charset charset = processEngineConfiguration . getDefaultCharset ( ) ; return string . getBytes ( charset ) ; } | Gets the bytes from a string using the provided process engine s default charset |
10,273 | public static ByteArrayEntity createExceptionByteArray ( String name , byte [ ] byteArray , ResourceType type ) { ByteArrayEntity result = null ; if ( byteArray != null ) { result = new ByteArrayEntity ( name , byteArray , type ) ; Context . getCommandContext ( ) . getByteArrayManager ( ) . insertByteArray ( result ) ; } return result ; } | create ByteArrayEntity with specified name and payload and make sure it s persisted |
10,274 | public void updateModifiableFieldsFromEntity ( DecisionDefinitionEntity updatingDecisionDefinition ) { if ( this . key . equals ( updatingDecisionDefinition . key ) && this . deploymentId . equals ( updatingDecisionDefinition . deploymentId ) ) { this . revision = updatingDecisionDefinition . revision ; this . historyTimeToLive = updatingDecisionDefinition . historyTimeToLive ; } else { LOG . logUpdateUnrelatedDecisionDefinitionEntity ( this . key , updatingDecisionDefinition . key , this . deploymentId , updatingDecisionDefinition . deploymentId ) ; } } | Updates all modifiable fields from another decision definition entity . |
10,275 | protected void migrateProcessInstance ( MigratingProcessInstance migratingProcessInstance ) { MigratingActivityInstance rootActivityInstance = migratingProcessInstance . getRootInstance ( ) ; MigratingProcessElementInstanceTopDownWalker walker = new MigratingProcessElementInstanceTopDownWalker ( rootActivityInstance ) ; walker . addPreVisitor ( new MigratingActivityInstanceVisitor ( executionBuilder . isSkipCustomListeners ( ) , executionBuilder . isSkipIoMappings ( ) ) ) ; walker . addPreVisitor ( new MigrationCompensationInstanceVisitor ( ) ) ; walker . walkUntil ( ) ; } | Migrate activity instances to their new activities and process definition . Creates new scope instances as necessary . |
10,276 | public Map < String , List < VariableListener < ? > > > getVariableListeners ( String eventName , boolean includeCustomListeners ) { Map < String , Map < String , List < VariableListener < ? > > > > listenerCache ; if ( includeCustomListeners ) { if ( resolvedVariableListeners == null ) { resolvedVariableListeners = new HashMap < String , Map < String , List < VariableListener < ? > > > > ( ) ; } listenerCache = resolvedVariableListeners ; } else { if ( resolvedBuiltInVariableListeners == null ) { resolvedBuiltInVariableListeners = new HashMap < String , Map < String , List < VariableListener < ? > > > > ( ) ; } listenerCache = resolvedBuiltInVariableListeners ; } Map < String , List < VariableListener < ? > > > resolvedListenersForEvent = listenerCache . get ( eventName ) ; if ( resolvedListenersForEvent == null ) { resolvedListenersForEvent = new HashMap < String , List < VariableListener < ? > > > ( ) ; listenerCache . put ( eventName , resolvedListenersForEvent ) ; CmmnActivity currentActivity = this ; while ( currentActivity != null ) { List < VariableListener < ? > > localListeners = null ; if ( includeCustomListeners ) { localListeners = currentActivity . getVariableListenersLocal ( eventName ) ; } else { localListeners = currentActivity . getBuiltInVariableListenersLocal ( eventName ) ; } if ( localListeners != null && ! localListeners . isEmpty ( ) ) { resolvedListenersForEvent . put ( currentActivity . getId ( ) , localListeners ) ; } currentActivity = currentActivity . getParent ( ) ; } } return resolvedListenersForEvent ; } | Returns a map of all variable listeners defined on this activity or any of its parents activities . The map s key is the id of the respective activity the listener is defined on . |
10,277 | public static Object convertToClass ( String value , Class < ? > clazz ) { Object propertyValue ; if ( clazz . isAssignableFrom ( int . class ) ) { propertyValue = Integer . parseInt ( value ) ; } else if ( clazz . isAssignableFrom ( long . class ) ) { propertyValue = Long . parseLong ( value ) ; } else if ( clazz . isAssignableFrom ( float . class ) ) { propertyValue = Float . parseFloat ( value ) ; } else if ( clazz . isAssignableFrom ( boolean . class ) ) { propertyValue = Boolean . parseBoolean ( value ) ; } else { propertyValue = value ; } return propertyValue ; } | Converts a value to the type of the given field . |
10,278 | public static void applyProperties ( Object configuration , Map < String , String > properties ) { for ( Map . Entry < String , String > property : properties . entrySet ( ) ) { applyProperty ( configuration , property . getKey ( ) , property . getValue ( ) ) ; } } | Sets an objects fields via reflection from String values . Depending on the field s type the respective values are converted to int or boolean . |
10,279 | protected void loadChildExecutionsFromCache ( ExecutionEntity execution , List < ExecutionEntity > childExecutions ) { List < ExecutionEntity > childrenOfThisExecution = execution . getExecutions ( ) ; if ( childrenOfThisExecution != null ) { childExecutions . addAll ( childrenOfThisExecution ) ; for ( ExecutionEntity child : childrenOfThisExecution ) { loadChildExecutionsFromCache ( child , childExecutions ) ; } } } | Loads all executions that are part of this process instance tree from the dbSqlSession cache . ( optionally querying the db if a child is not already loaded . |
10,280 | @ SuppressWarnings ( "unchecked" ) public T embed ( HalRelation relation , ProcessEngine processEngine ) { List < HalResource < ? > > resolvedLinks = linker . resolve ( relation , processEngine ) ; if ( resolvedLinks != null && resolvedLinks . size ( ) > 0 ) { addEmbedded ( relation . relName , resolvedLinks ) ; } return ( T ) this ; } | Can be used to embed a relation . Embedded all linked resources in the given relation . |
10,281 | private static OptimisticLockingException callFailedJobListenerWithRetries ( CommandExecutor commandExecutor , FailedJobListener failedJobListener ) { try { commandExecutor . execute ( failedJobListener ) ; return null ; } catch ( OptimisticLockingException ex ) { failedJobListener . incrementCountRetries ( ) ; if ( failedJobListener . getRetriesLeft ( ) > 0 ) { return callFailedJobListenerWithRetries ( commandExecutor , failedJobListener ) ; } return ex ; } } | Calls FailedJobListener in case of OptimisticLockException retries configured amount of times . |
10,282 | public void addLocation ( TaintLocation location , boolean isKnownTaintSource ) { Objects . requireNonNull ( location , "location is null" ) ; if ( isKnownTaintSource ) { taintLocations . add ( location ) ; } else { unknownLocations . add ( location ) ; } } | Adds location for a taint source or path to remember for reporting |
10,283 | public boolean hasOneTag ( Tag ... tags ) { for ( Tag t : tags ) { if ( this . tags . contains ( t ) ) return true ; } return false ; } | Checks whether one of the specified taint tag is present for this fact |
10,284 | public static Taint valueOf ( State state ) { Objects . requireNonNull ( state , "state is null" ) ; if ( state == State . INVALID ) { return null ; } return new Taint ( state ) ; } | Constructs a new instance of taint from the specified state |
10,285 | public static Taint merge ( Taint a , Taint b ) { if ( a == null ) { if ( b == null ) { return null ; } else { return new Taint ( b ) ; } } else if ( b == null ) { return new Taint ( a ) ; } assert a != null && b != null ; Taint result = new Taint ( State . merge ( a . getState ( ) , b . getState ( ) ) ) ; if ( a . variableIndex == b . variableIndex ) { result . variableIndex = a . variableIndex ; } result . taintLocations . addAll ( a . taintLocations ) ; result . taintLocations . addAll ( b . taintLocations ) ; result . unknownLocations . addAll ( a . unknownLocations ) ; result . unknownLocations . addAll ( b . unknownLocations ) ; if ( ! result . isTainted ( ) ) { mergeParameters ( a , b , result ) ; } mergeRealInstanceClass ( a , b , result ) ; mergeTags ( a , b , result ) ; if ( a . constantValue != null && a . constantValue . equals ( b . constantValue ) ) { result . constantValue = a . constantValue ; } if ( FindSecBugsGlobalConfig . getInstance ( ) . isDebugTaintState ( ) ) { result . setDebugInfo ( "[" + a . getDebugInfo ( ) + "]+[" + b . getDebugInfo ( ) + "]" ) ; } assert ! result . hasParameters ( ) || result . isUnknown ( ) ; if ( a . potentialValue != null ) { result . potentialValue = a . potentialValue ; } else if ( b . potentialValue != null ) { result . potentialValue = b . potentialValue ; } result . addAllSources ( a . sources ) ; result . addAllSources ( b . sources ) ; return result ; } | Returns the merge of the facts such that it can represent any of them |
10,286 | public void dump ( PrintStream output ) { TreeSet < String > keys = new TreeSet < String > ( keySet ( ) ) ; for ( String key : keys ) { output . println ( key + ":" + get ( key ) ) ; } } | Dumps all the summaries for debugging |
10,287 | public void load ( InputStream input , final boolean checkRewrite ) throws IOException { new TaintConfigLoader ( ) . load ( input , new TaintConfigLoader . TaintConfigReceiver ( ) { public void receiveTaintConfig ( String typeSignature , String config ) throws IOException { if ( TaintMethodConfig . accepts ( typeSignature , config ) ) { if ( checkRewrite && containsKey ( typeSignature ) ) { throw new IllegalStateException ( "Config for " + typeSignature + " already loaded" ) ; } TaintMethodConfig taintMethodConfig = new TaintMethodConfig ( true ) . load ( config ) ; taintMethodConfig . setTypeSignature ( typeSignature ) ; put ( typeSignature , taintMethodConfig ) ; return ; } if ( TaintClassConfig . accepts ( typeSignature , config ) ) { if ( checkRewrite && taintClassConfigMap . containsKey ( typeSignature ) ) { throw new IllegalStateException ( "Config for " + typeSignature + " already loaded" ) ; } TaintClassConfig taintClassConfig = new TaintClassConfig ( ) . load ( config ) ; taintClassConfigMap . put ( typeSignature , taintClassConfig ) ; return ; } if ( TaintMethodConfigWithArgumentsAndLocation . accepts ( typeSignature , config ) ) { if ( checkRewrite && taintMethodConfigWithArgumentsAndLocationMap . containsKey ( typeSignature ) ) { throw new IllegalStateException ( "Config for " + typeSignature + " already loaded" ) ; } TaintMethodConfigWithArgumentsAndLocation methodConfig = new TaintMethodConfigWithArgumentsAndLocation ( ) . load ( config ) ; methodConfig . setTypeSignature ( typeSignature ) ; String key = typeSignature + '@' + methodConfig . getLocation ( ) ; taintMethodConfigWithArgumentsAndLocationMap . put ( key , methodConfig ) ; return ; } throw new IllegalArgumentException ( "Invalid full method name " + typeSignature + " configured" ) ; } } ) ; } | Loads summaries from stream checking the format |
10,288 | public void initEntryFact ( TaintFrame fact ) { fact . setValid ( ) ; fact . clearStack ( ) ; boolean inMainMethod = isInMainMethod ( ) ; int numSlots = fact . getNumSlots ( ) ; int numLocals = fact . getNumLocals ( ) ; for ( int i = 0 ; i < numSlots ; ++ i ) { Taint value = new Taint ( Taint . State . UNKNOWN ) ; if ( i < numLocals ) { if ( i < parameterStackSize ) { int stackOffset = parameterStackSize - i - 1 ; if ( isTaintedByAnnotation ( i - 1 ) ) { value = new Taint ( Taint . State . TAINTED ) ; } else if ( inMainMethod ) { if ( FindSecBugsGlobalConfig . getInstance ( ) . isTaintedMainArgument ( ) ) { value = new Taint ( Taint . State . TAINTED ) ; } else { value = new Taint ( Taint . State . SAFE ) ; } } else { value . addParameter ( stackOffset ) ; } value . addSource ( new UnknownSource ( UnknownSourceType . PARAMETER , value . getState ( ) ) . setParameterIndex ( stackOffset ) ) ; } value . setVariableIndex ( i ) ; } fact . setValue ( i , value ) ; } } | Initialize the initial state of a TaintFrame . |
10,289 | protected Class < ? > resolveClass ( final ObjectStreamClass objectStreamClass ) throws IOException , ClassNotFoundException { try { return Class . forName ( objectStreamClass . getName ( ) , false , classLoader ) ; } catch ( final ClassNotFoundException cnfe ) { return super . resolveClass ( objectStreamClass ) ; } } | Resolve a class specified by the descriptor using the specified ClassLoader or the super ClassLoader . |
10,290 | protected Class < ? > resolveProxyClass ( final String [ ] interfaces ) throws IOException , ClassNotFoundException { final Class < ? > [ ] interfaceClasses = new Class [ interfaces . length ] ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { interfaceClasses [ i ] = Class . forName ( interfaces [ i ] , false , classLoader ) ; } try { return Proxy . getProxyClass ( classLoader , interfaceClasses ) ; } catch ( final IllegalArgumentException e ) { return super . resolveProxyClass ( interfaces ) ; } } | Create a proxy class that implements the specified interfaces using the specified ClassLoader or the super ClassLoader . |
10,291 | private boolean hasCustomReadObject ( Method m , ClassContext classContext , List < String > classesToIgnore ) throws CFGBuilderException , DataflowAnalysisException { ConstantPoolGen cpg = classContext . getConstantPoolGen ( ) ; CFG cfg = classContext . getCFG ( m ) ; int count = 0 ; for ( Iterator < Location > i = cfg . locationIterator ( ) ; i . hasNext ( ) ; ) { Location location = i . next ( ) ; Instruction inst = location . getHandle ( ) . getInstruction ( ) ; if ( inst instanceof InvokeInstruction ) { InvokeInstruction invoke = ( InvokeInstruction ) inst ; if ( ! READ_DESERIALIZATION_METHODS . contains ( invoke . getMethodName ( cpg ) ) && ! classesToIgnore . contains ( invoke . getClassName ( cpg ) ) ) { count += 1 ; } } } return count > 3 ; } | Check if the readObject is doing multiple external call beyond the basic readByte readBoolean etc .. |
10,292 | public void load ( InputStream input , TaintConfigReceiver receiver ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( input , "UTF-8" ) ) ; for ( ; ; ) { String line = reader . readLine ( ) ; if ( line == null ) { break ; } line = line . trim ( ) ; if ( line . isEmpty ( ) ) { continue ; } putFromLine ( line , receiver ) ; } } | Loads the summaries and do what is specified |
10,293 | public void addLines ( Collection < TaintLocation > locations ) { Objects . requireNonNull ( detector , "locations" ) ; for ( TaintLocation location : locations ) { lines . add ( SourceLineAnnotation . fromVisitedInstruction ( location . getMethodDescriptor ( ) , location . getPosition ( ) ) ) ; } } | Adds lines with tainted source or path for reporting |
10,294 | public BugInstance generateBugInstance ( boolean taintedInsideMethod ) { BugInstance bug = new BugInstance ( detector , bugType , originalPriority ) ; bug . addClassAndMethod ( classContext . getJavaClass ( ) , method ) ; bug . addSourceLine ( SourceLineAnnotation . fromVisitedInstruction ( classContext , method , instructionHandle ) ) ; addMessage ( bug , "Sink method" , sinkMethod ) ; addMessage ( bug , "Sink parameter" , String . valueOf ( parameterOffset ) ) ; for ( UnknownSource source : sources ) { if ( source . getSourceType ( ) == UnknownSourceType . FIELD ) { addMessage ( bug , "Unknown source" , source . getSignatureField ( ) ) ; } else if ( source . getSourceType ( ) == UnknownSourceType . RETURN ) { if ( isExclude ( source . getSignatureMethod ( ) ) ) continue ; addMessage ( bug , "Unknown source" , source . getSignatureMethod ( ) ) ; } } if ( sinkPriority != UNKNOWN_SINK_PRIORITY ) { if ( sinkPriority < originalPriority ) { bug . setPriority ( sinkPriority ) ; addMessage ( bug , "Method usage" , "with tainted arguments detected" ) ; } else if ( sinkPriority > originalPriority ) { bug . setPriority ( Priorities . LOW_PRIORITY ) ; addMessage ( bug , "Method usage" , "detected only with safe arguments" ) ; } } else if ( ! taintedInsideMethod ) { addMessage ( bug , "Method usage" , "not detected" ) ; } Collections . sort ( lines ) ; SourceLineAnnotation annotation = null ; for ( Iterator < SourceLineAnnotation > it = lines . iterator ( ) ; it . hasNext ( ) ; ) { SourceLineAnnotation prev = annotation ; annotation = it . next ( ) ; if ( prev != null && prev . getClassName ( ) . equals ( annotation . getClassName ( ) ) && prev . getStartLine ( ) == annotation . getStartLine ( ) ) { it . remove ( ) ; } } for ( SourceLineAnnotation sourceLine : lines ) { bug . addSourceLine ( sourceLine ) ; } return bug ; } | Uses immutable values updated priority and added lines for reporting |
10,295 | public void finishAnalysis ( ) { assert analyzedMethodConfig != null ; Taint outputTaint = analyzedMethodConfig . getOutputTaint ( ) ; if ( outputTaint == null ) { return ; } String returnType = getReturnType ( methodDescriptor . getSignature ( ) ) ; if ( taintConfig . isClassTaintSafe ( returnType ) && outputTaint . getState ( ) != Taint . State . NULL ) { return ; } String realInstanceClassName = outputTaint . getRealInstanceClassName ( ) ; if ( returnType . equals ( "L" + realInstanceClassName + ";" ) ) { outputTaint . setRealInstanceClass ( null ) ; analyzedMethodConfig . setOuputTaint ( outputTaint ) ; } String className = methodDescriptor . getSlashedClassName ( ) ; String methodId = "." + methodDescriptor . getName ( ) + methodDescriptor . getSignature ( ) ; if ( analyzedMethodConfig . isInformative ( ) || taintConfig . getSuperMethodConfig ( className , methodId ) != null ) { String fullMethodName = className . concat ( methodId ) ; if ( ! taintConfig . containsKey ( fullMethodName ) ) { taintConfig . put ( fullMethodName , analyzedMethodConfig ) ; } } } | This method must be called from outside at the end of the method analysis |
10,296 | private boolean isEmptyImplementation ( MethodGen methodGen ) { boolean invokeInst = false ; boolean loadField = false ; for ( Iterator itIns = methodGen . getInstructionList ( ) . iterator ( ) ; itIns . hasNext ( ) ; ) { Instruction inst = ( ( InstructionHandle ) itIns . next ( ) ) . getInstruction ( ) ; if ( DEBUG ) System . out . println ( inst . toString ( true ) ) ; if ( inst instanceof InvokeInstruction ) { invokeInst = true ; } if ( inst instanceof GETFIELD ) { loadField = true ; } } return ! invokeInst && ! loadField ; } | Currently the detection is pretty weak . It will catch Dummy implementation that have empty method implementation |
10,297 | public void setOuputTaint ( Taint taint ) { if ( taint == null ) { this . outputTaint = null ; return ; } Taint taintCopy = new Taint ( taint ) ; taintCopy . invalidateVariableIndex ( ) ; this . outputTaint = taintCopy ; } | Sets the output taint of the method describing the taint transfer copy of the parameter is made and variable index is invalidated |
10,298 | public boolean isInformative ( ) { if ( this == SAFE_CONFIG ) { return false ; } if ( outputTaint == null ) { return false ; } if ( ! outputTaint . isUnknown ( ) ) { return true ; } if ( outputTaint . hasParameters ( ) ) { return true ; } if ( outputTaint . getRealInstanceClass ( ) != null ) { return true ; } if ( outputTaint . hasTags ( ) || outputTaint . isRemovingTags ( ) ) { return true ; } return false ; } | Checks if the summary needs to be saved or has no information value |
10,299 | public void report ( ) { Set < InjectionSink > injectionSinksToReport = new HashSet < InjectionSink > ( ) ; for ( Set < InjectionSink > injectionSinkSet : injectionSinks . values ( ) ) { for ( InjectionSink injectionSink : injectionSinkSet ) { injectionSinksToReport . add ( injectionSink ) ; } } for ( InjectionSink injectionSink : injectionSinksToReport ) { bugReporter . reportBug ( injectionSink . generateBugInstance ( false ) ) ; } } | Once the analysis is completed all the collected sinks are reported as bugs . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.