idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
15,900 | public static final < T extends Recyclable > T get ( Class < T > cls , Consumer < T > initializer ) { T recyclable = null ; lock . lock ( ) ; try { List < Recyclable > list = mapList . get ( cls ) ; if ( list != null && ! list . isEmpty ( ) ) { recyclable = ( T ) list . remove ( list . size ( ) - 1 ) ; log . debug ( "get recycled %s" , recyclable ) ; } } finally { lock . unlock ( ) ; } if ( recyclable == null ) { try { recyclable = cls . newInstance ( ) ; log . debug ( "create new recycled %s" , recyclable ) ; } catch ( InstantiationException | IllegalAccessException ex ) { throw new IllegalArgumentException ( ex ) ; } } if ( initializer != null ) { initializer . accept ( recyclable ) ; } return ( T ) recyclable ; } | Returns new or recycled initialized object . |
15,901 | public Gild with ( final String serviceName , final ServiceProxy proxy ) { proxies . put ( serviceName , proxy ) ; return this ; } | Adds a service proxy to this harness . |
15,902 | public void nextStage ( final String stageName ) { assertNotNull ( "Cannot move to a null stage" , stageName ) ; execs . forEach ( consumer ( StageExec :: preserve ) ) ; stage = stage . nextStage ( stageName ) ; prepare ( ) ; } | Moves to the next stage in the staged test run . |
15,903 | public static final < T > Set < T > difference ( Set < T > u , Set < T > a ) { Set < T > set = new HashSet < > ( u ) ; set . removeAll ( a ) ; return set ; } | Set difference of U and A denoted U \ A is the set of all members of U that are not members of A |
15,904 | public static final < T > boolean intersect ( Collection < Set < T > > sets ) { Set < T > set = intersection ( sets ) ; return ! set . isEmpty ( ) ; } | return true if intersection is not empty |
15,905 | public static final < T > Set < Set < T > > powerSet ( Set < T > set ) { Set < Set < T > > powerSet = new HashSet < > ( ) ; powerSet . add ( Collections . EMPTY_SET ) ; powerSet ( powerSet , set ) ; return powerSet ; } | Power set of a set A is the set whose members are all possible subsets of A . |
15,906 | public static final < T > void assign ( Set < T > source , Set < T > target ) { target . retainAll ( source ) ; target . addAll ( source ) ; } | Sets target content to be the same as source without clearing the target . |
15,907 | public final void addFilters ( final List < IDataFilter > newFilters ) { assertFilterListExists ( ) ; for ( IDataFilter filter : newFilters ) { addFilter ( filter ) ; } } | Add many filters . |
15,908 | public final Map < String , Object > applyFilters ( final Map < String , Object > row ) { Map < String , Object > filteringRow = new LinkedHashMap < > ( row ) ; assertFilterListExists ( ) ; for ( IDataFilter filter : getFilters ( ) ) { filteringRow = filter . apply ( filteringRow ) ; } return filteringRow ; } | Apply the filters . |
15,909 | public final void setElement ( final WebElement element ) { if ( element == null ) { throw new IllegalArgumentException ( String . format ( ErrorMessages . ERROR_TEMPLATE_VARIABLE_NULL , "element" ) ) ; } this . element = element ; validateElementTag ( ) ; validateAttributes ( ) ; } | The Selenium - Webdriver element that represents the component HTML of the simulated page . |
15,910 | public void validateElementTag ( ) { String errorMsg = String . format ( ErrorMessages . ERROR_INVALID_TAG_TO_CLASS , getElement ( ) . getTagName ( ) ) ; if ( ! isValidElementTag ( ) ) { throw new IllegalArgumentException ( errorMsg ) ; } } | Verify if the element loaded is a valid element for the class that is representing it . |
15,911 | public String getLocator ( Integer index ) { String relLocator = ".//" ; if ( getBasicLocator ( ) . contains ( "[" ) ) { relLocator += getBasicLocator ( ) . replace ( "]" , " and position()=%d ]" ) ; } else { relLocator += "%s[%d]" ; } return String . format ( relLocator , index ) ; } | Returns the relative locator to find the html object on HTML page using the index of the HTML object to recover it . |
15,912 | protected Object [ ] getArguments ( IQueryContext context ) { List < Object > args = new ArrayList < > ( ) ; createArgumentList ( args , context ) ; return args . toArray ( ) ; } | Prepares an argument list from the query context . |
15,913 | public IQueryResult < T > fetch ( IQueryContext context ) { try { return QueryUtil . packageResult ( processData ( context , service . callRPC ( rpcName , getArguments ( context ) ) ) ) ; } catch ( Exception e ) { return QueryUtil . errorResult ( e ) ; } } | Fetches data in a foreground thread . |
15,914 | public Object getInfoFromHandle ( Object bookmark , boolean bGetTable , int iHandleType ) throws DBException { if ( iHandleType == DBConstants . OBJECT_ID_HANDLE ) { if ( ! ( bookmark instanceof String ) ) return null ; int iLastColon = ( ( String ) bookmark ) . lastIndexOf ( BaseTable . HANDLE_SEPARATOR ) ; if ( iLastColon == - 1 ) return null ; if ( bGetTable ) return ( ( String ) bookmark ) . substring ( 0 , iLastColon ) ; else return ( ( String ) bookmark ) . substring ( iLastColon + 1 ) ; } return bookmark ; } | Get the table or object ID portion of the bookmark . |
15,915 | public void set ( int index , int count , boolean value ) { for ( int ii = 0 ; ii < count ; ii ++ ) { set ( ii + index , value ) ; } } | Set count of bits starting from index to value |
15,916 | public void set ( int index , boolean value ) { check ( index ) ; if ( value ) { array [ index / 8 ] |= ( 1 << ( index % 8 ) ) ; } else { array [ index / 8 ] &= ~ ( 1 << ( index % 8 ) ) ; } } | Set bit at index to value |
15,917 | public boolean any ( ) { int l = bits / 8 ; for ( int ii = 0 ; ii < l ; ii ++ ) { if ( array [ ii ] != 0 ) { return true ; } } for ( int ii = l * 8 ; ii < bits ; ii ++ ) { if ( isSet ( ii ) ) { return true ; } } return false ; } | Returns true if any bit is set |
15,918 | public int first ( ) { for ( int ii = 0 ; ii < array . length ; ii ++ ) { if ( array [ ii ] != 0 ) { for ( int jj = ii * 8 ; jj < bits ; jj ++ ) { if ( isSet ( jj ) ) { return jj ; } } } } return - 1 ; } | returns the first set bits index |
15,919 | public int last ( ) { for ( int ii = array . length - 1 ; ii >= 0 ; ii -- ) { if ( array [ ii ] != 0 ) { for ( int jj = Math . min ( bits , ( ii + 1 ) * 8 ) - 1 ; jj >= 0 ; jj -- ) { if ( isSet ( jj ) ) { return jj ; } } } } return - 1 ; } | returns the last set bits index |
15,920 | public void forEach ( IntConsumer consumer ) { for ( int ii = 0 ; ii < array . length ; ii ++ ) { if ( array [ ii ] != 0 ) { int lim = Math . min ( bits , ( ii + 1 ) * 8 ) ; for ( int jj = ii * 8 ; jj < lim ; jj ++ ) { if ( isSet ( jj ) ) { consumer . accept ( jj ) ; } } } } } | For each set bet index . |
15,921 | public IntStream stream ( ) { IntStream . Builder builder = IntStream . builder ( ) ; forEach ( builder ) ; return builder . build ( ) ; } | Returns set bit indexes as stream |
15,922 | public int count ( ) { int count = 0 ; for ( int ii = bits - 1 ; ii >= 0 ; ii -- ) { if ( isSet ( ii ) ) { count ++ ; } } return count ; } | Returns number of set bits |
15,923 | public boolean and ( BitArray other ) { if ( bits != other . bits ) { throw new IllegalArgumentException ( "number of bits differ" ) ; } int l = bits / 8 ; for ( int ii = 0 ; ii < l ; ii ++ ) { if ( ( array [ ii ] & other . array [ ii ] ) != 0 ) { return true ; } } for ( int ii = l * 8 ; ii < bits ; ii ++ ) { if ( isSet ( ii ) && other . isSet ( ii ) ) { return true ; } } return false ; } | Returns true if bit in this and other is set in any same index . |
15,924 | public static void fillWidth ( Point point , Point derivate , double width , PlotOperator plot ) { fillWidth ( point . x , point . y , derivate . x , derivate . y , width , plot ) ; } | Draws orthogonal to derivate width length line having center at point . |
15,925 | public void readFields ( ArrayList < String > fields ) throws IOException { fields . clear ( ) ; if ( this . eof ) { throw new EOFException ( ) ; } do { fields . add ( readField ( ) ) ; } while ( this . moreFieldsOnLine ) ; } | Reads the current line s fields into an ArrayList . This is a convenience method . |
15,926 | public String readField ( ) throws IOException { int c ; final int UNQUOTED = 0 ; final int QUOTED = 1 ; final int QUOTEDPLUS = 2 ; int state = UNQUOTED ; if ( this . eof ) { throw new EOFException ( ) ; } this . buffer . setLength ( 0 ) ; while ( ( c = this . read ( ) ) >= 0 ) { if ( state == QUOTEDPLUS ) { switch ( c ) { case '"' : this . buffer . append ( '"' ) ; state = QUOTED ; continue ; default : state = UNQUOTED ; break ; } } if ( state == QUOTED ) { switch ( c ) { default : this . buffer . append ( ( char ) c ) ; continue ; case '"' : state = QUOTEDPLUS ; continue ; } } switch ( c ) { case '"' : state = QUOTED ; continue ; case '\r' : continue ; case '\n' : case ',' : this . moreFieldsOnLine = ( c != '\n' ) ; return this . buffer . toString ( ) ; default : this . buffer . append ( ( char ) c ) ; continue ; } } this . eof = true ; this . moreFieldsOnLine = false ; return this . buffer . toString ( ) ; } | Reads the next field from the input removing quotes as necessary . |
15,927 | public static void addLevelsToDatabase ( final BuildDatabase buildDatabase , final Level level ) { buildDatabase . add ( level ) ; for ( final Level childLevel : level . getChildLevels ( ) ) { addLevelsToDatabase ( buildDatabase , childLevel ) ; } } | Adds the levels in the provided Level object to the content spec database . |
15,928 | public static void setUniqueIds ( final BuildData buildData , final ITopicNode topicNode , final Node node , final Document doc , final Map < SpecTopic , Set < String > > usedIdAttributes ) { boolean isRootNode = doc . getDocumentElement ( ) == node ; final NamedNodeMap attributes = node . getAttributes ( ) ; if ( attributes != null ) { final Node idAttribute ; if ( buildData . getDocBookVersion ( ) == DocBookVersion . DOCBOOK_50 ) { idAttribute = attributes . getNamedItem ( "xml:id" ) ; } else { idAttribute = attributes . getNamedItem ( "id" ) ; } if ( idAttribute != null ) { final String idAttributeValue = idAttribute . getNodeValue ( ) ; String fixedIdAttributeValue = idAttributeValue ; if ( ! isRootNode ) { if ( topicNode . getDuplicateId ( ) != null ) { fixedIdAttributeValue += "-" + topicNode . getDuplicateId ( ) ; } if ( ! DocBookBuildUtilities . isUniqueAttributeId ( buildData , fixedIdAttributeValue , topicNode , usedIdAttributes ) ) { fixedIdAttributeValue += "-" + topicNode . getStep ( ) ; } } setUniqueIdReferences ( doc . getDocumentElement ( ) , idAttributeValue , fixedIdAttributeValue ) ; idAttribute . setNodeValue ( fixedIdAttributeValue ) ; } } final NodeList elements = node . getChildNodes ( ) ; for ( int i = 0 ; i < elements . getLength ( ) ; ++ i ) { setUniqueIds ( buildData , topicNode , elements . item ( i ) , doc , usedIdAttributes ) ; } } | Sets the id attributes in the supplied XML node so that they will be unique within the book . |
15,929 | public static boolean isUniqueAttributeId ( final BuildData buildData , final String id , final ITopicNode topicNode , final Map < SpecTopic , Set < String > > usedIdAttributes ) { if ( topicNode instanceof SpecTopic && id . equals ( ( ( SpecTopic ) topicNode ) . getUniqueLinkId ( buildData . isUseFixedUrls ( ) ) ) ) { return false ; } for ( final Entry < SpecTopic , Set < String > > entry : usedIdAttributes . entrySet ( ) ) { final SpecTopic topic2 = entry . getKey ( ) ; final Integer topicId2 = topic2 . getDBId ( ) ; if ( topicId2 . equals ( topicNode . getDBId ( ) ) ) { continue ; } final Set < String > ids2 = entry . getValue ( ) ; if ( ids2 . contains ( id ) ) { return false ; } } return true ; } | Checks to see if a supplied attribute id is unique within this book based upon the used id attributes that were calculated earlier . |
15,930 | public static void getTopicLinkIds ( final Node node , final Set < String > linkIds ) { if ( node == null ) { return ; } if ( node . getNodeName ( ) . equals ( "xref" ) || node . getNodeName ( ) . equals ( "link" ) ) { final NamedNodeMap attributes = node . getAttributes ( ) ; if ( attributes != null ) { final Node idAttribute = attributes . getNamedItem ( "linkend" ) ; if ( idAttribute != null ) { final String idAttributeValue = idAttribute . getNodeValue ( ) ; linkIds . add ( idAttributeValue ) ; } } } final NodeList elements = node . getChildNodes ( ) ; for ( int i = 0 ; i < elements . getLength ( ) ; ++ i ) { getTopicLinkIds ( elements . item ( i ) , linkIds ) ; } } | Get any ids that are referenced by a link or xref XML attribute within the node . Any ids that are found are added to the passes linkIds set . |
15,931 | public static String generateRevisionNumber ( final ContentSpec contentSpec ) { final StringBuilder rev = new StringBuilder ( ) ; rev . append ( generateRevision ( contentSpec ) ) ; rev . append ( "-" ) ; final Integer pubsnum = contentSpec . getPubsNumber ( ) ; if ( pubsnum == null ) { rev . append ( BuilderConstants . DEFAULT_PUBSNUMBER ) ; } else { rev . append ( pubsnum ) ; } return rev . toString ( ) ; } | Generates the Revision Number to be used in a Revision_History . xml file using the Book Version Edition and Pubsnumber values from a content specification . |
15,932 | public static String generateRevision ( final ContentSpec contentSpec ) { final StringBuilder rev = new StringBuilder ( ) ; final String bookVersion ; if ( contentSpec . getBookVersion ( ) == null ) { bookVersion = contentSpec . getEdition ( ) ; } else { bookVersion = contentSpec . getBookVersion ( ) ; } if ( bookVersion == null ) { rev . append ( BuilderConstants . DEFAULT_EDITION ) . append ( ".0.0" ) ; } else { final String removeContent = bookVersion . replaceAll ( "^(([0-9]+)|([0-9]+.[0-9]+)|([0-9]+.[0-9]+.[0-9]+))" , "" ) ; final String fixedBookVersion = bookVersion . replace ( removeContent , "" ) ; if ( fixedBookVersion . matches ( "^[0-9]+\\.[0-9]+\\.[0-9]+$" ) ) { rev . append ( fixedBookVersion ) ; } else if ( fixedBookVersion . matches ( "^[0-9]+\\.[0-9]+$" ) ) { rev . append ( fixedBookVersion ) . append ( ".0" ) ; } else { rev . append ( fixedBookVersion ) . append ( ".0.0" ) ; } } return rev . toString ( ) ; } | Generates the Revision component of a revnumber to be used in a Revision_History . xml file using the Book Version Edition and Pubsnumber values from a content specification . |
15,933 | public static String cleanUserPublicanCfg ( final String userPublicanCfg ) { String retValue = userPublicanCfg . replaceAll ( "(#( |\\t)*)?xml_lang\\s*:\\s*.*?($|\\r\\n|\\n)" , "" ) ; retValue = retValue . replaceAll ( "(#( |\\t)*)?type\\s*:\\s*.*($|\\r\\n|\\n)" + "" , "" ) ; retValue = retValue . replaceAll ( "(#( |\\t)*)?brand\\s*:\\s*.*($|\\r\\n|\\n)" + "" , "" ) ; retValue = retValue . replaceAll ( "(^|\\n)( |\\t)*dtdver\\s*:\\s*.*($|\\r\\n|\\n)" , "" ) ; retValue = retValue . replaceAll ( "(^|\\n)( |\\t)*mainfile\\s*:\\s*.*($|\\r\\n|\\n)" , "" ) ; retValue = retValue . replaceAll ( "(^|\\n)\\s*" , "$1" ) ; if ( ! retValue . endsWith ( "\n" ) ) { retValue += "\n" ; } return retValue ; } | Clean a user specified publican . cfg to remove content that should be set for a build . |
15,934 | public static Set < Pair < Integer , Integer > > getTopicIdsFromContentSpec ( final ContentSpec contentSpec ) { final Set < Pair < Integer , Integer > > topicIds = new HashSet < Pair < Integer , Integer > > ( ) ; final List < SpecTopic > specTopics = contentSpec . getSpecTopics ( ) ; for ( final SpecTopic specTopic : specTopics ) { if ( specTopic . getDBId ( ) != 0 ) { topicIds . add ( new Pair < Integer , Integer > ( specTopic . getDBId ( ) , specTopic . getRevision ( ) ) ) ; } } return topicIds ; } | Gets a Set of Topic ID s to Revisions from the content specification for each Spec Topic . |
15,935 | public static String addDocBookPreamble ( final DocBookVersion docBookVersion , final String xml , final String elementName , final String entityName ) { if ( docBookVersion == DocBookVersion . DOCBOOK_50 ) { final String xmlWithNamespace = DocBookUtilities . addDocBook50Namespace ( xml , elementName ) ; return XMLUtilities . addDoctype ( xmlWithNamespace , elementName , entityName ) ; } else { return DocBookUtilities . addDocBook45Doctype ( xml , entityName , elementName ) ; } } | Adds any content to the xml that is required for the specified DocBook version . |
15,936 | public static String convertDocumentToCDATAFormattedString ( final Document doc , final XMLFormatProperties xmlFormatProperties ) { return XMLUtilities . wrapStringInCDATA ( convertDocumentToFormattedString ( doc , xmlFormatProperties ) ) ; } | Convert a DOM Document to a Formatted String representation and wrap it in a CDATA element . |
15,937 | public static String getTranslatedTopicBuildKey ( final TranslatedTopicWrapper translatedTopic , final TranslatedCSNodeWrapper translatedCSNode ) { String topicKey = getBaseTopicBuildKey ( translatedTopic ) ; return translatedCSNode == null ? topicKey : ( topicKey + "-" + translatedCSNode . getId ( ) ) ; } | Create a Key that can be used to store a translated topic in a build database . |
15,938 | public static void processTopicID ( final BuildData buildData , final ITopicNode topicNode , final Document doc ) { final BaseTopicWrapper < ? > topic = topicNode . getTopic ( ) ; if ( ! topic . hasTag ( buildData . getServerEntities ( ) . getInfoTagId ( ) ) ) { final String errorXRefID = ( ( SpecNode ) topicNode ) . getUniqueLinkId ( buildData . isUseFixedUrls ( ) ) ; setDOMElementId ( buildData . getDocBookVersion ( ) , doc . getDocumentElement ( ) , errorXRefID ) ; } final Integer topicId = topicNode . getDBId ( ) ; doc . getDocumentElement ( ) . setAttribute ( "remap" , "TID_" + topicId ) ; } | Sets the topic xref id to the topic database id . |
15,939 | public static Document setTopicXMLForError ( final BuildData buildData , final BaseTopicWrapper < ? > topic , final String template ) throws BuildProcessingException { final String errorContent = buildTopicErrorTemplate ( buildData , topic , template ) ; Document doc = null ; try { doc = XMLUtilities . convertStringToDocument ( errorContent ) ; } catch ( Exception ex ) { log . debug ( "Topic Error Template is not valid XML" , ex ) ; throw new BuildProcessingException ( "Failed to convert the Topic Error template into a DOM document" ) ; } if ( DocBookUtilities . TOPIC_ROOT_NODE_NAME . equals ( doc . getDocumentElement ( ) . getNodeName ( ) ) ) { DocBookUtilities . setSectionTitle ( buildData . getDocBookVersion ( ) , topic . getTitle ( ) , doc ) ; } return doc ; } | Sets the XML of the topic to the specified error template . |
15,940 | public static void setTopicNodeXMLForError ( final BuildData buildData , final ITopicNode topicNode , final String template ) throws BuildProcessingException { final BaseTopicWrapper < ? > topic = topicNode . getTopic ( ) ; final Document doc = setTopicXMLForError ( buildData , topic , template ) ; processTopicID ( buildData , topicNode , doc ) ; topicNode . setXMLDocument ( doc ) ; } | Sets the XML of the topic in the content spec to the error template provided . |
15,941 | public static void collectIdAttributes ( final DocBookVersion docBookVersion , final SpecTopic topic , final Node node , final Map < SpecTopic , Set < String > > usedIdAttributes ) { final NamedNodeMap attributes = node . getAttributes ( ) ; if ( attributes != null ) { final Node idAttribute ; if ( docBookVersion == DocBookVersion . DOCBOOK_50 ) { idAttribute = attributes . getNamedItem ( "xml:id" ) ; } else { idAttribute = attributes . getNamedItem ( "id" ) ; } if ( idAttribute != null ) { final String idAttributeValue = idAttribute . getNodeValue ( ) ; if ( ! usedIdAttributes . containsKey ( topic ) ) { usedIdAttributes . put ( topic , new HashSet < String > ( ) ) ; } usedIdAttributes . get ( topic ) . add ( idAttributeValue ) ; } } final NodeList elements = node . getChildNodes ( ) ; for ( int i = 0 ; i < elements . getLength ( ) ; ++ i ) { collectIdAttributes ( docBookVersion , topic , elements . item ( i ) , usedIdAttributes ) ; } } | This function scans the supplied XML node and it s children for id attributes collecting them in the usedIdAttributes parameter . |
15,942 | public String copyProcessParams ( ) { String strProcess = null ; strProcess = Utility . addURLParam ( strProcess , DBParams . LOCAL , this . getProperty ( DBParams . LOCAL ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . REMOTE , this . getProperty ( DBParams . REMOTE ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . TABLE , this . getProperty ( DBParams . TABLE ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . MESSAGE_SERVER , this . getProperty ( DBParams . MESSAGE_SERVER ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . CONNECTION_TYPE , this . getProperty ( DBParams . CONNECTION_TYPE ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . REMOTE_HOST , this . getProperty ( DBParams . REMOTE_HOST ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . CODEBASE , this . getProperty ( DBParams . CODEBASE ) ) ; strProcess = Utility . addURLParam ( strProcess , SQLParams . DATABASE_PRODUCT_PARAM , this . getProperty ( SQLParams . DATABASE_PRODUCT_PARAM ) ) ; strProcess = Utility . addURLParam ( strProcess , DBConstants . SYSTEM_NAME , this . getProperty ( DBConstants . SYSTEM_NAME ) , false ) ; return strProcess ; } | CopyProcessParams Method . |
15,943 | protected boolean doValidationPass ( final ProcessorData processorData ) { if ( ! doFirstValidationPass ( processorData ) ) { return false ; } if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; return false ; } if ( ! doBugLinkValidationPass ( processorData ) ) { log . error ( ProcessorConstants . ERROR_INVALID_CS_MSG ) ; return false ; } if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; return false ; } if ( ! doSecondValidationPass ( processorData ) ) { log . error ( ProcessorConstants . ERROR_INVALID_CS_MSG ) ; return false ; } log . info ( ProcessorConstants . INFO_VALID_CS_MSG ) ; return true ; } | Does a validation pass before processing any data . |
15,944 | protected boolean doFirstValidationPass ( final ProcessorData processorData ) { final ContentSpec contentSpec = processorData . getContentSpec ( ) ; LOG . info ( "Starting first validation pass..." ) ; if ( ! validator . preValidateContentSpec ( contentSpec ) ) { log . error ( ProcessorConstants . ERROR_INVALID_CS_MSG ) ; return false ; } return true ; } | Does the first validation pass on the content spec which does the core validation without doing any rest calls . |
15,945 | protected boolean doBugLinkValidationPass ( final ProcessorData processorData ) { final ContentSpec contentSpec = processorData . getContentSpec ( ) ; boolean valid = true ; if ( processingOptions . isValidateBugLinks ( ) && contentSpec . isInjectBugLinks ( ) ) { boolean reValidateBugLinks = true ; if ( contentSpec . getId ( ) != null ) { ContentSpecWrapper contentSpecEntity = null ; try { contentSpecEntity = providerFactory . getProvider ( ContentSpecProvider . class ) . getContentSpec ( contentSpec . getId ( ) , contentSpec . getRevision ( ) ) ; } catch ( ProviderException e ) { } if ( contentSpecEntity != null ) { boolean weekPassed = false ; if ( processingOptions . isDoBugLinkLastValidateCheck ( ) ) { final PropertyTagInContentSpecWrapper lastValidated = contentSpecEntity . getProperty ( serverEntities . getBugLinksLastValidatedPropertyTagId ( ) ) ; final Date now = new Date ( ) ; final long then ; if ( lastValidated != null && lastValidated . getValue ( ) != null && lastValidated . getValue ( ) . matches ( "^[0-9]+$" ) ) { then = Long . parseLong ( lastValidated . getValue ( ) ) ; } else { then = 0L ; } weekPassed = ( then + WEEK_MILLI_SECS ) <= now . getTime ( ) ; } else { weekPassed = true ; } if ( ! weekPassed ) { boolean changed = false ; final String bugLinksValue = contentSpec . getBugLinksActualValue ( ) == null ? null : contentSpec . getBugLinksActualValue ( ) . toString ( ) ; if ( EntityUtilities . hasContentSpecMetaDataChanged ( CommonConstants . CS_BUG_LINKS_TITLE , bugLinksValue , contentSpecEntity ) ) { changed = true ; } else { BugLinkType bugLinkType = null ; BugLinkOptions bugOptions = null ; if ( contentSpec . getBugLinks ( ) == BugLinkType . JIRA ) { bugLinkType = BugLinkType . JIRA ; bugOptions = contentSpec . getJIRABugLinkOptions ( ) ; } else { bugLinkType = BugLinkType . BUGZILLA ; bugOptions = contentSpec . getBugzillaBugLinkOptions ( ) ; } final BaseBugLinkStrategy bugLinkStrategy = BugLinkStrategyFactory . getInstance ( ) . create ( bugLinkType , bugOptions . getBaseUrl ( ) ) ; if ( bugLinkType != null && bugLinkStrategy . hasValuesChanged ( contentSpecEntity , bugOptions ) ) { changed = true ; } } if ( ! changed ) { reValidateBugLinks = false ; } } } } if ( reValidateBugLinks ) { processorData . setBugLinksReValidated ( reValidateBugLinks ) ; LOG . info ( "Starting bug link validation pass..." ) ; if ( ! validator . postValidateBugLinks ( contentSpec , processingOptions . isStrictBugLinks ( ) ) ) { valid = false ; } } } return valid ; } | Checks if bug links should be validated and performs the validation if required . |
15,946 | protected boolean doSecondValidationPass ( final ProcessorData processorData ) { LOG . info ( "Starting second validation pass..." ) ; final ContentSpec contentSpec = processorData . getContentSpec ( ) ; return validator . postValidateContentSpec ( contentSpec , processorData . getUsername ( ) ) ; } | Does the post Validation step on a Content Spec . |
15,947 | protected boolean saveContentSpec ( final DataProviderFactory providerFactory , final ProcessorData processorData , final boolean edit ) { final ContentSpecProvider contentSpecProvider = providerFactory . getProvider ( ContentSpecProvider . class ) ; try { final ContentSpec contentSpec = processorData . contentSpec ; final LocaleWrapper locale = contentSpec . getLocale ( ) != null ? EntityUtilities . findLocaleFromString ( serverSettings . getLocales ( ) , contentSpec . getLocale ( ) ) : serverSettings . getDefaultLocale ( ) ; final List < ITopicNode > topicNodes = contentSpec . getAllTopicNodes ( ) ; final Map < ITopicNode , ITopicNode > duplicatedTopicMap = createDuplicatedTopicMap ( topicNodes ) ; createOrUpdateTopics ( topicNodes , topics , processorData , locale ) ; if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; throw new ProcessingException ( "Shutdown Requested" ) ; } if ( ! topics . savePool ( ) ) { log . error ( ProcessorConstants . ERROR_DATABASE_ERROR_MSG ) ; throw new ProcessingException ( "Failed to save the pool of topics." ) ; } for ( final ITopicNode topicNode : topicNodes ) { topics . initialiseFromPool ( topicNode ) ; cleanSpecTopicWhenCreatedOrUpdated ( topicNode ) ; } syncDuplicatedTopics ( duplicatedTopicMap ) ; mergeAndSaveContentSpec ( providerFactory , processorData , ! edit ) ; } catch ( ProcessingException e ) { LOG . debug ( "" , e ) ; if ( providerFactory . isTransactionsSupported ( ) ) { providerFactory . rollback ( ) ; } else { if ( processorData . getContentSpec ( ) . getId ( ) != null && ! edit ) { try { contentSpecProvider . deleteContentSpec ( processorData . getContentSpec ( ) . getId ( ) ) ; } catch ( Exception e1 ) { log . error ( "Unable to clean up the Content Specification from the database." , e ) ; } } if ( topics . isInitialised ( ) ) topics . rollbackPool ( ) ; } return false ; } catch ( Exception e ) { LOG . error ( "" , e ) ; if ( providerFactory . isTransactionsSupported ( ) ) { providerFactory . rollback ( ) ; } else { if ( processorData . getContentSpec ( ) . getId ( ) != null && ! edit ) { try { contentSpecProvider . deleteContentSpec ( processorData . getContentSpec ( ) . getId ( ) ) ; } catch ( Exception e1 ) { log . error ( "Unable to clean up the Content Specification from the database." , e ) ; } } if ( topics . isInitialised ( ) ) topics . rollbackPool ( ) ; } log . debug ( "" , e ) ; return false ; } return true ; } | Saves the Content Specification and all of the topics in the content specification |
15,948 | protected void cleanSpecTopicWhenCreatedOrUpdated ( final ITopicNode topicNode ) { topicNode . setDescription ( null ) ; topicNode . setTags ( new ArrayList < String > ( ) ) ; topicNode . setRemoveTags ( new ArrayList < String > ( ) ) ; topicNode . setAssignedWriter ( null ) ; if ( topicNode instanceof SpecTopic ) { final SpecTopic specTopic = ( SpecTopic ) topicNode ; specTopic . setSourceUrls ( new ArrayList < String > ( ) ) ; specTopic . setType ( null ) ; } } | Cleans a SpecTopic to reset any content that should be removed in a post processed content spec . |
15,949 | protected TopicWrapper createTopicEntity ( final DataProviderFactory providerFactory , final ITopicNode topicNode , final String docBookVersion , final LocaleWrapper locale ) throws ProcessingException { LOG . debug ( "Processing topic: {}" , topicNode . getText ( ) ) ; if ( topicNode . isTopicAClonedDuplicateTopic ( ) || topicNode . isTopicADuplicateTopic ( ) ) return null ; final TagProvider tagProvider = providerFactory . getProvider ( TagProvider . class ) ; final TopicSourceURLProvider topicSourceURLProvider = providerFactory . getProvider ( TopicSourceURLProvider . class ) ; if ( isShuttingDown . get ( ) ) { return null ; } boolean changed = topicNode . isTopicAClonedTopic ( ) || topicNode . isTopicANewTopic ( ) ; final TopicWrapper topic = getTopicForTopicNode ( providerFactory , topicNode ) ; if ( topic == null ) { throw new ProcessingException ( "Creating a topic failed." ) ; } if ( isShuttingDown . get ( ) ) { return null ; } if ( processTopicTags ( tagProvider , topicNode , topic ) ) { changed = true ; } if ( isShuttingDown . get ( ) ) { return null ; } if ( ! topicNode . isTopicAnExistingTopic ( ) && ! isNullOrEmpty ( topicNode . getAssignedWriter ( true ) ) ) { processAssignedWriter ( tagProvider , topicNode , topic ) ; changed = true ; } if ( isShuttingDown . get ( ) ) { return null ; } if ( topicNode instanceof SpecTopic && ! topicNode . isTopicAnExistingTopic ( ) ) { if ( processTopicSourceUrls ( topicSourceURLProvider , ( SpecTopic ) topicNode , topic ) ) changed = true ; } if ( isShuttingDown . get ( ) ) { return null ; } if ( ! topicNode . isTopicAnExistingTopic ( ) ) { if ( docBookVersion . equals ( CommonConstants . DOCBOOK_45_TITLE ) && ( topic . getXmlFormat ( ) == null || topic . getXmlFormat ( ) != CommonConstants . DOCBOOK_45 ) ) { topic . setXmlFormat ( CommonConstants . DOCBOOK_45 ) ; changed = true ; } else if ( docBookVersion . equals ( CommonConstants . DOCBOOK_50_TITLE ) && ( topic . getXmlFormat ( ) == null || topic . getXmlFormat ( ) != CommonConstants . DOCBOOK_50 ) ) { topic . setXmlFormat ( CommonConstants . DOCBOOK_50 ) ; changed = true ; } if ( locale != null && ! locale . equals ( topic . getLocale ( ) ) ) { topic . setLocale ( locale ) ; changed = true ; } } if ( isShuttingDown . get ( ) ) { return null ; } if ( changed ) { if ( topicNode . isTopicAClonedTopic ( ) || topicNode . isTopicANewTopic ( ) ) { setCSPPropertyForTopic ( topic , topicNode , providerFactory . getProvider ( PropertyTagProvider . class ) ) ; } return topic ; } else { return null ; } } | Creates an entity to be sent through the REST interface to create or update a DB entry . |
15,950 | protected TopicWrapper getTopicForTopicNode ( final DataProviderFactory providerFactory , final ITopicNode topicNode ) { TopicWrapper topic = null ; if ( topicNode . isTopicANewTopic ( ) ) { topic = getTopicForNewTopicNode ( providerFactory , topicNode ) ; } else if ( topicNode . isTopicAClonedTopic ( ) ) { topic = ProcessorUtilities . cloneTopic ( providerFactory , topicNode , serverEntities ) ; } else if ( topicNode . isTopicAnExistingTopic ( ) ) { topic = getTopicForExistingTopicNode ( providerFactory , topicNode ) ; } return topic ; } | Gets or creates the underlying Topic Entity for a spec topic . |
15,951 | protected boolean processTopicTags ( final TagProvider tagProvider , final ITopicNode specTopic , final TopicWrapper topic ) { LOG . debug ( "Processing topic tags" ) ; boolean changed = false ; final List < String > addTagNames = specTopic . getTags ( true ) ; final List < TagWrapper > addTags = new ArrayList < TagWrapper > ( ) ; for ( final String addTagName : addTagNames ) { final TagWrapper tag = tagProvider . getTagByName ( addTagName ) ; if ( tag != null ) { addTags . add ( tag ) ; } } if ( isShuttingDown . get ( ) ) { return changed ; } if ( specTopic . isTopicAClonedTopic ( ) ) { if ( processClonedTopicTags ( tagProvider , specTopic , topic , addTags ) ) changed = true ; } else if ( specTopic . isTopicAnExistingTopic ( ) && specTopic . getRevision ( ) == null ) { if ( processExistingTopicTags ( tagProvider , topic , addTags ) ) changed = true ; } else if ( specTopic . isTopicANewTopic ( ) ) { if ( processNewTopicTags ( tagProvider , topic , addTags ) ) changed = true ; } return changed ; } | Process a Spec Topic and add or remove tags defined by the spec topic . |
15,952 | protected void processAssignedWriter ( final TagProvider tagProvider , final ITopicNode topicNode , final TopicWrapper topic ) { LOG . debug ( "Processing assigned writer" ) ; if ( topic . getTags ( ) == null ) { topic . setTags ( tagProvider . newTagCollection ( ) ) ; } final TagWrapper writerTag = tagProvider . getTagByName ( topicNode . getAssignedWriter ( true ) ) ; topic . getTags ( ) . addNewItem ( writerTag ) ; topic . setTags ( topic . getTags ( ) ) ; } | Processes a Spec Topic and adds the assigned writer for the topic it represents . |
15,953 | protected boolean processTopicSourceUrls ( final TopicSourceURLProvider topicSourceURLProvider , final SpecTopic specTopic , final TopicWrapper topic ) { LOG . debug ( "Processing topic source urls" ) ; boolean changed = false ; final List < String > urls = specTopic . getSourceUrls ( true ) ; if ( urls != null && ! urls . isEmpty ( ) ) { final UpdateableCollectionWrapper < TopicSourceURLWrapper > sourceUrls = topic . getSourceURLs ( ) == null ? topicSourceURLProvider . newTopicSourceURLCollection ( topic ) : topic . getSourceURLs ( ) ; for ( final String url : urls ) { final TopicSourceURLWrapper sourceUrl = topicSourceURLProvider . newTopicSourceURL ( topic ) ; sourceUrl . setUrl ( url ) ; sourceUrls . addNewItem ( sourceUrl ) ; } topic . setSourceURLs ( sourceUrls ) ; changed = true ; } return changed ; } | Processes a Spec Topic and adds any new Source Urls to the topic it represents . |
15,954 | protected void syncDuplicatedTopics ( final Map < ITopicNode , ITopicNode > duplicatedTopics ) { for ( final Map . Entry < ITopicNode , ITopicNode > topicEntry : duplicatedTopics . entrySet ( ) ) { final ITopicNode topic = topicEntry . getKey ( ) ; final ITopicNode cloneTopic = topicEntry . getValue ( ) ; topic . setId ( cloneTopic . getDBId ( ) == null ? null : cloneTopic . getDBId ( ) . toString ( ) ) ; } } | Syncs all duplicated topics with their real topic counterpart in the content specification . |
15,955 | protected CSNodeWrapper findExistingNode ( final CSNodeWrapper parent , final Node childNode , final List < CSNodeWrapper > entityChildrenNodes ) { CSNodeWrapper foundNodeEntity = null ; if ( entityChildrenNodes != null && ! entityChildrenNodes . isEmpty ( ) ) { for ( final CSNodeWrapper nodeEntity : entityChildrenNodes ) { if ( ! doesParentMatch ( parent , nodeEntity . getParent ( ) ) ) { continue ; } if ( childNode instanceof Comment ) { if ( doesCommentMatch ( ( Comment ) childNode , nodeEntity , foundNodeEntity != null ) ) { foundNodeEntity = nodeEntity ; } } else if ( childNode instanceof Level ) { if ( doesLevelMatch ( ( Level ) childNode , nodeEntity , foundNodeEntity != null ) ) { foundNodeEntity = nodeEntity ; } if ( parent != null && foundNodeEntity != null && foundNodeEntity . getTitle ( ) . equals ( ( ( Level ) childNode ) . getTitle ( ) ) ) { break ; } } else { if ( childNode instanceof SpecTopic && doesTopicMatch ( ( SpecTopic ) childNode , nodeEntity , foundNodeEntity != null ) ) { foundNodeEntity = nodeEntity ; } else if ( childNode instanceof CommonContent && doesCommonContentMatch ( ( CommonContent ) childNode , nodeEntity , foundNodeEntity != null ) ) { foundNodeEntity = nodeEntity ; } else if ( childNode instanceof KeyValueNode && doesMetaDataMatch ( ( KeyValueNode < ? > ) childNode , nodeEntity ) ) { foundNodeEntity = nodeEntity ; } else if ( childNode instanceof File && doesFileMatch ( ( File ) childNode , nodeEntity ) ) { foundNodeEntity = nodeEntity ; } } } } return foundNodeEntity ; } | Finds the existing Entity Node that matches a ContentSpec node . |
15,956 | protected boolean doesParentMatch ( final CSNodeWrapper parent , final CSNodeWrapper entityParent ) { if ( parent != null && entityParent != null ) { if ( parent . getId ( ) != null && parent . getId ( ) . equals ( entityParent . getId ( ) ) ) { return true ; } else if ( parent . getId ( ) == null && entityParent . getId ( ) == null && parent == entityParent ) { return true ; } else { return false ; } } else if ( parent == null && entityParent == null ) { return true ; } else { return false ; } } | Checks to see if two parent nodes match |
15,957 | protected boolean mergeMetaData ( final KeyValueNode < ? > metaData , final CSNodeWrapper metaDataEntity ) { boolean changed = false ; final Object value = metaData . getValue ( ) ; if ( metaData instanceof FileList ) { if ( metaDataEntity . getAdditionalText ( ) != null ) { metaDataEntity . setAdditionalText ( null ) ; changed = true ; } } else { if ( metaDataEntity . getAdditionalText ( ) == null || ! metaDataEntity . getAdditionalText ( ) . equals ( value . toString ( ) ) ) { metaDataEntity . setAdditionalText ( value . toString ( ) ) ; changed = true ; } } if ( metaDataEntity . getNodeType ( ) != null ) { if ( value instanceof SpecTopic && ! metaDataEntity . getNodeType ( ) . equals ( CommonConstants . CS_NODE_META_DATA_TOPIC ) ) { metaDataEntity . setNodeType ( CommonConstants . CS_NODE_META_DATA_TOPIC ) ; } else if ( ! ( value instanceof SpecTopic ) && ! metaDataEntity . getNodeType ( ) . equals ( CommonConstants . CS_NODE_META_DATA ) ) { metaDataEntity . setNodeType ( CommonConstants . CS_NODE_META_DATA ) ; } } if ( value instanceof SpecTopic ) { if ( mergeTopic ( ( SpecTopic ) value , metaDataEntity ) ) { changed = true ; } } if ( metaDataEntity . getTitle ( ) == null || ! metaDataEntity . getTitle ( ) . equals ( metaData . getKey ( ) ) ) { metaDataEntity . setTitle ( metaData . getKey ( ) ) ; changed = true ; } return changed ; } | Merges a Content Specs meta data with a Content Spec Entities meta data |
15,958 | protected void mergeRelationships ( final Map < SpecNode , CSNodeWrapper > nodeMapping , final DataProviderFactory providerFactory ) { final CSNodeProvider nodeProvider = providerFactory . getProvider ( CSNodeProvider . class ) ; for ( final Map . Entry < SpecNode , CSNodeWrapper > nodes : nodeMapping . entrySet ( ) ) { if ( ! ( nodes . getKey ( ) instanceof SpecNodeWithRelationships ) ) continue ; final SpecNodeWithRelationships specNode = ( SpecNodeWithRelationships ) nodes . getKey ( ) ; final CSNodeWrapper entity = nodes . getValue ( ) ; if ( ! specNode . getRelationships ( ) . isEmpty ( ) || entity . getRelatedToNodes ( ) != null && ! entity . getRelatedToNodes ( ) . isEmpty ( ) ) { mergeRelationship ( nodeMapping , specNode , entity , nodeProvider ) ; } } } | Merges the relationships for all Spec Topics into their counterpart Entity nodes . |
15,959 | protected CSRelatedNodeWrapper findExistingRelatedNode ( final Relationship relationship , final List < CSRelatedNodeWrapper > topicRelatedNodes ) { if ( topicRelatedNodes != null ) { for ( final CSRelatedNodeWrapper relatedNode : topicRelatedNodes ) { if ( relationship instanceof TargetRelationship ) { if ( doesRelationshipMatch ( ( TargetRelationship ) relationship , relatedNode ) ) { return relatedNode ; } } else { if ( doesRelationshipMatch ( ( TopicRelationship ) relationship , relatedNode ) ) { return relatedNode ; } } } } return null ; } | Finds an existing relationship for a topic . |
15,960 | protected List < Node > getTransformableNodes ( final List < Node > childNodes ) { final List < Node > nodes = new LinkedList < Node > ( ) ; for ( final Node childNode : childNodes ) { if ( isTransformableNode ( childNode ) ) { nodes . add ( childNode ) ; } } return nodes ; } | Gets a list of child nodes that can be transformed . |
15,961 | protected boolean isTransformableNode ( final Node childNode ) { if ( childNode instanceof KeyValueNode ) { return ! IGNORE_META_DATA . contains ( ( ( KeyValueNode ) childNode ) . getKey ( ) ) ; } else { return childNode instanceof SpecNode || childNode instanceof Comment || childNode instanceof Level || childNode instanceof File ; } } | Checks to see if a node is a node that can be transformed and saved |
15,962 | protected boolean doesMetaDataMatch ( final KeyValueNode < ? > metaData , final CSNodeWrapper node ) { if ( ! ( node . getNodeType ( ) . equals ( CommonConstants . CS_NODE_META_DATA ) || node . getNodeType ( ) . equals ( CommonConstants . CS_NODE_META_DATA_TOPIC ) ) ) return false ; if ( metaData . getUniqueId ( ) != null && metaData . getUniqueId ( ) . matches ( "^\\d.*" ) ) { return metaData . getUniqueId ( ) . equals ( Integer . toString ( node . getId ( ) ) ) ; } else { if ( metaData . getKey ( ) . equals ( CommonConstants . CS_ABSTRACT_TITLE ) && node . getTitle ( ) . equals ( CommonConstants . CS_ABSTRACT_ALTERNATE_TITLE ) ) { return true ; } if ( metaData . getKey ( ) . equals ( CommonConstants . CS_FILE_TITLE ) && node . getTitle ( ) . equals ( CommonConstants . CS_FILE_SHORT_TITLE ) ) { return true ; } return metaData . getKey ( ) . equals ( node . getTitle ( ) ) ; } } | Checks to see if a ContentSpec meta data matches a Content Spec Entity meta data . |
15,963 | protected boolean doesLevelMatch ( final Level level , final CSNodeWrapper node , boolean matchContent ) { if ( ! EntityUtilities . isNodeALevel ( node ) ) return false ; if ( level . getUniqueId ( ) != null && level . getUniqueId ( ) . matches ( "^\\d.*" ) ) { return level . getUniqueId ( ) . equals ( Integer . toString ( node . getId ( ) ) ) ; } else { if ( level . getTargetId ( ) != null && level . getTargetId ( ) == node . getTargetId ( ) ) { return true ; } if ( matchContent ) { if ( node . getNodeType ( ) != level . getLevelType ( ) . getId ( ) ) return false ; return level . getTitle ( ) . equals ( node . getTitle ( ) ) ; } else { return StringUtilities . similarDamerauLevenshtein ( level . getTitle ( ) , node . getTitle ( ) ) >= ProcessorConstants . MIN_MATCH_SIMILARITY ; } } } | Checks to see if a ContentSpec level matches a Content Spec Entity level . |
15,964 | protected boolean doesFileMatch ( final File file , final CSNodeWrapper node ) { if ( ! node . getNodeType ( ) . equals ( CommonConstants . CS_NODE_FILE ) ) return false ; if ( file . getUniqueId ( ) != null && file . getUniqueId ( ) . matches ( "^\\d.*" ) ) { return file . getUniqueId ( ) . equals ( Integer . toString ( node . getId ( ) ) ) ; } else { return file . getId ( ) . equals ( node . getEntityId ( ) ) ; } } | Checks to see if a ContentSpec topic matches a Content Spec Entity file . |
15,965 | protected boolean doesCommentMatch ( final Comment comment , final CSNodeWrapper node , boolean matchContent ) { if ( ! node . getNodeType ( ) . equals ( CommonConstants . CS_NODE_COMMENT ) ) return false ; if ( comment . getUniqueId ( ) != null && comment . getUniqueId ( ) . matches ( "^\\d.*" ) ) { return comment . getUniqueId ( ) . equals ( Integer . toString ( node . getId ( ) ) ) ; } else if ( matchContent ) { return StringUtilities . similarDamerauLevenshtein ( comment . getText ( ) , node . getTitle ( ) ) >= ProcessorConstants . MIN_MATCH_SIMILARITY ; } else { if ( comment . getParent ( ) != null ) { if ( comment . getParent ( ) instanceof ContentSpec ) { return node . getParent ( ) == null ; } else if ( comment . getParent ( ) instanceof Level && node . getParent ( ) != null ) { final Level parent = ( ( Level ) comment . getParent ( ) ) ; return parent . getTitle ( ) . equals ( node . getParent ( ) . getTitle ( ) ) ; } else { return false ; } } return true ; } } | Checks to see if a ContentSpec comment matches a Content Spec Entity comment . |
15,966 | protected boolean doesCommonContentMatch ( final CommonContent commonContent , final CSNodeWrapper node , boolean matchContent ) { if ( ! node . getNodeType ( ) . equals ( CommonConstants . CS_NODE_COMMON_CONTENT ) ) return false ; if ( commonContent . getUniqueId ( ) != null && commonContent . getUniqueId ( ) . matches ( "^\\d.*" ) ) { return commonContent . getUniqueId ( ) . equals ( Integer . toString ( node . getId ( ) ) ) ; } else if ( matchContent ) { return StringUtilities . similarDamerauLevenshtein ( commonContent . getTitle ( ) , node . getTitle ( ) ) >= ProcessorConstants . MIN_MATCH_SIMILARITY ; } else { if ( commonContent . getParent ( ) != null ) { return commonContent . getParent ( ) . getTitle ( ) . equals ( node . getParent ( ) . getTitle ( ) ) ; } return true ; } } | Checks to see if a ContentSpec Common Content matches a Content Spec Entity Common Content . |
15,967 | public ScheduledFuture < ? > schedule ( Runnable command , TemporalAccessor time ) { ensureWaiterRunning ( ) ; log ( logLevel , "schedule(%s, %s)" , command , time ) ; RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl ( command , Instant . from ( time ) , null , false ) ; delayQueue . add ( future ) ; return future ; } | Schedule command to be run not earlier than time . |
15,968 | public < V > ScheduledFuture < V > schedule ( Callable < V > callable , TemporalAccessor time ) { ensureWaiterRunning ( ) ; log ( logLevel , "schedule(%s, %s)" , callable , time ) ; RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl ( callable , Instant . from ( time ) , null , false ) ; delayQueue . add ( future ) ; return future ; } | Schedule callable to be run not earlier than time . |
15,969 | public ScheduledFuture < ? > iterateAtFixedRate ( long initialDelay , long period , TimeUnit unit , Runnable ... commands ) { return iterateAtFixedRate ( initialDelay , period , unit , new ArrayIterator < > ( commands ) ) ; } | After initialDelay executes commands with period delay or command throws exception . |
15,970 | public ScheduledFuture < ? > iterateAtFixedRate ( long initialDelay , long period , TimeUnit unit , Collection < Runnable > commands ) { return iterateAtFixedRate ( initialDelay , period , unit , commands . iterator ( ) ) ; } | After initialDelay executes commands using collections iterator until either iterator has no more commands or command throws exception . |
15,971 | public ScheduledFuture < ? > iterateAtFixedRate ( long initialDelay , long period , TimeUnit unit , Iterator < Runnable > commands ) { ensureWaiterRunning ( ) ; log ( logLevel , "iterateAtFixedRate(%d, %d, %s)" , initialDelay , period , unit ) ; RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl ( new RunnableIterator ( commands ) , initialDelay , period , unit , false ) ; delayQueue . add ( future ) ; return future ; } | After initialDelay executes commands from iterator until either iterator has no more or command throws exception . |
15,972 | public Runnable concat ( Runnable ... runnables ) { if ( runnables . length == 0 ) { throw new IllegalArgumentException ( "empty" ) ; } Runnable r = runnables [ runnables . length - 1 ] ; for ( int ii = runnables . length - 2 ; ii >= 0 ; ii -- ) { r = concat ( runnables [ ii ] , r ) ; } return r ; } | Concatenates tasks to one task . After first tasks run is completed next start is submitted and so on until all tasks are run or exception is thrown . run is completed . |
15,973 | public < V > Future < V > submitAfter ( Waiter waiter , Callable < V > callable , long timeout , TimeUnit unit ) { AfterTask < V > task = new AfterTask < > ( waiter , callable , timeout , unit ) ; log ( logLevel , "submit after task %s" , task ) ; return ( Future < V > ) submit ( task ) ; } | submits callable after waiting future to complete or timeout to exceed . If timeout exceeds task is cancelled . |
15,974 | public Future < ? > submitAfter ( Waiter waiter , Runnable runnable , long timeout , TimeUnit unit ) { AfterTask < ? > task = new AfterTask < > ( waiter , runnable , timeout , unit ) ; log ( logLevel , "submit after task %s" , task ) ; return submit ( task ) ; } | submits runnable after waiting future to complete or timeout to exceed . If timeout exceeds task is cancelled . |
15,975 | protected boolean matches ( PDF pdf ) { try ( InputStream inStream = pdf . openStream ( ) ) { final PDDocument doc = PDDocument . load ( inStream ) ; return matchesPDF ( doc ) ; } catch ( IOException e ) { LOG . debug ( "Could not load PDF document" , e ) ; return false ; } } | Is invoked by the matches method when the type of the target object is verified . Override this method to add verifications on the raw data instead of a loaded document . |
15,976 | public Record getCurrentLevelInfo ( int iOffsetFromCurrentLevel , Record record ) { int dLevel = ( int ) this . getScreenRecord ( ) . getField ( ProjectTaskScreenRecord . CURRENT_LEVEL ) . getValue ( ) ; dLevel = dLevel + iOffsetFromCurrentLevel ; this . getScreenRecord ( ) . getField ( ProjectTaskScreenRecord . CURRENT_LEVEL ) . setValue ( dLevel ) ; if ( m_rgCurrentLevelInfo . size ( ) >= dLevel ) { try { m_rgCurrentLevelInfo . add ( ( Record ) record . clone ( ) ) ; m_rgCurrentLevelInfo . elementAt ( dLevel ) . setKeyArea ( ProjectTask . PARENT_PROJECT_TASK_ID_KEY ) ; } catch ( CloneNotSupportedException ex ) { ex . printStackTrace ( ) ; } } return m_rgCurrentLevelInfo . elementAt ( dLevel ) ; } | Add to the current level then get the record at this level If the record doesn t exist clone a new one and return it . |
15,977 | public static void fixDisplayedText ( final RESTTextContentSpecV1 source ) { if ( source . getFailedContentSpec ( ) != null ) { source . setText ( source . getFailedContentSpec ( ) ) ; } } | If the last save of the content spec was not valid the text field will display the last valid state the errors field will be populated and the failedContentSpec will have the invalid spec text . |
15,978 | public Iterator < Record > getSource ( ) { String strURL = this . getProperty ( "source" ) ; if ( strURL == null ) return null ; Reader reader = null ; try { URL url = new URL ( strURL ) ; InputStream inputStream = url . openStream ( ) ; InputStreamReader inStream = new InputStreamReader ( inputStream ) ; reader = inStream ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } Record record = this . getMergeRecord ( ) ; SaxHtmlHandler handler = this . getSaxHandler ( record ) ; return new HtmlSource ( reader , record , handler ) ; } | GetSource Method . |
15,979 | public void doFilter ( ServletRequest servletRequest , ServletResponse servletResponse , FilterChain filterChain ) throws IOException , ServletException { HttpServletRequest request = ( HttpServletRequest ) servletRequest ; String uri = request . getRequestURI ( ) ; if ( ! uri . endsWith ( ".js" ) ) { filterChain . doFilter ( servletRequest , servletResponse ) ; return ; } if ( CACHE . containsKey ( uri ) ) { ModifiedServletResponse cr = CACHE . get ( uri ) ; cr . copyToResponse ( servletResponse ) ; return ; } HttpServletResponseWrapperImpl wrapper = new HttpServletResponseWrapperImpl ( servletResponse ) ; filterChain . doFilter ( servletRequest , wrapper ) ; wrapper . flushBuffer ( ) ; byte [ ] bytes = wrapper . getBytes ( ) ; if ( bytes == null || bytes . length == 0 ) { wrapper . copyToResponse ( servletResponse ) ; return ; } final String type = wrapper . getContentType ( ) ; final String encoding = wrapper . getCharacterEncoding ( ) ; LOGGER . info ( "Content encoding being sent to client: " + encoding ) ; LOGGER . info ( "Content type being sent to client: " + type ) ; if ( type != null && ! isJavascript ( type ) ) { wrapper . copyToResponse ( servletResponse ) ; return ; } wrapper . addHeader ( "X-Jerry-Minified" , "true" ) ; byte [ ] newBytes = bytes ; if ( isGZip ( bytes ) ) { newBytes = unGZip ( bytes ) ; } if ( newBytes == null ) { wrapper . copyToResponse ( servletResponse ) ; return ; } String jsCode = null ; if ( encoding != null ) { try { jsCode = new String ( newBytes , encoding ) ; } catch ( UnsupportedEncodingException e ) { LOGGER . error ( "Unable to encode byte response to string for encoding: " + encoding , e ) ; } } else { jsCode = new String ( newBytes ) ; } String compressedCode = null ; try { compressedCode = compressJavascriptEmbedded ( uri , jsCode ) ; } catch ( Exception e ) { LOGGER . error ( "Unable to compress Javascript at URL: " + uri , e ) ; wrapper . copyToResponse ( servletResponse ) ; return ; } if ( encoding != null ) { bytes = compressedCode . getBytes ( encoding ) ; } else { bytes = compressedCode . getBytes ( ) ; } ResponseUtils . setCacheHeaders ( wrapper , DateUtils . ONE_MONTH ) ; ModifiedServletResponse cr = new ModifiedServletResponse ( wrapper , bytes ) ; CACHE . put ( uri , cr ) ; cr . copyToResponse ( servletResponse ) ; } | Compress JS and CSS files using the Google compiler . |
15,980 | private boolean isJavascript ( String type ) { if ( "text/javascript" . equalsIgnoreCase ( type ) ) { return true ; } if ( "application/x-javascript" . equalsIgnoreCase ( type ) ) { return true ; } return false ; } | Check if the resource is javascript or not . |
15,981 | private String compressJavascriptEmbedded ( final String uri , final String code ) { if ( code == null || code . isEmpty ( ) ) { return code ; } int index = uri . lastIndexOf ( '/' ) ; String name = uri ; if ( index > 0 ) { name = uri . substring ( index + 1 ) ; } List < SourceFile > externs = Collections . emptyList ( ) ; List < SourceFile > inputs = Arrays . asList ( SourceFile . fromCode ( name , code ) ) ; CompilerOptions options = new CompilerOptions ( ) ; CompilationLevel . SIMPLE_OPTIMIZATIONS . setOptionsForCompilationLevel ( options ) ; com . google . javascript . jscomp . Compiler compiler = new com . google . javascript . jscomp . Compiler ( ) ; Result result = compiler . compile ( externs , inputs , options ) ; if ( result . success ) { return compiler . toSource ( ) ; } throw new IllegalArgumentException ( "Unable to compress javascript" ) ; } | Compress the Javascript . |
15,982 | private byte [ ] unGZip ( byte [ ] bytes ) { if ( bytes == null || bytes . length == 0 ) { return bytes ; } GZIPInputStream gzis = null ; ByteArrayOutputStream baos = null ; try { gzis = new GZIPInputStream ( new ByteArrayInputStream ( bytes ) ) ; baos = new ByteArrayOutputStream ( ) ; int len ; byte [ ] buffer = new byte [ 1024 ] ; while ( ( len = gzis . read ( buffer ) ) > 0 ) { baos . write ( buffer , 0 , len ) ; } return baos . toByteArray ( ) ; } catch ( IOException e ) { } finally { if ( gzis != null ) { try { gzis . close ( ) ; } catch ( IOException e ) { } } if ( baos != null ) { try { baos . close ( ) ; } catch ( IOException e ) { } } } return null ; } | UnGZIP a given byte stream . |
15,983 | private boolean isGZip ( byte [ ] bytes ) { if ( bytes == null || bytes . length == 0 ) { return false ; } if ( bytes [ 0 ] == 31 && ( bytes [ 1 ] == 0x8b || bytes [ 1 ] == - 117 ) ) { return true ; } return false ; } | Check if a byte stream is GZIP compressed or not . |
15,984 | public int submitSingle ( T item ) { if ( Objects . isNull ( item ) ) return 0 ; synchronized ( this . dataList ) { this . dataList . add ( item ) ; setLastDataTimestamp ( ) ; if ( this . dataList . size ( ) >= this . bulkSize ) flush ( ) ; return 1 ; } } | Submit single int . |
15,985 | public static PrintFields parse ( final String printFields ) { Validate . notNull ( printFields , "PrintFields must not be null" ) ; final Set < String > printFieldsSet = new LinkedHashSet < String > ( Arrays . asList ( SEPARATORS . split ( printFields ) ) ) ; printFieldsSet . remove ( "" ) ; return new PrintFields ( printFieldsSet ) ; } | Parser for a printfields string . |
15,986 | public ClassProject . CodeType getCodeType ( ) { String code = this . toString ( ) ; if ( "THICK" . equalsIgnoreCase ( code ) ) return ClassProject . CodeType . THICK ; if ( "THIN" . equalsIgnoreCase ( code ) ) return ClassProject . CodeType . THIN ; if ( "RESOURCE_CODE" . equalsIgnoreCase ( code ) ) return ClassProject . CodeType . RESOURCE_CODE ; if ( "RESOURCE_PROPERTIES" . equalsIgnoreCase ( code ) ) return ClassProject . CodeType . RESOURCE_PROPERTIES ; if ( "INTERFACE" . equalsIgnoreCase ( code ) ) return ClassProject . CodeType . INTERFACE ; return null ; } | GetCodeType Method . |
15,987 | public int setCodeType ( ClassProject . CodeType codeType ) { String codeString = null ; if ( codeType == ClassProject . CodeType . THICK ) codeString = "THICK" ; if ( codeType == ClassProject . CodeType . THIN ) codeString = "THIN" ; if ( codeType == ClassProject . CodeType . RESOURCE_CODE ) codeString = "RESOURCE_CODE" ; if ( codeType == ClassProject . CodeType . RESOURCE_PROPERTIES ) codeString = "RESOURCE_PROPERTIES" ; if ( codeType == ClassProject . CodeType . INTERFACE ) codeString = "INTERFACE" ; return this . setString ( codeString ) ; } | SetCodeType Method . |
15,988 | JsonNode sendRequest ( RequestBuilder requestBuilder ) throws IOException , GroovesharkException { createSessionIfRequired ( ) ; session . createCommsTokenAsRequired ( ) ; boolean sessionAlreadyRenewed = false ; boolean commsTokenAlreadyRenewed = false ; while ( true ) { if ( ! sessionAlreadyRenewed ) { createSessionIfRequired ( ) ; } if ( ! commsTokenAlreadyRenewed ) { session . createCommsTokenAsRequired ( ) ; } HttpPost httpRequest = requestBuilder . build ( session ) ; try { JsonNode jsonNode = executeRequest ( httpRequest ) ; GroovesharkException exception = mapGroovesharkFaultCodeToException ( jsonNode ) ; if ( exception != null ) { if ( exception instanceof GroovesharkException . InvalidSessionException ) { if ( sessionAlreadyRenewed ) { throw new GroovesharkException . ServerErrorException ( "Failed with invalid session. Renewed session still invalid." ) ; } else { createSession ( ) ; sessionAlreadyRenewed = true ; continue ; } } else if ( exception instanceof GroovesharkException . InvalidCommsTokenException ) { if ( commsTokenAlreadyRenewed ) { throw new GroovesharkException . ServerErrorException ( "Failed with invalid comms token. Renewed token also invalid." ) ; } else { session . createCommsToken ( ) ; commsTokenAlreadyRenewed = true ; continue ; } } else { throw exception ; } } return jsonNode ; } finally { httpRequest . reset ( ) ; } } } | Sends a request and keeps the connection open for re - use . |
15,989 | private JsonNode executeRequest ( HttpPost request ) throws IOException , GroovesharkException { HttpResponse response = httpClient . execute ( request ) ; if ( debugLogging ) { logRequest ( request , response ) ; } String responsePayload = CharStreams . toString ( new InputStreamReader ( response . getEntity ( ) . getContent ( ) , Charsets . UTF_8 ) ) ; try { return jsonMapper . readTree ( new StringReader ( responsePayload ) ) ; } catch ( JsonProcessingException e ) { throw new GroovesharkException . ServerErrorException ( "Failed to parse response - received data was not valid JSON: " + responsePayload ) ; } } | Boilerplate to send the request and parse the response payload as JSON . |
15,990 | public void init ( String actionKey , ActionListener targetListener ) { m_targetListener = targetListener ; m_actionKey = actionKey ; String text = BaseApplet . getSharedInstance ( ) . getString ( actionKey ) ; String desc = BaseApplet . getSharedInstance ( ) . getString ( actionKey + TIP ) ; ImageIcon icon = BaseApplet . getSharedInstance ( ) . loadImageIcon ( actionKey ) ; ActionManager . getActionManager ( ) . put ( actionKey , this ) ; this . putValue ( AbstractAction . NAME , text ) ; if ( desc != null ) if ( ! desc . equalsIgnoreCase ( actionKey + TIP ) ) this . putValue ( AbstractAction . SHORT_DESCRIPTION , desc ) ; if ( icon != null ) this . putValue ( AbstractAction . SMALL_ICON , icon ) ; } | Creates a new instance of BaseAction . |
15,991 | public static void assertStringPropertyEquals ( final Node node , final String propertyName , final String actualValue ) throws RepositoryException { assertTrue ( "Node " + node . getPath ( ) + " has no property " + propertyName , node . hasProperty ( propertyName ) ) ; final Property prop = node . getProperty ( propertyName ) ; assertEquals ( "Property type is not STRING " , PropertyType . STRING , prop . getType ( ) ) ; assertEquals ( actualValue , prop . getString ( ) ) ; } | Asserts the equality of a property value of a node with an expected value |
15,992 | public static void assertNodeExistByPath ( final Session session , final String absPath ) throws RepositoryException { try { session . getNode ( absPath ) ; } catch ( final PathNotFoundException e ) { LOG . debug ( "Node path {} does not exist" , absPath , e ) ; fail ( e . getMessage ( ) ) ; } } | Asserts that a specific node with the given absolute path exists in the session |
15,993 | public static void assertNodeNotExistByPath ( final Session session , final String absPath ) throws RepositoryException { try { session . getNode ( absPath ) ; fail ( "Node " + absPath + " does not exist" ) ; } catch ( final PathNotFoundException e ) { } } | Asserts that a specific node with the given absolute path does not exist in the session |
15,994 | public static void assertNodeExistById ( final Session session , final String itemId ) throws RepositoryException { try { session . getNodeByIdentifier ( itemId ) ; } catch ( final ItemNotFoundException e ) { LOG . debug ( "Item with id {} does not exist" , itemId , e ) ; fail ( e . getMessage ( ) ) ; } } | Asserts that an item identified by it s unique id is found in the repository session . |
15,995 | public static void assertNodeNotExistById ( final Session session , final String itemId ) throws RepositoryException { try { session . getNodeByIdentifier ( itemId ) ; fail ( "ItemNotFoundException expected" ) ; } catch ( final ItemNotFoundException e ) { } } | Asserts that an item identified by it s unique id is not found in the repository session . |
15,996 | public static void assertNodeExist ( final Node rootNode , final String relPath ) throws RepositoryException { try { rootNode . getNode ( relPath ) ; } catch ( final PathNotFoundException e ) { LOG . debug ( "Node {} does not exist in path {}" , relPath , rootNode . getPath ( ) , e ) ; fail ( e . getMessage ( ) ) ; } } | Asserts that a specific node exists under the root node where the specific node is specified using its relative path |
15,997 | public static void assertPrimaryNodeType ( final Node node , final String nodeType ) throws RepositoryException { final NodeType primaryNodeType = node . getPrimaryNodeType ( ) ; assertEquals ( nodeType , primaryNodeType . getName ( ) ) ; } | Asserts the primary node type of the node |
15,998 | public static void assertMixinNodeType ( final Node node , final String mixinType ) throws RepositoryException { for ( final NodeType nt : node . getMixinNodeTypes ( ) ) { if ( mixinType . equals ( nt . getName ( ) ) ) { return ; } } fail ( "Node " + node . getPath ( ) + " has no mixin type " + mixinType ) ; } | Asserts one of the node s mixin type equals the specified nodetype |
15,999 | public static void assertNodeTypeExists ( final Session session , final String nodeTypeName ) throws RepositoryException { final NodeTypeManager ntm = session . getWorkspace ( ) . getNodeTypeManager ( ) ; assertTrue ( "NodeType " + nodeTypeName + " does not exist" , ntm . hasNodeType ( nodeTypeName ) ) ; } | Asserts that a specific node type is registered in the workspace of the session . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.