idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
15,200
@ Override public void draw ( Canvas canvas ) { float width = canvas . getWidth ( ) ; float margin = ( width / 3 ) + mState . mMarginSide ; float posY = canvas . getHeight ( ) - mState . mMarginBottom ; canvas . drawLine ( margin , posY , width - margin , posY , mPaint ) ; }
It is based on the canvas width and height instead of the bounds in order not to consider the margins of the button it is drawn in .
81
28
15,201
static void addAttachObserver ( HTMLElement element , ObserverCallback callback ) { if ( ! ready ) { startObserving ( ) ; } attachObservers . add ( createObserver ( element , callback , ATTACH_UID_KEY ) ) ; }
Check if the observer is already started if not it will start it then register and callback for when the element is attached to the dom .
56
27
15,202
static void addDetachObserver ( HTMLElement element , ObserverCallback callback ) { if ( ! ready ) { startObserving ( ) ; } detachObservers . add ( createObserver ( element , callback , DETACH_UID_KEY ) ) ; }
Check if the observer is already started if not it will start it then register and callback for when the element is removed from the dom .
57
27
15,203
public static < DateInstantT extends DateInstant > DatePickerFragment newInstance ( int pickerId , DateInstantT selectedInstant ) { DatePickerFragment f = new DatePickerFragment ( ) ; Bundle args = new Bundle ( ) ; args . putInt ( ARG_PICKER_ID , pickerId ) ; args . putParcelable ( ARG_SELECTED_INSTANT , selectedInstan...
Create a new date picker
106
6
15,204
private void abortWithError ( Element element , String msg , Object ... args ) throws AbortProcessingException { error ( element , msg , args ) ; throw new AbortProcessingException ( ) ; }
Issue a compilation error and abandon the processing of this template . This does not prevent the processing of other templates .
43
22
15,205
public static AccentPalette getPalette ( Context context ) { Resources resources = context . getResources ( ) ; if ( ! ( resources instanceof AccentResources ) ) return null ; return ( ( AccentResources ) resources ) . getPalette ( ) ; }
Get the AccentPalette instance from the the context .
56
12
15,206
public void prepareDialog ( Context c , Window window ) { if ( mDividerPainter == null ) mDividerPainter = initPainter ( c , mOverrideColor ) ; mDividerPainter . paint ( window ) ; }
Paint the dialog s divider if required to correctly customize it .
51
14
15,207
public static < E extends HTMLElement > EmptyContentBuilder < E > emptyElement ( String tag , Class < E > type ) { return emptyElement ( ( ) -> createElement ( tag , type ) ) ; }
Returns a builder for the specified empty tag .
46
9
15,208
public static < E extends HTMLElement > TextContentBuilder < E > textElement ( String tag , Class < E > type ) { return new TextContentBuilder <> ( createElement ( tag , type ) ) ; }
Returns a builder for the specified text tag .
47
9
15,209
public static < E extends HTMLElement > HtmlContentBuilder < E > htmlElement ( String tag , Class < E > type ) { return new HtmlContentBuilder <> ( createElement ( tag , type ) ) ; }
Returns a builder for the specified html tag .
49
9
15,210
public static < E > Stream < E > stream ( JsArrayLike < E > nodes ) { if ( nodes == null ) { return Stream . empty ( ) ; } else { return StreamSupport . stream ( spliteratorUnknownSize ( iterator ( nodes ) , 0 ) , false ) ; } }
Returns a stream for the elements in the given array - like .
62
13
15,211
public static Stream < Node > stream ( Node parent ) { if ( parent == null ) { return Stream . empty ( ) ; } else { return StreamSupport . stream ( spliteratorUnknownSize ( iterator ( parent ) , 0 ) , false ) ; } }
Returns a stream for the child nodes of the given parent node .
53
13
15,212
public static void lazyAppend ( Element parent , Element child ) { if ( ! parent . contains ( child ) ) { parent . appendChild ( child ) ; } }
Appends the specified element to the parent element if not already present . If parent already contains child this method does nothing .
35
24
15,213
public static void insertAfter ( Element newElement , Element after ) { after . parentNode . insertBefore ( newElement , after . nextSibling ) ; }
Inserts the specified element into the parent of the after element .
33
13
15,214
public static void lazyInsertAfter ( Element newElement , Element after ) { if ( ! after . parentNode . contains ( newElement ) ) { after . parentNode . insertBefore ( newElement , after . nextSibling ) ; } }
Inserts the specified element into the parent of the after element if not already present . If parent already contains child this method does nothing .
50
27
15,215
public static void insertBefore ( Element newElement , Element before ) { before . parentNode . insertBefore ( newElement , before ) ; }
Inserts the specified element into the parent of the before element .
29
13
15,216
public static void lazyInsertBefore ( Element newElement , Element before ) { if ( ! before . parentNode . contains ( newElement ) ) { before . parentNode . insertBefore ( newElement , before ) ; } }
Inserts the specified element into the parent of the before element if not already present . If parent already contains child this method does nothing .
46
27
15,217
public static boolean failSafeRemoveFromParent ( Element element ) { return failSafeRemove ( element != null ? element . parentNode : null , element ) ; }
Removes the element from its parent if the element is not null and has a parent .
33
18
15,218
public static boolean failSafeRemove ( Node parent , Element child ) { //noinspection SimplifiableIfStatement if ( parent != null && child != null && parent . contains ( child ) ) { return parent . removeChild ( child ) != null ; } return false ; }
Removes the child from parent if both parent and child are not null and parent contains child .
56
19
15,219
public static void onAttach ( HTMLElement element , ObserverCallback callback ) { if ( element != null ) { BodyObserver . addAttachObserver ( element , callback ) ; } }
Registers a callback when an element is appended to the document body . Note that the callback will be called only once if the element is appended more than once a new callback should be registered .
40
40
15,220
public static void onDetach ( HTMLElement element , ObserverCallback callback ) { if ( element != null ) { BodyObserver . addDetachObserver ( element , callback ) ; } }
Registers a callback when an element is removed from the document body . Note that the callback will be called only once if the element is removed and re - appended a new callback should be registered .
42
40
15,221
public void setSwitchTextAppearance ( Context context , int resid ) { TypedArray appearance = context . obtainStyledAttributes ( resid , R . styleable . TextAppearanceAccentSwitch ) ; ColorStateList colors ; int ts ; colors = appearance . getColorStateList ( R . styleable . TextAppearanceAccentSwitch_android_textColor ...
Sets the switch text color size style hint color and highlight color from the specified TextAppearance resource .
365
20
15,222
private void stopDrag ( MotionEvent ev ) { mTouchMode = TOUCH_MODE_IDLE ; // Up and not canceled, also checks the switch has not been disabled // during the drag boolean commitChange = ev . getAction ( ) == MotionEvent . ACTION_UP && isEnabled ( ) ; cancelSuperTouch ( ev ) ; if ( commitChange ) { boolean newState ; mVe...
Called from onTouchEvent to end a drag operation .
205
12
15,223
public static < TimeInstantT extends TimeInstant > TimePickerFragment newInstance ( int pickerId , TimeInstantT selectedInstant ) { TimePickerFragment f = new TimePickerFragment ( ) ; Bundle args = new Bundle ( ) ; args . putInt ( ARG_PICKER_ID , pickerId ) ; args . putParcelable ( ARG_SELECTED_INSTANT , selectedInstan...
Create a new time picker
106
6
15,224
@ SuppressWarnings ( "deprecation" ) @ SuppressLint ( "NewApi" ) private void setBackground ( View view , Drawable drawable ) { if ( Build . VERSION . SDK_INT >= SET_DRAWABLE_MIN_SDK ) view . setBackground ( drawable ) ; else view . setBackgroundDrawable ( drawable ) ; }
Call the appropriate method to set the background to the View
83
11
15,225
void sendAccessibilityEvent ( View view ) { // Since the view is still not attached we create, populate, // and send the event directly since we do not know when it // will be attached and posting commands is not as clean. AccessibilityManager accessibilityManager = ( AccessibilityManager ) getContext ( ) . getSystemSe...
As defined in TwoStatePreference source
183
8
15,226
public static String unescape ( String string , char escape ) { CharArrayWriter out = new CharArrayWriter ( string . length ( ) ) ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { char c = string . charAt ( i ) ; if ( c == escape ) { try { out . write ( Integer . parseInt ( string . substring ( i + 1 , i + 3 ) , 1...
Unescapes string using escape symbol .
146
9
15,227
public static String escape ( String string , char escape , boolean isPath ) { try { BitSet validChars = isPath ? URISaveEx : URISave ; byte [ ] bytes = string . getBytes ( "utf-8" ) ; StringBuffer out = new StringBuffer ( bytes . length ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { int c = bytes [ i ] & 0xff ; i...
Escapes string using escape symbol .
200
7
15,228
public static String relativizePath ( String path , boolean withIndex ) { if ( path . startsWith ( "/" ) ) path = path . substring ( 1 ) ; if ( ! withIndex && path . endsWith ( "]" ) ) { int index = path . lastIndexOf ( ' ' ) ; return index == - 1 ? path : path . substring ( 0 , index ) ; } return path ; }
Creates relative path from string .
89
7
15,229
public static String removeIndexFromPath ( String path ) { if ( path . endsWith ( "]" ) ) { int index = path . lastIndexOf ( ' ' ) ; if ( index != - 1 ) { return path . substring ( 0 , index ) ; } } return path ; }
Removes the index from the path if it has an index defined
62
13
15,230
public static String pathOnly ( String path ) { String curPath = path ; curPath = curPath . substring ( curPath . indexOf ( "/" ) ) ; curPath = curPath . substring ( 0 , curPath . lastIndexOf ( "/" ) ) ; if ( "" . equals ( curPath ) ) { curPath = "/" ; } return curPath ; }
Cuts the path from string .
82
7
15,231
public static String nameOnly ( String path ) { int index = path . lastIndexOf ( ' ' ) ; String name = index == - 1 ? path : path . substring ( index + 1 ) ; if ( name . endsWith ( "]" ) ) { index = name . lastIndexOf ( ' ' ) ; return index == - 1 ? name : name . substring ( 0 , index ) ; } return name ; }
Cuts the current name from the path .
90
9
15,232
public static String getExtension ( String filename ) { int index = filename . lastIndexOf ( ' ' ) ; if ( index >= 0 ) { return filename . substring ( index + 1 ) ; } return "" ; }
Extracts the extension of the file .
47
9
15,233
protected boolean isPredecessor ( NodeData mergeVersion , NodeData corrVersion ) throws RepositoryException { SessionDataManager mergeDataManager = mergeSession . getTransientNodesManager ( ) ; PropertyData predecessorsProperty = ( PropertyData ) mergeDataManager . getItemData ( mergeVersion , new QPathEntry ( Constant...
Is a predecessor of the merge version
290
7
15,234
protected boolean isSuccessor ( NodeData mergeVersion , NodeData corrVersion ) throws RepositoryException { SessionDataManager mergeDataManager = mergeSession . getTransientNodesManager ( ) ; PropertyData successorsProperty = ( PropertyData ) mergeDataManager . getItemData ( mergeVersion , new QPathEntry ( Constants . ...
Is a successor of the merge version
288
7
15,235
public PersistedNodeData read ( ObjectReader in ) throws UnknownClassIdException , IOException { // read id int key ; if ( ( key = in . readInt ( ) ) != SerializationConstants . PERSISTED_NODE_DATA ) { throw new UnknownClassIdException ( "There is unexpected class [" + key + "]" ) ; } QPath qpath ; try { String sQPath ...
Read and set PersistedNodeData data .
600
9
15,236
protected void prepareRenamingApproachScripts ( ) throws DBCleanException { cleaningScripts . addAll ( getTablesRenamingScripts ( ) ) ; cleaningScripts . addAll ( getDBInitializationScripts ( ) ) ; cleaningScripts . addAll ( getFKRemovingScripts ( ) ) ; cleaningScripts . addAll ( getConstraintsRemovingScripts ( ) ) ; c...
Prepares scripts for renaming approach database cleaning .
218
10
15,237
protected void prepareDroppingTablesApproachScripts ( ) throws DBCleanException { cleaningScripts . addAll ( getTablesDroppingScripts ( ) ) ; cleaningScripts . addAll ( getDBInitializationScripts ( ) ) ; cleaningScripts . addAll ( getFKRemovingScripts ( ) ) ; cleaningScripts . addAll ( getIndexesDroppingScripts ( ) ) ;...
Prepares scripts for dropping tables approach database cleaning .
123
10
15,238
protected void prepareSimpleCleaningApproachScripts ( ) { cleaningScripts . addAll ( getFKRemovingScripts ( ) ) ; cleaningScripts . addAll ( getSingleDbWorkspaceCleaningScripts ( ) ) ; committingScripts . addAll ( getFKAddingScripts ( ) ) ; rollbackingScripts . addAll ( getFKAddingScripts ( ) ) ; }
Prepares scripts for simple cleaning database .
85
8
15,239
protected Collection < String > getFKRemovingScripts ( ) { List < String > scripts = new ArrayList < String > ( ) ; String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT" ; scripts . add ( "ALTER TABLE " + itemTableName + " " + constraintDroppingSyntax ( ) + " " + constraintName ) ; return scripts ; }
Returns SQL scripts for removing FK on JCR_ITEM table .
88
15
15,240
protected Collection < String > getFKAddingScripts ( ) { List < String > scripts = new ArrayList < String > ( ) ; String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)" ; scripts . add ( "ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraint...
Returns SQL scripts for adding FK on JCR_ITEM table .
103
15
15,241
protected Collection < String > getOldTablesDroppingScripts ( ) { List < String > scripts = new ArrayList < String > ( ) ; scripts . add ( "DROP TABLE " + valueTableName + "_OLD" ) ; scripts . add ( "DROP TABLE " + refTableName + "_OLD" ) ; scripts . add ( "DROP TABLE " + itemTableName + "_OLD" ) ; return scripts ; }
Returns SQL scripts for dropping existed old JCR tables .
92
11
15,242
protected Collection < String > getDBInitializationScripts ( ) throws DBCleanException { String dbScripts ; try { dbScripts = DBInitializerHelper . prepareScripts ( wsEntry , dialect ) ; } catch ( IOException e ) { throw new DBCleanException ( e ) ; } catch ( RepositoryConfigurationException e ) { throw new DBCleanExce...
Returns SQL scripts for database initalization .
207
9
15,243
public < T > List < T > getComponentInstancesOfType ( Class < T > componentType ) { return container . getComponentInstancesOfType ( componentType ) ; }
Returns list of components of specific type .
38
8
15,244
public int getState ( ) { boolean hasSuspendedComponents = false ; boolean hasResumedComponents = false ; List < Suspendable > suspendableComponents = getComponentInstancesOfType ( Suspendable . class ) ; for ( Suspendable component : suspendableComponents ) { if ( component . isSuspended ( ) ) { hasSuspendedComponents...
Returns current workspace state .
167
5
15,245
public void setState ( final int state ) throws RepositoryException { // Need privileges to manage repository. SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; } try { SecurityHelper . doPrivilege...
Set new workspace state .
221
5
15,246
private void suspend ( ) throws RepositoryException { WorkspaceResumer workspaceResumer = getWorkspaceResumer ( ) ; if ( workspaceResumer != null ) { workspaceResumer . onSuspend ( ) ; } List < Suspendable > components = getComponentInstancesOfType ( Suspendable . class ) ; Comparator < Suspendable > c = new Comparator...
Suspend all components in workspace .
198
8
15,247
private void resume ( ) throws RepositoryException { WorkspaceResumer workspaceResumer = getWorkspaceResumer ( ) ; if ( workspaceResumer != null ) { workspaceResumer . onResume ( ) ; } // components should be resumed in reverse order List < Suspendable > components = getComponentInstancesOfType ( Suspendable . class ) ...
Set all components online .
205
5
15,248
private Set < QName > propertyNames ( HierarchicalProperty body ) { HashSet < QName > names = new HashSet < QName > ( ) ; HierarchicalProperty propBody = body . getChild ( PropertyConstants . DAV_ALLPROP_INCLUDE ) ; if ( propBody != null ) { names . add ( PropertyConstants . DAV_ALLPROP_INCLUDE ) ; } else { propBody = ...
Returns the set of properties names .
180
7
15,249
protected String getCurrentFolderPath ( GenericWebAppContext context ) { // To limit browsing set Servlet init param "digitalAssetsPath" with desired JCR path String rootFolderStr = ( String ) context . get ( "org.exoplatform.frameworks.jcr.command.web.fckeditor.digitalAssetsPath" ) ; if ( rootFolderStr == null ) rootF...
Return FCKeditor current folder path .
158
8
15,250
protected String makeRESTPath ( String repoName , String workspace , String resource ) { final StringBuilder sb = new StringBuilder ( 512 ) ; ExoContainer container = ExoContainerContext . getCurrentContainerIfPresent ( ) ; if ( container instanceof PortalContainer ) { PortalContainer pContainer = ( PortalContainer ) c...
Compile REST path of the given resource .
173
9
15,251
protected String getLockToken ( String tokenHash ) { for ( String token : tokens . keySet ( ) ) { if ( tokens . get ( token ) . equals ( tokenHash ) ) { return token ; } } return null ; }
Returns real token if session has it .
49
8
15,252
public LockData getPendingLock ( String nodeId ) { if ( pendingLocks . contains ( nodeId ) ) { return lockedNodes . get ( nodeId ) ; } else { return null ; } }
Return pending lock .
45
4
15,253
public int getNodeIndex ( NodeData parentData , InternalQName name , String skipIdentifier ) throws PathNotFoundException , IllegalPathException , RepositoryException { if ( name instanceof QPathEntry ) { name = new InternalQName ( name . getNamespace ( ) , name . getName ( ) ) ; } int newIndex = 1 ; NodeDefinitionData...
Return new node index .
656
5
15,254
public void setAncestorToSave ( QPath newAncestorToSave ) { if ( ! ancestorToSave . equals ( newAncestorToSave ) ) { isNeedReloadAncestorToSave = true ; } this . ancestorToSave = newAncestorToSave ; }
Set new ancestorToSave .
64
6
15,255
protected void createVersionHistory ( ImportNodeData nodeData ) throws RepositoryException { // Generate new VersionHistoryIdentifier and BaseVersionIdentifier // if uuid changed after UC boolean newVersionHistory = nodeData . isNewIdentifer ( ) || ! nodeData . isContainsVersionhistory ( ) ; if ( newVersionHistory ) { ...
Create new version history .
268
5
15,256
protected void checkReferenceable ( ImportNodeData currentNodeInfo , String olUuid ) throws RepositoryException { // if node is in version storage - do not assign new id from jcr:uuid // property if ( Constants . JCR_VERSION_STORAGE_PATH . getDepth ( ) + 3 <= currentNodeInfo . getQPath ( ) . getDepth ( ) && currentNode...
Check uuid collision . If collision happen reload path information .
322
12
15,257
private List < ItemState > getItemStatesList ( NodeData parentData , InternalQName name , int state , String skipIdentifier ) { List < ItemState > states = new ArrayList < ItemState > ( ) ; for ( ItemState itemState : changesLog . getAllStates ( ) ) { ItemData stateData = itemState . getData ( ) ; if ( isParent ( state...
Return list of changes for item .
163
7
15,258
protected ItemState getLastItemState ( String identifer ) { List < ItemState > allStates = changesLog . getAllStates ( ) ; for ( int i = allStates . size ( ) - 1 ; i >= 0 ; i -- ) { ItemState state = allStates . get ( i ) ; if ( state . getData ( ) . getIdentifier ( ) . equals ( identifer ) ) return state ; } return nu...
Return last item state in changes log . If no state exist return null .
93
15
15,259
private void removeExisted ( NodeData sameUuidItem ) throws RepositoryException , ConstraintViolationException , PathNotFoundException { if ( ! nodeTypeDataManager . isNodeType ( Constants . MIX_REFERENCEABLE , sameUuidItem . getPrimaryTypeName ( ) , sameUuidItem . getMixinTypeNames ( ) ) ) { throw new RepositoryExcept...
Remove existed item .
844
4
15,260
private void removeVersionHistory ( NodeData mixVersionableNode ) throws RepositoryException , ConstraintViolationException , VersionException { try { PropertyData vhpd = ( PropertyData ) dataConsumer . getItemData ( mixVersionableNode , new QPathEntry ( Constants . JCR_VERSIONHISTORY , 1 ) , ItemType . PROPERTY ) ; St...
Remove version history of versionable node .
183
8
15,261
protected void notifyListeners ( ) { synchronized ( listeners ) { Thread notifier = new NotifyThread ( listeners . toArray ( new BackupJobListener [ listeners . size ( ) ] ) , this ) ; notifier . start ( ) ; } }
Notify all listeners about the job state changed
52
9
15,262
protected void notifyError ( String message , Throwable error ) { synchronized ( listeners ) { Thread notifier = new ErrorNotifyThread ( listeners . toArray ( new BackupJobListener [ listeners . size ( ) ] ) , this , message , error ) ; notifier . start ( ) ; } }
Notify all listeners about an error
62
7
15,263
private UserProfile readProfile ( Session session , String userName ) throws Exception { Node profileNode ; try { profileNode = utils . getProfileNode ( session , userName ) ; } catch ( PathNotFoundException e ) { return null ; } return readProfile ( userName , profileNode ) ; }
Reads user profile from storage based on user name .
64
11
15,264
private UserProfile removeUserProfile ( Session session , String userName , boolean broadcast ) throws Exception { Node profileNode ; try { profileNode = utils . getProfileNode ( session , userName ) ; } catch ( PathNotFoundException e ) { return null ; } UserProfile profile = readProfile ( userName , profileNode ) ; i...
Remove user profile from storage .
120
6
15,265
void migrateProfile ( Node oldUserNode ) throws Exception { UserProfile userProfile = new UserProfileImpl ( oldUserNode . getName ( ) ) ; Node attrNode = null ; try { attrNode = oldUserNode . getNode ( JCROrganizationServiceImpl . JOS_PROFILE + "/" + MigrationTool . JOS_ATTRIBUTES ) ; } catch ( PathNotFoundException e ...
Migrates user profile from old storage into new .
264
11
15,266
private void saveUserProfile ( Session session , UserProfile profile , boolean broadcast ) throws RepositoryException , Exception { Node userNode = utils . getUserNode ( session , profile . getUserName ( ) ) ; Node profileNode = getProfileNode ( userNode ) ; boolean isNewProfile = profileNode . isNew ( ) ; if ( broadca...
Persist user profile to the storage .
125
8
15,267
private Node getProfileNode ( Node userNode ) throws RepositoryException { try { return userNode . getNode ( JCROrganizationServiceImpl . JOS_PROFILE ) ; } catch ( PathNotFoundException e ) { return userNode . addNode ( JCROrganizationServiceImpl . JOS_PROFILE ) ; } }
Create new profile node .
71
5
15,268
private UserProfile readProfile ( String userName , Node profileNode ) throws RepositoryException { UserProfile profile = createUserProfileInstance ( userName ) ; PropertyIterator attributes = profileNode . getProperties ( ) ; while ( attributes . hasNext ( ) ) { Property prop = attributes . nextProperty ( ) ; if ( pro...
Read user profile from storage .
141
6
15,269
private void writeProfile ( UserProfile userProfile , Node profileNode ) throws RepositoryException { for ( Entry < String , String > attribute : userProfile . getUserInfoMap ( ) . entrySet ( ) ) { profileNode . setProperty ( ATTRIBUTE_PREFIX + attribute . getKey ( ) , attribute . getValue ( ) ) ; } }
Write profile to storage .
77
5
15,270
private UserProfile getFromCache ( String userName ) { return ( UserProfile ) cache . get ( userName , CacheType . USER_PROFILE ) ; }
Returns user profile from cache . Can return null .
35
10
15,271
private void putInCache ( UserProfile profile ) { cache . put ( profile . getUserName ( ) , profile , CacheType . USER_PROFILE ) ; }
Putting user profile in cache if profile is not null .
36
11
15,272
private void preSave ( UserProfile userProfile , boolean isNew ) throws Exception { for ( UserProfileEventListener listener : listeners ) { listener . preSave ( userProfile , isNew ) ; } }
Notifying listeners before profile creation .
42
7
15,273
private void postSave ( UserProfile userProfile , boolean isNew ) throws Exception { for ( UserProfileEventListener listener : listeners ) { listener . postSave ( userProfile , isNew ) ; } }
Notifying listeners after profile creation .
42
7
15,274
private void preDelete ( UserProfile userProfile , boolean broadcast ) throws Exception { for ( UserProfileEventListener listener : listeners ) { listener . preDelete ( userProfile ) ; } }
Notifying listeners before profile deletion .
38
7
15,275
private void postDelete ( UserProfile userProfile ) throws Exception { for ( UserProfileEventListener listener : listeners ) { listener . postDelete ( userProfile ) ; } }
Notifying listeners after profile deletion .
35
7
15,276
protected void addScripts ( ) { if ( loadPlugins == null || loadPlugins . size ( ) == 0 ) { return ; } for ( GroovyScript2RestLoaderPlugin loadPlugin : loadPlugins ) { // If no one script configured then skip this item, // there is no reason to do anything. if ( loadPlugin . getXMLConfigs ( ) . size ( ) == 0 ) { contin...
Add scripts that specified in configuration .
428
7
15,277
protected Node createScript ( Node parent , String name , boolean autoload , InputStream stream ) throws Exception { Node scriptFile = parent . addNode ( name , "nt:file" ) ; Node script = scriptFile . addNode ( "jcr:content" , getNodeType ( ) ) ; script . setProperty ( "exo:autoload" , autoload ) ; script . setPropert...
Create JCR node .
147
5
15,278
protected void setAttributeSmart ( Element element , String attr , String value ) { if ( value == null ) { element . removeAttribute ( attr ) ; } else { element . setAttribute ( attr , value ) ; } }
Set attribute value . If value is null the attribute will be removed .
49
14
15,279
@ POST @ Path ( "load/{repository}/{workspace}/{path:.*}" ) @ RolesAllowed ( { "administrators" } ) public Response load ( @ PathParam ( "repository" ) String repository , @ PathParam ( "workspace" ) String workspace , @ PathParam ( "path" ) String path , @ DefaultValue ( "true" ) @ QueryParam ( "state" ) boolean state...
Deploy groovy script as REST service . If this property set to true then script will be deployed as REST service if false the script will be undeployed . NOTE is script already deployed and state is true script will be re - deployed .
238
48
15,280
@ POST @ Path ( "delete/{repository}/{workspace}/{path:.*}" ) public Response deleteScript ( @ PathParam ( "repository" ) String repository , @ PathParam ( "workspace" ) String workspace , @ PathParam ( "path" ) String path ) { Session ses = null ; try { ses = sessionProviderService . getSessionProvider ( null ) . getS...
Remove node that contains groovy script .
301
8
15,281
@ POST @ Produces ( { "script/groovy" } ) @ Path ( "src/{repository}/{workspace}/{path:.*}" ) public Response getScript ( @ PathParam ( "repository" ) String repository , @ PathParam ( "workspace" ) String workspace , @ PathParam ( "path" ) String path ) { Session ses = null ; try { ses = sessionProviderService . getSe...
Get source code of groovy script .
350
8
15,282
@ POST @ Produces ( { MediaType . APPLICATION_JSON } ) @ Path ( "meta/{repository}/{workspace}/{path:.*}" ) public Response getScriptMetadata ( @ PathParam ( "repository" ) String repository , @ PathParam ( "workspace" ) String workspace , @ PathParam ( "path" ) String path ) { Session ses = null ; try { ses = sessionP...
Get groovy script s meta - information .
447
9
15,283
@ POST @ Produces ( MediaType . APPLICATION_JSON ) @ Path ( "list/{repository}/{workspace}" ) public Response list ( @ PathParam ( "repository" ) String repository , @ PathParam ( "workspace" ) String workspace , @ QueryParam ( "name" ) String name ) { Session ses = null ; try { ses = sessionProviderService . getSessio...
Returns the list of all groovy - scripts found in workspace .
615
13
15,284
protected static String getPath ( String fullPath ) { int sl = fullPath . lastIndexOf ( ' ' ) ; return sl > 0 ? "/" + fullPath . substring ( 0 , sl ) : "/" ; }
Extract path to node s parent from full path .
48
11
15,285
protected static String getName ( String fullPath ) { int sl = fullPath . lastIndexOf ( ' ' ) ; return sl >= 0 ? fullPath . substring ( sl + 1 ) : fullPath ; }
Extract node s name from full node path .
45
10
15,286
public HierarchicalProperty getChild ( QName name ) { for ( HierarchicalProperty child : children ) { if ( child . getName ( ) . equals ( name ) ) return child ; } return null ; }
retrieves children property by name .
46
8
15,287
public static String md5 ( String data , String enc ) throws UnsupportedEncodingException { try { return digest ( "MD5" , data . getBytes ( enc ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new InternalError ( "MD5 digest not available???" ) ; } }
Calculate an MD5 hash of the string given .
66
12
15,288
public static String [ ] explode ( String str , int ch , boolean respectEmpty ) { if ( str == null || str . length ( ) == 0 ) { return new String [ 0 ] ; } ArrayList strings = new ArrayList ( ) ; int pos ; int lastpos = 0 ; // add snipples while ( ( pos = str . indexOf ( ch , lastpos ) ) >= 0 ) { if ( pos - lastpos > 0...
returns an array of strings decomposed of the original string split at every occurance of ch .
203
20
15,289
public static String implode ( String [ ] arr , String delim ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i > 0 ) { buf . append ( delim ) ; } buf . append ( arr [ i ] ) ; } return buf . toString ( ) ; }
Concatenates all strings in the string array using the specified delimiter .
77
16
15,290
public static String encodeIllegalXMLCharacters ( String text ) { if ( text == null ) { throw new IllegalArgumentException ( "null argument" ) ; } StringBuilder buf = null ; int length = text . length ( ) ; int pos = 0 ; for ( int i = 0 ; i < length ; i ++ ) { int ch = text . charAt ( i ) ; switch ( ch ) { case ' ' : c...
Replaces illegal XML characters in the given string by their corresponding predefined entity references .
304
17
15,291
public static String getName ( String path ) { int pos = path . lastIndexOf ( ' ' ) ; return pos >= 0 ? path . substring ( pos + 1 ) : "" ; }
Returns the name part of the path
41
7
15,292
public static boolean isSibling ( String p1 , String p2 ) { int pos1 = p1 . lastIndexOf ( ' ' ) ; int pos2 = p2 . lastIndexOf ( ' ' ) ; return ( pos1 == pos2 && pos1 >= 0 && p1 . regionMatches ( 0 , p2 , 0 , pos1 ) ) ; }
Determines if two paths denote hierarchical siblins .
79
12
15,293
private InternalQName getNodeTypeName ( Node config ) throws IllegalNameException , RepositoryException { String ntString = config . getAttributes ( ) . getNamedItem ( "primaryType" ) . getNodeValue ( ) ; return resolver . parseJCRName ( ntString ) . getInternalName ( ) ; }
Reads the node type of the root node of the indexing aggregate .
71
15
15,294
@ SuppressWarnings ( "unchecked" ) private boolean isIndexRecoveryRequired ( ) throws RepositoryException { // instantiate filters first, if not initialized if ( recoveryFilters == null ) { recoveryFilters = new ArrayList < AbstractRecoveryFilter > ( ) ; log . info ( "Initializing RecoveryFilters." ) ; // add default f...
Invokes all recovery filters from the set
444
8
15,295
public MultiColumnQueryHits executeQuery ( SessionImpl session , AbstractQueryImpl queryImpl , Query query , QPath [ ] orderProps , boolean [ ] orderSpecs , long resultFetchHint ) throws IOException , RepositoryException { waitForResuming ( ) ; checkOpen ( ) ; workingThreads . incrementAndGet ( ) ; try { FieldComparato...
Executes the query on the search index .
347
9
15,296
public IndexFormatVersion getIndexFormatVersion ( ) { if ( indexFormatVersion == null ) { if ( getContext ( ) . getParentHandler ( ) instanceof SearchIndex ) { SearchIndex parent = ( SearchIndex ) getContext ( ) . getParentHandler ( ) ; if ( parent . getIndexFormatVersion ( ) . getVersion ( ) < indexRegister . getDefau...
Returns the index format version that this search index is able to support when a query is executed on this index .
163
22
15,297
protected IndexReader getIndexReader ( boolean includeSystemIndex ) throws IOException { // deny query execution if index in offline mode and allowQuery is false if ( ! indexRegister . getDefaultIndex ( ) . isOnline ( ) && ! allowQuery . get ( ) ) { throw new IndexOfflineIOException ( "Index is offline" ) ; } QueryHand...
Returns an index reader for this search index . The caller of this method is responsible for closing the index reader when he is finished using it .
222
28
15,298
protected SortField [ ] createSortFields ( QPath [ ] orderProps , boolean [ ] orderSpecs , FieldComparatorSource scs ) throws RepositoryException { List < SortField > sortFields = new ArrayList < SortField > ( ) ; for ( int i = 0 ; i < orderProps . length ; i ++ ) { if ( orderProps [ i ] . getEntries ( ) . length == 1 ...
Creates the SortFields for the order properties .
274
11
15,299
public MultiIndex createNewIndex ( String suffix ) throws IOException { IndexInfos indexInfos = new IndexInfos ( ) ; IndexUpdateMonitor indexUpdateMonitor = new DefaultIndexUpdateMonitor ( ) ; IndexerIoModeHandler modeHandler = new IndexerIoModeHandler ( IndexerIoMode . READ_WRITE ) ; MultiIndex newIndex = new MultiInd...
Create a new index with the same actual context .
127
10