idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
25,700
public void read ( final File filename ) { filePath = filename ; globalMeta . clear ( ) ; super . read ( filename ) ; }
read map files .
25,701
private void removeIndexTermRecursive ( final Element parent ) { if ( parent == null ) { return ; } final NodeList children = parent . getChildNodes ( ) ; Element child ; for ( int i = children . getLength ( ) - 1 ; i >= 0 ; i -- ) { if ( children . item ( i ) . getNodeType ( ) == Node . ELEMENT_NODE ) { child = ( Elem...
traverse the node tree and remove all indexterm elements with either start or end attribute .
25,702
private Map < String , Element > cloneElementMap ( final Map < String , Element > current ) { final Map < String , Element > topicMetaTable = new HashMap < > ( 16 ) ; for ( final Entry < String , Element > topicMetaItem : current . entrySet ( ) ) { topicMetaTable . put ( topicMetaItem . getKey ( ) , ( Element ) resultD...
Clone metadata map .
25,703
public Processor setProperty ( final String name , final String value ) { args . put ( name , value ) ; return this ; }
Set property . Existing property mapping will be overridden .
25,704
private void findTargets ( final IndexTerm term ) { final List < IndexTerm > subTerms = term . getSubTerms ( ) ; List < IndexTermTarget > subTargets = null ; if ( subTerms != null && ! subTerms . isEmpty ( ) ) { for ( final IndexTerm subTerm : subTerms ) { subTargets = subTerm . getTargetList ( ) ; if ( subTargets != n...
find the targets in its subterms when the current term doesn t have any target
25,705
public void setBaseTempDir ( final File tmp ) { if ( ! tmp . isAbsolute ( ) ) { throw new IllegalArgumentException ( "Temporary directory must be absolute" ) ; } args . put ( "base.temp.dir" , tmp . getAbsolutePath ( ) ) ; }
Set base directory for temporary directories .
25,706
public Processor newProcessor ( final String transtype ) { if ( ditaDir == null ) { throw new IllegalStateException ( ) ; } if ( ! Configuration . transtypes . contains ( transtype ) ) { throw new IllegalArgumentException ( "Transtype " + transtype + " not supported" ) ; } return new Processor ( ditaDir , transtype , C...
Create new Processor to run DITA - OT
25,707
public static List < String > getInstalledPlugins ( ) { final List < Element > plugins = toList ( getPluginConfiguration ( ) . getElementsByTagName ( "plugin" ) ) ; return plugins . stream ( ) . map ( ( Element elem ) -> elem . getAttributeNode ( "id" ) ) . filter ( Objects :: nonNull ) . map ( Attr :: getValue ) . sor...
Read the list of installed plugins
25,708
public static Document getPluginConfiguration ( ) { try ( final InputStream in = Plugins . class . getClassLoader ( ) . getResourceAsStream ( PLUGIN_CONF ) ) { return DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) . parse ( in ) ; } catch ( final ParserConfigurationException | SAXException | IOExcept...
Read plugin configuration
25,709
public final void addFeature ( final String id , final Element elem ) { boolean isFile ; String value = elem . getAttribute ( "file" ) ; if ( ! value . isEmpty ( ) ) { isFile = true ; } else { value = elem . getAttribute ( "value" ) ; isFile = "file" . equals ( elem . getAttribute ( "type" ) ) ; } final StringTokenizer...
Add feature to the feature table .
25,710
public void close ( ) throws IOException { if ( outStream == null && outWriter == null ) { throw new IllegalStateException ( ) ; } if ( outStream != null ) { outStream . close ( ) ; } if ( outWriter != null ) { outWriter . close ( ) ; } }
Close output .
25,711
public void writeStartElement ( final String uri , final String qName ) throws SAXException { processStartElement ( ) ; final QName res = new QName ( uri , qName ) ; addNamespace ( res . uri , res . prefix , res ) ; elementStack . addFirst ( res ) ; openStartElement = true ; }
Write start element without attributes .
25,712
public void writeNamespace ( final String prefix , final String uri ) { if ( ! openStartElement ) { throw new IllegalStateException ( "Current state does not allow Namespace writing" ) ; } final QName qName = elementStack . getFirst ( ) ; for ( final NamespaceMapping p : qName . mappings ) { if ( p . prefix . equals ( ...
Write namepace prefix .
25,713
public void writeEndElement ( ) throws SAXException { processStartElement ( ) ; final QName qName = elementStack . remove ( ) ; transformer . endElement ( qName . uri , qName . localName , qName . qName ) ; for ( final NamespaceMapping p : qName . mappings ) { if ( p . newMapping ) { transformer . endPrefixMapping ( p ...
Write end element .
25,714
public void writeProcessingInstruction ( final String target , final String data ) throws SAXException { processStartElement ( ) ; transformer . processingInstruction ( target , data != null ? data : "" ) ; }
Write processing instruction .
25,715
public void writeComment ( final String data ) throws SAXException { processStartElement ( ) ; final char [ ] ch = data . toCharArray ( ) ; transformer . comment ( ch , 0 , ch . length ) ; }
Write comment .
25,716
public static boolean isHTMLFile ( final String lcasefn ) { for ( final String ext : supportedHTMLExtensions ) { if ( lcasefn . endsWith ( ext ) ) { return true ; } } return false ; }
Return if the file is a html file by extension .
25,717
public static boolean isResourceFile ( final String lcasefn ) { for ( final String ext : supportedResourceExtensions ) { if ( lcasefn . endsWith ( ext ) ) { return true ; } } return false ; }
Return if the file is a resource file by its extension .
25,718
public static boolean isSupportedImageFile ( final String lcasefn ) { for ( final String ext : supportedImageExtensions ) { if ( lcasefn . endsWith ( ext ) ) { return true ; } } return false ; }
Return if the file is a supported image file by extension .
25,719
private static String normalizePath ( final String path , final String separator ) { final String p = path . replace ( WINDOWS_SEPARATOR , separator ) . replace ( UNIX_SEPARATOR , separator ) ; final List < String > dirs = new LinkedList < > ( ) ; final StringTokenizer tokenizer = new StringTokenizer ( p , separator ) ...
Remove redundant names .. and . from the given path and replace directory separators .
25,720
public static boolean isAbsolutePath ( final String path ) { if ( path == null || path . trim ( ) . length ( ) == 0 ) { return false ; } if ( File . separator . equals ( UNIX_SEPARATOR ) ) { return path . startsWith ( UNIX_SEPARATOR ) ; } else if ( File . separator . equals ( WINDOWS_SEPARATOR ) && path . length ( ) > ...
Return if the path is absolute .
25,721
public static String getExtension ( final String file ) { final int index = file . indexOf ( SHARP ) ; if ( file . startsWith ( SHARP ) ) { return null ; } else if ( index != - 1 ) { final String fileName = file . substring ( 0 , index ) ; final int fileExtIndex = fileName . lastIndexOf ( DOT ) ; return fileExtIndex !=...
Get file extension
25,722
public static String getName ( final String aURLString ) { int pathnameEndIndex ; if ( isWindows ( ) ) { if ( aURLString . contains ( SHARP ) ) { pathnameEndIndex = aURLString . lastIndexOf ( SHARP ) ; } else { pathnameEndIndex = aURLString . lastIndexOf ( WINDOWS_SEPARATOR ) ; if ( pathnameEndIndex == - 1 ) { pathname...
Get filename from a path .
25,723
public static String getFullPathNoEndSeparator ( final String aURLString ) { final int pathnameStartIndex = aURLString . indexOf ( UNIX_SEPARATOR ) ; final int pathnameEndIndex = aURLString . lastIndexOf ( UNIX_SEPARATOR ) ; String aPath = aURLString . substring ( 0 , pathnameEndIndex ) ; return aPath ; }
Get base path from a path .
25,724
public static String stripFragment ( final String path ) { final int i = path . indexOf ( SHARP ) ; if ( i != - 1 ) { return path . substring ( 0 , i ) ; } else { return path ; } }
Strip fragment part from path .
25,725
public static String getFragment ( final String path , final String defaultValue ) { final int i = path . indexOf ( SHARP ) ; if ( i != - 1 ) { return path . substring ( i + 1 ) ; } else { return defaultValue ; } }
Get fragment part from path or return default fragment .
25,726
private static SchemaWrapper wrapPattern2 ( Pattern start , SchemaPatternBuilder spb , PropertyMap properties ) throws SAXException , IncorrectSchemaException { if ( properties . contains ( RngProperty . FEASIBLE ) ) { start = FeasibleTransform . transform ( spb , start ) ; } properties = AbstractSchema . filterPropert...
Make a schema wrapper .
25,727
public AbstractPipelineOutput execute ( final AbstractPipelineInput input ) throws DITAOTException { final Collection < FileInfo > fis = job . getFileInfo ( fileInfoFilter ) ; for ( final FileInfo f : fis ) { final URI file = job . tempDirURI . resolve ( f . uri ) ; logger . info ( "Processing " + file ) ; try { xmlUti...
Filter files through XML filters .
25,728
public static void writeMapToXML ( final Map < URI , Set < URI > > m , final File outputFile ) throws IOException { if ( m == null ) { return ; } final Properties prop = new Properties ( ) ; for ( final Map . Entry < URI , Set < URI > > entry : m . entrySet ( ) ) { final URI key = entry . getKey ( ) ; final String valu...
Write map of sets to a file .
25,729
public void loadSubjectScheme ( final File scheme ) { assert scheme . isAbsolute ( ) ; if ( ! scheme . exists ( ) ) { throw new IllegalStateException ( ) ; } logger . debug ( "Load subject scheme " + scheme ) ; try { final DocumentBuilder builder = XMLUtils . getDocumentBuilder ( ) ; final Document doc = builder . pars...
Load schema file .
25,730
private void putValuePairsIntoMap ( final Element subtree , final String elementName , final QName attName , final String category ) { if ( subtree == null || attName == null ) { return ; } Map < String , Set < String > > valueMap = validValuesMap . get ( attName ) ; if ( valueMap == null ) { valueMap = new HashMap < >...
Populate valid values map
25,731
private void processMap ( ) throws DITAOTException { final URI in = job . tempDirURI . resolve ( job . getFileInfo ( fi -> fi . isInput ) . iterator ( ) . next ( ) . uri ) ; final List < XMLFilter > pipe = getProcessingPipe ( in ) ; xmlUtils . transform ( in , pipe ) ; }
Process start map to read copy - to map and write unique topic references .
25,732
private List < XMLFilter > getProcessingPipe ( final URI fileToParse ) { final List < XMLFilter > pipe = new ArrayList < > ( ) ; if ( forceUnique ) { forceUniqueFilter = new ForceUniqueFilter ( ) ; forceUniqueFilter . setLogger ( logger ) ; forceUniqueFilter . setJob ( job ) ; forceUniqueFilter . setCurrentFile ( fileT...
Get processign filters
25,733
private Map < FileInfo , FileInfo > getCopyToMap ( ) { final Map < FileInfo , FileInfo > copyToMap = new HashMap < > ( ) ; if ( forceUnique ) { forceUniqueFilter . copyToMap . forEach ( ( dstFi , srcFi ) -> { job . add ( dstFi ) ; copyToMap . put ( dstFi , srcFi ) ; } ) ; } for ( final Map . Entry < URI , URI > e : rea...
Get copy - to map based on map processing .
25,734
private void performCopytoTask ( final Map < FileInfo , FileInfo > copyToMap ) { for ( final Map . Entry < FileInfo , FileInfo > entry : copyToMap . entrySet ( ) ) { final URI copytoTarget = entry . getKey ( ) . uri ; final URI copytoSource = entry . getValue ( ) . uri ; final URI srcFile = job . tempDirURI . resolve (...
Execute copy - to task generate copy - to targets base on sources .
25,735
private void copyFileWithPIReplaced ( final URI src , final URI target , final URI copytoTargetFilename , final URI inputMapInTemp ) { assert src . isAbsolute ( ) ; assert target . isAbsolute ( ) ; assert ! copytoTargetFilename . isAbsolute ( ) ; assert inputMapInTemp . isAbsolute ( ) ; final File workdir = new File ( ...
Copy files and replace workdir PI contents .
25,736
public static File getPathtoRootmap ( final URI traceFilename , final URI inputMap ) { assert traceFilename . isAbsolute ( ) ; assert inputMap . isAbsolute ( ) ; return toFile ( getRelativePath ( traceFilename , inputMap ) ) . getParentFile ( ) ; }
Get path to root map
25,737
public void read ( final File filename , final File tmpDir ) { tempdir = tmpDir != null ? tmpDir : filename . getParentFile ( ) ; try { final TransformerHandler s = stf . newTransformerHandler ( ) ; s . getTransformer ( ) . setOutputProperty ( OMIT_XML_DECLARATION , "yes" ) ; s . setResult ( new StreamResult ( output )...
Read map .
25,738
void initXMLReader ( final File ditaDir , final boolean validate ) throws SAXException { reader = XMLUtils . getXMLReader ( ) ; reader . setFeature ( FEATURE_NAMESPACE , true ) ; reader . setFeature ( FEATURE_NAMESPACE_PREFIX , true ) ; if ( validate ) { reader . setFeature ( FEATURE_VALIDATION , true ) ; try { reader ...
Init xml reader used for pipeline parsing .
25,739
void processParseResult ( final URI currentFile ) { for ( final Reference file : listFilter . getNonCopytoResult ( ) ) { categorizeReferenceFile ( file ) ; } for ( final Map . Entry < URI , URI > e : listFilter . getCopytoMap ( ) . entrySet ( ) ) { final URI source = e . getValue ( ) ; final URI target = e . getKey ( )...
Process results from parsing a single topic
25,740
void addToWaitList ( final Reference ref ) { final URI file = ref . filename ; assert file . isAbsolute ( ) && file . getFragment ( ) == null ; if ( doneList . contains ( file ) || waitList . contains ( ref ) || file . equals ( currentFile ) ) { return ; } waitList . add ( ref ) ; }
Add the given file the wait list if it has not been parsed .
25,741
private FilterUtils parseFilterFile ( ) { final FilterUtils filterUtils ; if ( ditavalFile != null ) { final DitaValReader ditaValReader = new DitaValReader ( ) ; ditaValReader . setLogger ( logger ) ; ditaValReader . setJob ( job ) ; ditaValReader . read ( ditavalFile . toURI ( ) ) ; flagImageSet . addAll ( ditaValRea...
Parse filter file
25,742
private String getAttributeValue ( final String elemQName , final QName attQName , final String value ) { if ( StringUtils . isEmptyString ( value ) && ! defaultValueMap . isEmpty ( ) ) { final Map < String , String > defaultMap = defaultValueMap . get ( attQName ) ; if ( defaultMap != null ) { final String defaultValu...
Get attribute value or default if attribute is not defined
25,743
private URI replaceHREF ( final QName attName , final Attributes atts ) { URI attValue = toURI ( atts . getValue ( attName . getNamespaceURI ( ) , attName . getLocalPart ( ) ) ) ; if ( attValue != null ) { final String fragment = attValue . getFragment ( ) ; if ( fragment != null ) { attValue = stripFragment ( attValue...
Relativize absolute references if possible .
25,744
public Alphabet getAlphabetForChar ( final char theChar ) { Alphabet result = null ; for ( final Alphabet alphabet : this . alphabets ) { if ( alphabet . isContain ( theChar ) ) { result = alphabet ; break ; } } return result ; }
Searches alphabets for a char
25,745
public static URL correct ( final File file ) throws MalformedURLException { if ( file == null ) { throw new MalformedURLException ( "The url is null" ) ; } return new URL ( correct ( file . toURI ( ) . toString ( ) , true ) ) ; }
Corrects the file to URL .
25,746
public static URL correct ( final URL url ) throws MalformedURLException { if ( url == null ) { throw new MalformedURLException ( "The url is null" ) ; } return new URL ( correct ( url . toString ( ) , false ) ) ; }
Corrects an URL .
25,747
public static File getCanonicalFileFromFileUrl ( final URL url ) { File file = null ; if ( url == null ) { throw new NullPointerException ( "The URL cannot be null." ) ; } if ( "file" . equals ( url . getProtocol ( ) ) ) { final String fileName = url . getFile ( ) ; final String path = URLUtils . uncorrect ( fileName )...
On Windows names of files from network neighborhood must be corrected before open .
25,748
private static String correct ( String url , final boolean forceCorrection ) { if ( url == null ) { return null ; } final String initialUrl = url ; if ( ! forceCorrection && url . contains ( "%" ) ) { return initialUrl ; } String reference = null ; if ( ! forceCorrection ) { final int refIndex = url . lastIndexOf ( '#'...
Method introduced to correct the URLs in the default machine encoding .
25,749
public static String getURL ( final String fileName ) { if ( fileName . startsWith ( "file:/" ) ) { return fileName ; } else { final File file = new File ( fileName ) ; return file . toURI ( ) . toString ( ) ; } }
Convert a file name to url .
25,750
public static boolean isAbsolute ( final URI uri ) { final String p = uri . getPath ( ) ; return p != null && p . startsWith ( URI_SEPARATOR ) ; }
Test if URI path is absolute .
25,751
public static File toFile ( final URI filename ) { if ( filename == null ) { return null ; } final URI f = stripFragment ( filename ) ; if ( "file" . equals ( f . getScheme ( ) ) && f . getPath ( ) != null && f . isAbsolute ( ) ) { return new File ( f ) ; } else { return toFile ( f . toString ( ) ) ; } }
Convert URI reference to system file path .
25,752
public static File toFile ( final String filename ) { if ( filename == null ) { return null ; } String f ; try { f = URLDecoder . decode ( filename , UTF8 ) ; } catch ( final UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } f = f . replace ( WINDOWS_SEPARATOR , File . separator ) . replace ( UNIX...
Convert URI or chimera references to file paths .
25,753
public static URI toURI ( final String file ) { if ( file == null ) { return null ; } if ( File . separatorChar == '\\' && file . indexOf ( '\\' ) != - 1 ) { return toURI ( new File ( file ) ) ; } try { return new URI ( file ) ; } catch ( final URISyntaxException e ) { try { return new URI ( clean ( file . replace ( WI...
Covert file reference to URI . Fixes directory separators and escapes characters .
25,754
public static URI setFragment ( final URI path , final String fragment ) { try { if ( path . getPath ( ) != null ) { return new URI ( path . getScheme ( ) , path . getUserInfo ( ) , path . getHost ( ) , path . getPort ( ) , path . getPath ( ) , path . getQuery ( ) , fragment ) ; } else { return new URI ( path . getSche...
Create new URI with a given fragment .
25,755
public static URI setPath ( final URI orig , final String path ) { try { return new URI ( orig . getScheme ( ) , orig . getUserInfo ( ) , orig . getHost ( ) , orig . getPort ( ) , path , orig . getQuery ( ) , orig . getFragment ( ) ) ; } catch ( final URISyntaxException e ) { throw new RuntimeException ( e . getMessage...
Create new URI with a given path .
25,756
public static URI setScheme ( final URI orig , final String scheme ) { try { return new URI ( scheme , orig . getUserInfo ( ) , orig . getHost ( ) , orig . getPort ( ) , orig . getPath ( ) , orig . getQuery ( ) , orig . getFragment ( ) ) ; } catch ( final URISyntaxException e ) { throw new RuntimeException ( e . getMes...
Create new URI with a given scheme .
25,757
public static URI getRelativePath ( final URI base , final URI ref ) { final String baseScheme = base . getScheme ( ) ; final String refScheme = ref . getScheme ( ) ; final String baseAuth = base . getAuthority ( ) ; final String refAuth = ref . getAuthority ( ) ; if ( ! ( ( ( baseScheme == null && refScheme == null ) ...
Resolves absolute URI against another absolute URI .
25,758
public static URI setElementID ( final URI relativePath , final String id ) { String topic = getTopicID ( relativePath ) ; if ( topic != null ) { return setFragment ( relativePath , topic + ( id != null ? SLASH + id : "" ) ) ; } else if ( id == null ) { return stripFragment ( relativePath ) ; } else { throw new Illegal...
Set the element ID from the path
25,759
public static String getElementID ( final String relativePath ) { final String fragment = FileUtils . getFragment ( relativePath ) ; if ( fragment != null ) { if ( fragment . lastIndexOf ( SLASH ) != - 1 ) { final String id = fragment . substring ( fragment . lastIndexOf ( SLASH ) + 1 ) ; return id . isEmpty ( ) ? null...
Retrieve the element ID from the path
25,760
public static String getTopicID ( final URI relativePath ) { final String fragment = relativePath . getFragment ( ) ; if ( fragment != null ) { final String id = fragment . lastIndexOf ( SLASH ) != - 1 ? fragment . substring ( 0 , fragment . lastIndexOf ( SLASH ) ) : fragment ; return id . isEmpty ( ) ? null : id ; } r...
Retrieve the topic ID from the path
25,761
@ SuppressWarnings ( "rawtypes" ) public static String join ( final Collection coll , final String delim ) { final StringBuilder buff = new StringBuilder ( 256 ) ; Iterator iter ; if ( ( coll == null ) || coll . isEmpty ( ) ) { return "" ; } iter = coll . iterator ( ) ; while ( iter . hasNext ( ) ) { buff . append ( it...
Assemble all elements in collection to a string .
25,762
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static String join ( final Map value , final String delim ) { if ( value == null || value . isEmpty ( ) ) { return "" ; } final StringBuilder buf = new StringBuilder ( ) ; for ( final Iterator < Map . Entry < String , String > > i = value . entrySet ( ) . itera...
Assemble all elements in map to a string .
25,763
public static String replaceAll ( final String input , final String pattern , final String replacement ) { final StringBuilder result = new StringBuilder ( ) ; int startIndex = 0 ; int newIndex ; while ( ( newIndex = input . indexOf ( pattern , startIndex ) ) >= 0 ) { result . append ( input , startIndex , newIndex ) ;...
Replaces each substring of this string that matches the given string with the given replacement . Differ from the JDK String . replaceAll function this method does not support regular expression based replacement on purpose .
25,764
public static String setOrAppend ( final String target , final String value , final boolean withSpace ) { if ( target == null ) { return value ; } if ( value == null ) { return target ; } else { if ( withSpace && ! target . endsWith ( STRING_BLANK ) ) { return target + STRING_BLANK + value ; } else { return target + va...
If target is null return the value ; else append value to target . If withSpace is true insert a blank between them .
25,765
public static Locale getLocale ( final String anEncoding ) { Locale aLocale = null ; String country = null ; String language = null ; String variant ; final StringTokenizer tokenizer = new StringTokenizer ( anEncoding , "-" ) ; final int numberOfTokens = tokenizer . countTokens ( ) ; if ( numberOfTokens == 1 ) { final ...
Return a Java Locale object .
25,766
public static String escapeRegExp ( final String value ) { final StringBuilder buff = new StringBuilder ( ) ; if ( value == null || value . length ( ) == 0 ) { return "" ; } int index = 0 ; while ( index < value . length ( ) ) { final char current = value . charAt ( index ) ; switch ( current ) { case '.' : buff . appe...
Escape regular expression special characters .
25,767
public static void normalizeAndCollapseWhitespace ( final StringBuilder strBuffer ) { WhiteSpaceState currentState = WhiteSpaceState . WORD ; for ( int i = strBuffer . length ( ) - 1 ; i >= 0 ; i -- ) { final char currentChar = strBuffer . charAt ( i ) ; if ( Character . isWhitespace ( currentChar ) ) { if ( currentSta...
Normalize and collapse whitespaces from string buffer .
25,768
public static Collection < String > split ( final String value ) { if ( value == null ) { return Collections . emptyList ( ) ; } final String [ ] tokens = value . trim ( ) . split ( "\\s+" ) ; return asList ( tokens ) ; }
Split string by whitespace .
25,769
public AbstractPipelineOutput execute ( final AbstractPipelineInput input ) throws DITAOTException { if ( logger == null ) { throw new IllegalStateException ( "Logger not set" ) ; } final Collection < FileInfo > images = job . getFileInfo ( f -> ATTR_FORMAT_VALUE_IMAGE . equals ( f . format ) || ATTR_FORMAT_VALUE_HTML ...
Entry point of image metadata ModuleElem .
25,770
public static final String idFromName ( String name ) { Transliterator tr = Transliterator . getInstance ( "Any-Latin; Latin-ASCII" ) ; return removeNonWord ( tr . transliterate ( name ) ) ; }
Creates a bean id from the given bean name .
25,771
private HttpEngine getResponse ( ) throws IOException { initHttpEngine ( ) ; if ( httpEngine . hasResponse ( ) ) { return httpEngine ; } while ( true ) { if ( ! execute ( true ) ) { continue ; } Response response = httpEngine . getResponse ( ) ; Request followUp = httpEngine . followUpRequest ( ) ; if ( followUp == nul...
Aggressively tries to get the final HTTP response potentially making many HTTP requests in the process in order to cope with redirects and authentication .
25,772
private boolean execute ( boolean readResponse ) throws IOException { try { httpEngine . sendRequest ( ) ; route = httpEngine . getRoute ( ) ; handshake = httpEngine . getConnection ( ) != null ? httpEngine . getConnection ( ) . getHandshake ( ) : null ; if ( readResponse ) { httpEngine . readResponse ( ) ; } return tr...
Sends a request and optionally reads a response . Returns true if the request was successfully executed and false if the request can be retried . Throws an exception if the request failed permanently .
25,773
public void close ( IAsyncResultHandler < Void > result ) { vertx . executeBlocking ( blocking -> { super . close ( result ) ; } , res -> { if ( res . failed ( ) ) result . handle ( AsyncResultImpl . create ( res . cause ( ) ) ) ; } ) ; }
Indicates whether connection was successfully closed .
25,774
public static void reloadData ( IAsyncHandler < Void > doneHandler ) { synchronized ( URILoadingRegistry . class ) { if ( instance == null ) { doneHandler . handle ( ( Void ) null ) ; return ; } Map < URILoadingRegistry , IAsyncResultHandler < Void > > regs = instance . handlers ; Vertx vertx = instance . vertx ; URI u...
For testing only . Reloads rather than full restart .
25,775
protected void doQuotaExceededFailure ( final IPolicyContext context , final TransferQuotaConfig config , final IPolicyChain < ? > chain , RateLimitResponse rtr ) { Map < String , String > responseHeaders = RateLimitingPolicy . responseHeaders ( config , rtr , defaultLimitHeader ( ) , defaultRemainingHeader ( ) , defau...
Called to send a quota exceeded failure .
25,776
public static boolean isConstraintViolation ( Exception e ) { Throwable cause = e ; while ( cause != cause . getCause ( ) && cause . getCause ( ) != null ) { if ( cause . getClass ( ) . getSimpleName ( ) . equals ( "ConstraintViolationException" ) ) return true ; cause = cause . getCause ( ) ; } return false ; }
Returns true if the given exception is a unique constraint violation . This is useful to detect whether someone is trying to persist an entity that already exists . It allows us to simply assume that persisting a new entity will work without first querying the DB for the existence of that entity .
25,777
public static void rollbackQuietly ( EntityManager entityManager ) { if ( entityManager . getTransaction ( ) . isActive ( ) ) { try { entityManager . getTransaction ( ) . rollback ( ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; } } }
Rolls back a transaction . Tries to be smart and quiet about it .
25,778
public String getConfigProperty ( String propertyName , String defaultValue ) { return getConfig ( ) . getString ( propertyName , defaultValue ) ; }
Returns the given configuration property name or the provided default value if not found .
25,779
private IndexedPermissions loadPermissions ( ) { String userId = getCurrentUser ( ) ; try { return new IndexedPermissions ( getQuery ( ) . getPermissions ( userId ) ) ; } catch ( StorageException e ) { logger . error ( Messages . getString ( "AbstractSecurityContext.ErrorLoadingPermissions" ) + userId , e ) ; return ne...
Loads the current user s permissions into a thread local variable .
25,780
@ SuppressWarnings ( "nls" ) protected DataSource datasourceFromConfig ( JdbcOptionsBean config ) { Properties props = new Properties ( ) ; props . putAll ( config . getDsProperties ( ) ) ; setConfigProperty ( props , "jdbcUrl" , config . getJdbcUrl ( ) ) ; setConfigProperty ( props , "username" , config . getUsername ...
Creates a datasource from the given jdbc config info .
25,781
private void setConfigProperty ( Properties props , String propName , Object value ) { if ( value != null ) { props . setProperty ( propName , String . valueOf ( value ) ) ; } }
Sets a configuration property but only if it s not null .
25,782
private ResourceBundle getBundle ( ) { String bundleKey = getBundleKey ( ) ; if ( bundles . containsKey ( bundleKey ) ) { return bundles . get ( bundleKey ) ; } else { ResourceBundle bundle = loadBundle ( ) ; bundles . put ( bundleKey , bundle ) ; return bundle ; } }
Gets a bundle . First tries to find one in the cache then loads it if it can t find one .
25,783
private ResourceBundle loadBundle ( ) { String pkg = clazz . getPackage ( ) . getName ( ) ; Locale locale = getLocale ( ) ; return PropertyResourceBundle . getBundle ( pkg + ".messages" , locale , clazz . getClassLoader ( ) , new ResourceBundle . Control ( ) { public List < String > getFormats ( String baseName ) { ret...
Loads the resource bundle .
25,784
public String format ( String key , Object ... params ) { ResourceBundle bundle = getBundle ( ) ; if ( bundle . containsKey ( key ) ) { String msg = bundle . getString ( key ) ; return MessageFormat . format ( msg , params ) ; } else { return MessageFormat . format ( "!!{0}!!" , key ) ; } }
Look up a message in the i18n resource message bundle by key then format the message with the given params and return the result .
25,785
@ SuppressWarnings ( "nls" ) public void listDatabases ( final IAsyncResultHandler < List < String > > handler ) { IHttpClientRequest request = httpClient . request ( queryUrl . toString ( ) , HttpMethod . GET , result -> { try { if ( result . isError ( ) || result . getResult ( ) . getResponseCode ( ) != 200 ) { handl...
List all databases
25,786
@ SuppressWarnings ( "unchecked" ) private static < T > T createCustomComponent ( Class < T > componentType , Class < ? > componentClass , Map < String , String > configProperties ) throws Exception { if ( componentClass == null ) { throw new IllegalArgumentException ( "Invalid component spec (class not found)." ) ; } ...
Creates a custom component from a loaded class .
25,787
private static DataSource lookupDS ( String dsJndiLocation ) { DataSource ds ; try { InitialContext ctx = new InitialContext ( ) ; ds = ( DataSource ) ctx . lookup ( dsJndiLocation ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } if ( ds == null ) { throw new RuntimeException ( "Datasource not found: ...
Lookup the datasource in JNDI .
25,788
protected File createWorkDir ( File pluginArtifactFile ) throws IOException { File tempDir = File . createTempFile ( pluginArtifactFile . getName ( ) , "" ) ; tempDir . delete ( ) ; tempDir . mkdirs ( ) ; return tempDir ; }
Creates a work directory into which various resources discovered in the plugin artifact can be extracted .
25,789
private void indexPluginArtifact ( ) throws IOException { dependencyZips = new ArrayList < > ( ) ; Enumeration < ? extends ZipEntry > entries = this . pluginArtifactZip . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry zipEntry = entries . nextElement ( ) ; if ( zipEntry . getName ( ) . startsWith ( "W...
Indexes the content of the plugin artifact . This includes discovering all of the dependency JARs as well as any configuration resources such as plugin definitions .
25,790
protected InputStream findClassContent ( String className ) throws IOException { String primaryArtifactEntryName = "WEB-INF/classes/" + className . replace ( '.' , '/' ) + ".class" ; String dependencyEntryName = className . replace ( '.' , '/' ) + ".class" ; ZipEntry entry = this . pluginArtifactZip . getEntry ( primar...
Searches the plugin artifact ZIP and all dependency ZIPs for a zip entry for the given fully qualified class name .
25,791
public void close ( ) throws IOException { if ( closed ) { return ; } this . pluginArtifactZip . close ( ) ; for ( ZipFile zipFile : this . dependencyZips ) { zipFile . close ( ) ; } closed = true ; }
Closes any resources the plugin classloader is holding open .
25,792
protected PluginClassLoader createPluginClassLoader ( final File pluginFile ) throws IOException { return new PluginClassLoader ( pluginFile , Thread . currentThread ( ) . getContextClassLoader ( ) ) { protected File createWorkDir ( File pluginArtifactFile ) throws IOException { File workDir = new File ( pluginFile . g...
Creates a plugin classloader for the given plugin file .
25,793
protected Client getClientInternal ( String idx ) { Client client ; synchronized ( mutex ) { client = ( Client ) getMap ( ) . get ( idx ) ; } return client ; }
Gets the client and returns it .
25,794
private String getClientIndex ( Client client ) { return getClientIndex ( client . getOrganizationId ( ) , client . getClientId ( ) , client . getVersion ( ) ) ; }
Generates an in - memory key for an client used to index the client for later quick retrieval .
25,795
protected List < ContractSummaryBean > getClientContractsInternal ( String organizationId , String clientId , String version ) throws StorageException { List < ContractSummaryBean > rval = new ArrayList < > ( ) ; EntityManager entityManager = getActiveEntityManager ( ) ; String jpql = "SELECT c from ContractBean c " + ...
Returns a list of all contracts for the given client .
25,796
public static void main ( String [ ] args ) { File from ; File to ; if ( args . length < 2 ) { System . out . println ( "Usage: DataMigrator <pathToSourceFile> <pathToDestFile>" ) ; return ; } String frompath = args [ 0 ] ; String topath = args [ 1 ] ; from = new File ( frompath ) ; to = new File ( topath ) ; System ....
Main method - used when running the data migrator in standalone mode .
25,797
public static Object readPrimitive ( Class < ? > clazz , String value ) throws Exception { if ( clazz == String . class ) { return value ; } else if ( clazz == Long . class ) { return Long . parseLong ( value ) ; } else if ( clazz == Integer . class ) { return Integer . parseInt ( value ) ; } else if ( clazz == Double ...
Parses the String value as a primitive or a String depending on its type .
25,798
protected Object readPrimitive ( JestResult result ) throws Exception { PrimitiveBean pb = result . getSourceAsObject ( PrimitiveBean . class ) ; String value = pb . getValue ( ) ; Class < ? > c = Class . forName ( pb . getType ( ) ) ; return BackingStoreUtil . readPrimitive ( c , value ) ; }
Reads a stored primitive .
25,799
private void connect ( ) { try { URL url = new URL ( this . endpoint ) ; connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setReadTimeout ( this . readTimeoutMs ) ; connection . setConnectTimeout ( this . connectTimeoutMs ) ; connection . setRequestMethod ( this . method . name ( ) ) ; if ( met...
Connect to the remote server .