idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
28,800 | public Vector wait ( TypedVector < Future < ActivityData > > futures ) throws ActivityException { Vector results = new Vector ( ) ; results . setSize ( futures . size ( ) ) ; try { int count = futures . size ( ) ; logger . trace ( "waiting for {} activities to complete..." , count ) ; long newTimeout = timeout ; while ( count -- > 0 && newTimeout > 0 ) { long start = System . currentTimeMillis ( ) ; Integer id = queue . poll ( newTimeout , unit ) ; newTimeout = newTimeout - unit . convert ( ( System . currentTimeMillis ( ) - start ) , TimeUnit . MILLISECONDS ) ; if ( id == null || newTimeout < 0 ) { logger . trace ( "no activity completed within timeout, exiting" ) ; throw new TimedOutException ( "Timeout expired before all activities completed" ) ; } logger . debug ( "activity '{}' complete (count: {}, queue: {})" , id , count , queue . size ( ) ) ; ActivityData result = futures . get ( id ) . get ( ) ; if ( result instanceof Scalar ) { results . set ( id , ( ( Scalar ) result ) . get ( ) ) ; } else { results . set ( id , result ) ; } if ( this . mode == WaitMode . WAIT_FOR_ANY ) { return results ; } } logger . debug ( "all activities complete" ) ; return results ; } catch ( ExecutionException e ) { logger . error ( "error executing asynchronous activity" , e ) ; throw new ActivityException ( "Error executing asynchronous activity" , e ) ; } catch ( InterruptedException e ) { logger . error ( "operation interrupted" , e ) ; throw new ActivityException ( "Operation interrupted" ) ; } } | Waits for all activities to complete before returning . |
28,801 | public synchronized T get ( ) { T val ; synchronized ( this ) { if ( valRef == null || ( val = valRef . get ( ) ) == null ) { val = make ( ) ; valRef = new WeakReference < T > ( val ) ; } } return val ; } | Get the cached object . If the object is not in memory it is recreated . |
28,802 | private void tidy ( ) { nonPermanent . entrySet ( ) . stream ( ) . map ( entry -> { List < WeakReference < IzouSoundLineBaseClass > > collect = entry . getValue ( ) . stream ( ) . filter ( izouSoundLineWeakReference -> izouSoundLineWeakReference . get ( ) != null ) . collect ( Collectors . toList ( ) ) ; if ( ! collect . isEmpty ( ) ) { nonPermanent . put ( entry . getKey ( ) , collect ) ; return null ; } else { return entry ; } } ) . filter ( Objects :: nonNull ) . forEach ( entry -> nonPermanent . remove ( entry . getKey ( ) ) ) ; } | removes obsolete references |
28,803 | public void addIzouSoundLine ( AddOnModel addOnModel , IzouSoundLineBaseClass izouSoundLine ) { debug ( "adding soundLine " + izouSoundLine + " from " + addOnModel ) ; if ( permanentAddOn != null && permanentAddOn . equals ( addOnModel ) ) { addPermanent ( izouSoundLine ) ; } else { addNonPermanent ( addOnModel , izouSoundLine ) ; } izouSoundLine . registerCloseCallback ( voit -> closeCallback ( addOnModel , izouSoundLine ) ) ; izouSoundLine . registerMuteCallback ( voit -> muteCallback ( addOnModel , izouSoundLine ) ) ; } | adds an IzouSoundLine will now be tracked by the SoundManager |
28,804 | private void closeCallback ( AddOnModel addOnModel , IzouSoundLine izouSoundLine ) { debug ( "removing soundline " + izouSoundLine + " from " + addOnModel ) ; Predicate < WeakReference < IzouSoundLineBaseClass > > removeFromList = weakReference -> weakReference . get ( ) != null && weakReference . get ( ) . equals ( izouSoundLine ) ; synchronized ( permanentUserReadWriteLock ) { if ( permanentAddOn != null && permanentAddOn . equals ( addOnModel ) && permanentLines != null ) { permanentLines . removeIf ( removeFromList ) ; if ( permanentLines . isEmpty ( ) ) { permanentLines = null ; permissionWithoutUsage ( ) ; } } } List < WeakReference < IzouSoundLineBaseClass > > weakReferences = nonPermanent . get ( addOnModel ) ; if ( weakReferences != null ) { weakReferences . removeIf ( removeFromList ) ; synchronized ( mutingLock ) { if ( mutingManager != null && mutingManager . getMuting ( ) . equals ( addOnModel ) ) { mutingManager = mutingManager . remove ( izouSoundLine ) ; } } } submit ( this :: tidy ) ; } | the close - callback or the AddonModel removes now redundant references |
28,805 | private void permissionWithoutUsage ( ) { if ( isUsingNonJava ) return ; synchronized ( permanentUserReadWriteLock ) { permissionWithoutUsageLimit = LocalDateTime . now ( ) . plus ( 10 , ChronoUnit . SECONDS ) ; permissionWithoutUsageCloseThread = getMain ( ) . getThreadPoolManager ( ) . getAddOnsThreadPool ( ) . submit ( ( Runnable ) ( ) -> { try { Thread . sleep ( 10000 ) ; fireLineAccessEndedNotification ( ) ; endPermanent ( permanentAddOn ) ; } catch ( InterruptedException ignored ) { } } ) ; } } | creates a LocaleDateTime - Object 10 seconds in the Future and a Thread which will remove it if it passes the threshold . the Thread |
28,806 | private void addPermanent ( IzouSoundLineBaseClass izouSoundLine ) { debug ( "adding " + izouSoundLine + " to permanent" ) ; if ( ! izouSoundLine . isPermanent ( ) ) izouSoundLine . setToPermanent ( ) ; synchronized ( permanentUserReadWriteLock ) { endWaitingForUsage ( ) ; if ( permanentLines == null ) { permanentLines = Collections . synchronizedList ( new ArrayList < > ( ) ) ; } permanentLines . add ( new WeakReference < > ( izouSoundLine ) ) ; } } | adds the IzouSoundLine as permanent |
28,807 | private void addNonPermanent ( AddOnModel addOnModel , IzouSoundLineBaseClass izouSoundLine ) { debug ( "adding " + izouSoundLine + " from " + addOnModel + " to non-permanent" ) ; if ( izouSoundLine . isPermanent ( ) ) izouSoundLine . setToNonPermanent ( ) ; List < WeakReference < IzouSoundLineBaseClass > > weakReferences = nonPermanent . get ( addOnModel ) ; if ( weakReferences == null ) weakReferences = Collections . synchronizedList ( new ArrayList < > ( ) ) ; nonPermanent . put ( addOnModel , weakReferences ) ; weakReferences . add ( new WeakReference < > ( izouSoundLine ) ) ; } | adds the IzouSoundLine as NonPermanent |
28,808 | public void requestPermanent ( AddOnModel addOnModel , Identification source , boolean nonJava ) { debug ( "requesting permanent for addon: " + addOnModel ) ; boolean notUsing = isUsing . compareAndSet ( false , true ) ; if ( ! notUsing ) { debug ( "already used by " + permanentAddOn ) ; synchronized ( permanentUserReadWriteLock ) { if ( permanentAddOn != null && permanentAddOn . equals ( addOnModel ) ) { if ( knownIdentification == null ) knownIdentification = source ; return ; } else { endPermanent ( permanentAddOn ) ; addAsPermanent ( addOnModel , source , nonJava ) ; } } } else { addAsPermanent ( addOnModel , source , nonJava ) ; } } | tries to register the AddonModel as permanent |
28,809 | public void endPermanent ( AddOnModel addOnModel ) { if ( ! isUsing . get ( ) || ( permanentAddOn != null && ! permanentAddOn . equals ( addOnModel ) ) ) return ; synchronized ( permanentUserReadWriteLock ) { permanentAddOn = null ; Identification tempID = this . knownIdentification ; this . knownIdentification = null ; if ( permanentLines != null ) { permanentLines . forEach ( weakReferenceLine -> { if ( weakReferenceLine . get ( ) != null ) weakReferenceLine . get ( ) . setToNonPermanent ( ) ; } ) ; nonPermanent . put ( addOnModel , permanentLines ) ; permanentLines = null ; } stopAddon ( tempID ) ; endWaitingForUsage ( ) ; isUsing . set ( false ) ; } } | unregisters the AddonModel as permanent |
28,810 | void muteOthers ( AddOnModel addOnModel ) { Set < AddOnModel > toMute = nonPermanent . entrySet ( ) . stream ( ) . filter ( entry -> ! entry . getKey ( ) . equals ( addOnModel ) ) . flatMap ( entry -> entry . getValue ( ) . stream ( ) ) . map ( Reference :: get ) . filter ( Objects :: nonNull ) . peek ( izouSoundLineBaseClass -> izouSoundLineBaseClass . setMutedFromSystem ( true ) ) . map ( IzouSoundLine :: getAddOnModel ) . collect ( Collectors . toSet ( ) ) ; if ( permanentAddOn != null && ! permanentAddOn . equals ( addOnModel ) && permanentLines != null ) { toMute . add ( addOnModel ) ; permanentLines . stream ( ) . map ( Reference :: get ) . filter ( Objects :: nonNull ) . forEach ( izouSoundLineBaseClass -> izouSoundLineBaseClass . setMutedFromSystem ( true ) ) ; } toMute . forEach ( this :: mute ) ; List < WeakReference < IzouSoundLineBaseClass > > weakReferences = nonPermanent . get ( addOnModel ) ; if ( weakReferences != null ) { weakReferences . stream ( ) . map ( Reference :: get ) . filter ( Objects :: nonNull ) . forEach ( izouSoundLine -> izouSoundLine . setMutedFromSystem ( false ) ) ; } } | mutes the other Addons |
28,811 | private void mute ( AddOnModel model ) { IdentificationManager . getInstance ( ) . getIdentification ( this ) . map ( id -> new EventMinimalImpl ( SoundIDs . MuteEvent . type , id , SoundIDs . MuteEvent . descriptors ) ) . map ( eventMinimal -> eventMinimal . addResource ( new ResourceMinimalImpl < > ( SoundIDs . MuteEvent . resourceSelector , eventMinimal . getSource ( ) , model , null ) ) ) . ifPresent ( event -> getMain ( ) . getEventDistributor ( ) . fireEventConcurrently ( event ) ) ; } | mutes the list of soundLines and fires the Mute - Event |
28,812 | public void eventFired ( EventModel event ) { if ( event . containsDescriptor ( SoundIDs . StartRequest . descriptor ) ) { Identification identification = event . getListResourceContainer ( ) . provideResource ( "izou.common.resource.selector" ) . stream ( ) . map ( ResourceModel :: getResource ) . filter ( resource -> resource instanceof Identification ) . map ( resource -> ( Identification ) resource ) . findFirst ( ) . orElseGet ( event :: getSource ) ; AddOnModel addonModel = getMain ( ) . getAddOnInformationManager ( ) . getAddonModel ( identification ) ; if ( addonModel != null ) { requestPermanent ( addonModel , event . getSource ( ) , event . containsDescriptor ( SoundIDs . StartEvent . isUsingNonJava ) ) ; } } else if ( event . containsDescriptor ( SoundIDs . StartEvent . descriptor ) ) { checkAndUpdateIdentification ( event . getSource ( ) ) ; } else { Identification identification = event . getListResourceContainer ( ) . provideResource ( "izou.common.resource.selector" ) . stream ( ) . map ( ResourceModel :: getResource ) . filter ( resource -> resource instanceof Identification ) . map ( resource -> ( Identification ) resource ) . findFirst ( ) . orElseGet ( event :: getSource ) ; AddOnModel addonModel = getMain ( ) . getAddOnInformationManager ( ) . getAddonModel ( identification ) ; if ( addonModel != null ) { endPermanent ( addonModel ) ; } } } | Invoked when an activator - event occurs . |
28,813 | public static URL makeURL ( String specification ) throws MalformedURLException { logger . trace ( "retrieving URL for specification: '{}'" , specification ) ; if ( specification . startsWith ( "classpath:" ) ) { logger . trace ( "URL is of type 'classpath'" ) ; return new URL ( null , specification , new ClassPathURLStreamHandler ( ) ) ; } logger . trace ( "URL is of normal type" ) ; return new URL ( specification ) ; } | Returns an URL object for the given URL specification . |
28,814 | public int compareTo ( ItemAndSupport other ) { if ( other . support == this . support ) { return this . item - other . item ; } else { return other . support - this . support ; } } | Returns a negative integer zero or a positive integer as this object s support is less than equal to or greater than the specified object s support . |
28,815 | public int [ ] get ( ) { if ( capacity < buffer . size ( ) ) { capacity = buffer . size ( ) ; } int [ ] res = buffer . toArray ( ) ; buffer . clear ( capacity ) ; return res ; } | Resets the builder by the way |
28,816 | public String getV4Authorization ( String accessKey , String secretKey , String action , String url , String serviceId , Map < String , String > headers , String bodyHash ) throws InternalException { serviceId = serviceId . toLowerCase ( ) ; String regionId = "us-east-1" ; String host = url . replaceAll ( "https?:\\/\\/" , "" ) ; if ( host . indexOf ( '/' ) > 0 ) { host = host . substring ( 0 , host . indexOf ( '/' , 1 ) ) ; } if ( ! IAMMethod . SERVICE_ID . equalsIgnoreCase ( serviceId ) ) { String [ ] urlParts = host . split ( "\\." ) ; if ( urlParts . length > 2 ) { regionId = urlParts [ 1 ] ; if ( regionId . startsWith ( "s3-" ) ) { regionId = regionId . substring ( 3 ) ; } } } String amzDate = extractV4Date ( headers ) ; String credentialScope = getV4CredentialScope ( amzDate , regionId , serviceId ) ; String signedHeaders = getV4SignedHeaders ( headers ) ; String signature = signV4 ( secretKey , action , url , regionId , serviceId , headers , bodyHash ) ; return V4_ALGORITHM + " " + "Credential=" + accessKey + "/" + credentialScope + ", " + "SignedHeaders=" + signedHeaders + ", " + "Signature=" + signature ; } | Generates an AWS v4 signature authorization string |
28,817 | private String getOwnerId ( ) { APITrace . begin ( this , "AWSCloud.getOwnerId" ) ; try { ProviderContext ctx = getContext ( ) ; if ( ctx == null ) { return null ; } Map < String , String > parameters = getStandardParameters ( getContext ( ) , EC2Method . DESCRIBE_SECURITY_GROUPS ) ; EC2Method method ; NodeList blocks ; Document doc ; method = new EC2Method ( EC2Method . SERVICE_ID , this , parameters ) ; try { doc = method . invoke ( ) ; } catch ( EC2Exception e ) { logger . error ( e . getSummary ( ) ) ; throw new CloudException ( e ) ; } blocks = doc . getElementsByTagName ( "securityGroupInfo" ) ; for ( int i = 0 ; i < blocks . getLength ( ) ; i ++ ) { NodeList items = blocks . item ( i ) . getChildNodes ( ) ; for ( int j = 0 ; j < items . getLength ( ) ; j ++ ) { Node item = items . item ( j ) ; if ( item . getNodeName ( ) . equals ( "item" ) ) { NodeList attrs = item . getChildNodes ( ) ; for ( int k = 0 ; k < attrs . getLength ( ) ; k ++ ) { Node attr = attrs . item ( k ) ; if ( attr . getNodeName ( ) . equals ( "ownerId" ) ) { return attr . getFirstChild ( ) . getNodeValue ( ) . trim ( ) ; } } } } } return null ; } catch ( InternalException e ) { } catch ( CloudException e ) { } finally { APITrace . end ( ) ; } return null ; } | Retrieve current account number using DescribeSecurityGroups . May not always be reliable but is better than nothing . |
28,818 | public static long getTimestampValue ( Node node ) throws CloudException { SimpleDateFormat fmt = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" ) ; fmt . setTimeZone ( TimeZone . getTimeZone ( "UTC" ) ) ; String value = getTextValue ( node ) ; try { return fmt . parse ( value ) . getTime ( ) ; } catch ( ParseException e ) { logger . error ( e ) ; e . printStackTrace ( ) ; throw new CloudException ( e ) ; } } | Gets the epoch form of the text value of the provided node . |
28,819 | public static < T > T getBean ( Class < T > type ) { checkBeanFactory ( 0 , type . getName ( ) ) ; return beanFactory . getBean ( type ) ; } | Pobiera z kontekstu aplikacji obiekt o wskazanym typie . |
28,820 | public static void generateSecretKey ( KeyConfig config ) throws NoSuchAlgorithmException , KeyStoreException , CertificateException , IOException { if ( config == null || config . getKeyStoreFile ( ) == null || StringUtils . isEmpty ( config . getKeyEntryName ( ) ) || config . getAlgorithm ( ) == null ) { throw new KeyStoreException ( "Missing parameters, unable to create keystore." ) ; } SecureRandom random = new SecureRandom ( ) ; KeyGenerator keygen = KeyGenerator . getInstance ( config . getAlgorithm ( ) . getName ( ) , new BouncyCastleProvider ( ) ) ; keygen . init ( config . getKeySize ( ) , random ) ; SecretKey key = keygen . generateKey ( ) ; KeyStore keyStore = KeyStore . getInstance ( "JCEKS" ) ; FileInputStream fis = null ; if ( config . getKeyStoreFile ( ) . exists ( ) && FileUtils . sizeOf ( config . getKeyStoreFile ( ) ) > 0 ) { fis = new FileInputStream ( config . getKeyStoreFile ( ) ) ; } keyStore . load ( fis , config . getKeyStorePassword ( ) . toCharArray ( ) ) ; KeyStore . ProtectionParameter protectionParameter = new KeyStore . PasswordProtection ( config . getKeyStorePassword ( ) . toCharArray ( ) ) ; KeyStore . SecretKeyEntry secretKeyEntry = new KeyStore . SecretKeyEntry ( key ) ; keyStore . setEntry ( config . getKeyEntryName ( ) , secretKeyEntry , protectionParameter ) ; if ( fis != null ) { fis . close ( ) ; } FileOutputStream fos = new FileOutputStream ( config . getKeyStoreFile ( ) ) ; keyStore . store ( fos , config . getKeyStorePassword ( ) . toCharArray ( ) ) ; fos . close ( ) ; } | Method which will generate a random Secret key and add it to a keystore with the entry name provided . |
28,821 | public static SecretKey getSecretKey ( File keystore , String entryName , String keyStorePassword ) throws KeyStoreException , NoSuchAlgorithmException , CertificateException , FileNotFoundException , IOException , UnrecoverableEntryException { KeyStore keyStore = KeyStore . getInstance ( "JCEKS" ) ; FileInputStream fis = null ; if ( keystore == null || ! keystore . exists ( ) || FileUtils . sizeOf ( keystore ) == 0 ) { throw new FileNotFoundException ( ) ; } if ( StringUtils . isEmpty ( keyStorePassword ) ) { throw new KeyStoreException ( "No Keystore password provided." ) ; } if ( StringUtils . isEmpty ( entryName ) ) { throw new KeyStoreException ( "No Keystore entry name provided." ) ; } fis = new FileInputStream ( keystore ) ; return getSecretKey ( fis , entryName , keyStorePassword ) ; } | Method which will load a secret key from disk with the specified entry name . |
28,822 | public static SecretKey getSecretKey ( InputStream keyInputStream , String entryName , String keyStorePassword ) throws KeyStoreException , NoSuchAlgorithmException , CertificateException , IOException , UnrecoverableEntryException { KeyStore keyStore = KeyStore . getInstance ( "JCEKS" ) ; if ( keyInputStream == null ) { throw new KeyStoreException ( "No Keystore stream provided." ) ; } if ( StringUtils . isEmpty ( keyStorePassword ) ) { throw new KeyStoreException ( "No Keystore password provided." ) ; } if ( StringUtils . isEmpty ( entryName ) ) { throw new KeyStoreException ( "No Keystore entry name provided." ) ; } keyStore . load ( keyInputStream , keyStorePassword . toCharArray ( ) ) ; KeyStore . ProtectionParameter protectionParameter = new KeyStore . PasswordProtection ( keyStorePassword . toCharArray ( ) ) ; KeyStore . SecretKeyEntry pkEntry = ( KeyStore . SecretKeyEntry ) keyStore . getEntry ( entryName , protectionParameter ) ; try { return pkEntry . getSecretKey ( ) ; } finally { keyInputStream . close ( ) ; } } | Method which will load a secret key from an input stream with the specified entry name . |
28,823 | public static SupportedType guess ( ISource source ) { Logger logger = LoggerFactory . getLogger ( MimeGuesser . class ) ; SupportedType type = SupportedType . TEXT ; if ( ! source . available ( ) ) { return type ; } InputStream stream = source . stream ( ) ; try { if ( stream . available ( ) <= 0 ) { logger . trace ( "Blank files will be treated as plain text" ) ; return type ; } } catch ( IOException e1 ) { logger . debug ( "Error while checking file availability: {}" , e1 . getMessage ( ) ) ; return type ; } try { String typeString = URLConnection . guessContentTypeFromStream ( stream ) ; ; if ( typeString == null || typeString . isEmpty ( ) ) { typeString = URLConnection . guessContentTypeFromName ( source . getPath ( ) ) ; } if ( typeString == null || typeString . isEmpty ( ) ) { typeString = source . getExtension ( ) . toLowerCase ( ) ; } logger . trace ( "Mime type: " + typeString ) ; if ( typeString . contains ( "xml" ) ) { type = SupportedType . XML ; } else if ( typeString . contains ( "json" ) ) { type = SupportedType . JSON ; } else if ( typeString . contains ( "yaml" ) ) { type = SupportedType . YAML ; } } catch ( IOException e ) { logger . error ( "Could not get MIME type due to i/o exception: {}" , e . getMessage ( ) ) ; } catch ( Exception ex ) { logger . error ( "Could not get MIME due to exception: {}" , ex . getMessage ( ) ) ; type = SupportedType . TEXT ; ex . printStackTrace ( ) ; } finally { try { stream . close ( ) ; } catch ( IOException e ) { logger . trace ( "Could not close stream: {}" , e . getMessage ( ) ) ; } } return type ; } | Guesses the supported type from the given source . If the source type cannot be guessed then it returns TEXT . If the source is empty it returns TEXT . If it cannot guess then it returns TEXT . |
28,824 | public final DataModel fromJson ( final InputStream resource ) { ObjectMapper mapper = new ObjectMapper ( ) ; mapper . addMixInAnnotations ( DataType . class , DataTypeConfigMixin . class ) ; mapper . addMixInAnnotations ( ObjectDataType . class , ObjectDataTypeConfigMixin . class ) ; try { return mapper . readValue ( resource , DataModel . class ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Create data model definition from JSON file . |
28,825 | private void registerOrThrow ( AddOnModel addOn , String permissionMessage ) throws IzouSoundPermissionException { Function < PluginDescriptor , Boolean > checkPlayPermission = descriptor -> { if ( descriptor . getAddOnProperties ( ) == null ) throw new IzouPermissionException ( "addon_config.properties not found for addon:" + addOn ) ; try { return descriptor . getAddOnProperties ( ) . getProperty ( "audio_output" ) != null && descriptor . getAddOnProperties ( ) . getProperty ( "audio_output" ) . trim ( ) . equals ( "true" ) && descriptor . getAddOnProperties ( ) . getProperty ( "audio_usage_descripton" ) != null && ! descriptor . getAddOnProperties ( ) . getProperty ( "audio_usage_descripton" ) . trim ( ) . equals ( "null" ) && ! descriptor . getAddOnProperties ( ) . getProperty ( "audio_usage_descripton" ) . trim ( ) . isEmpty ( ) ; } catch ( NullPointerException e ) { return false ; } } ; registerOrThrow ( addOn , ( ) -> new IzouSoundPermissionException ( permissionMessage ) , checkPlayPermission ) ; } | registers the AddOn or throws the Exception |
28,826 | public static int xmx2MB ( String xmx ) { int size = 200 ; if ( xmx == null || xmx . isEmpty ( ) ) { return size ; } String s = xmx . substring ( xmx . length ( ) - 1 , xmx . length ( ) ) ; int unit = - 1 ; int localSize = - 1 ; if ( unitMap . get ( s ) == null ) { localSize = Integer . valueOf ( xmx . substring ( 4 , xmx . length ( ) ) ) ; return localSize / 1024 / 1024 ; } else { unit = unitMap . get ( s ) ; localSize = Integer . valueOf ( xmx . substring ( 4 , xmx . length ( ) - 1 ) ) ; } switch ( unit ) { case K : size = localSize / 1024 ; break ; case M : size = localSize ; break ; case G : size = localSize * 1024 ; break ; } return size ; } | - Xmx to MByte |
28,827 | public XMLElement [ ] getChildren ( String name ) { java . util . List < XMLElement > list = new java . util . ArrayList < XMLElement > ( ) ; for ( XMLElement child : getChildren ( ) ) { if ( child . getName ( ) . equals ( name ) ) { list . add ( child ) ; } } return ( 0 < list . size ( ) ) ? list . toArray ( new XMLElement [ 0 ] ) : null ; } | Returns children that have the specified name as a XMLElement array . |
28,828 | public final TaskExecutor < T > addObservers ( TaskObserver < T > ... observers ) { if ( observers != null ) { for ( TaskObserver < T > observer : observers ) { this . observers . add ( observer ) ; } } return this ; } | Adds task observers to the set of registered observers . |
28,829 | public List < Future < T > > execute ( @ SuppressWarnings ( "unchecked" ) Task < T > ... tasks ) { List < Future < T > > futures = new ArrayList < Future < T > > ( ) ; if ( tasks != null ) { synchronized ( queue ) { int i = 0 ; for ( Task < T > task : tasks ) { if ( task != null ) { this . tasks . add ( task ) ; TaskCallable < T > callable = new TaskCallable < T > ( i ++ , queue , task ) ; for ( TaskObserver < T > observer : observers ) { observer . onTaskStarting ( task ) ; } futures . add ( executor . submit ( callable ) ) ; for ( TaskObserver < T > observer : observers ) { observer . onTaskStarted ( task ) ; } } } } } return futures ; } | Starts the given set of tasks asynchronously returning their futures . |
28,830 | public List < T > waitForAll ( List < Future < T > > futures ) throws InterruptedException , ExecutionException { Map < Integer , T > results = new HashMap < Integer , T > ( ) ; int count = futures . size ( ) ; while ( count -- > 0 ) { int id = queue . take ( ) ; logger . trace ( "task '{}' complete (count: {}, queue: {})" , id , count , queue . size ( ) ) ; T result = futures . get ( id ) . get ( ) ; results . put ( id , result ) ; for ( TaskObserver < T > observer : observers ) { observer . onTaskComplete ( tasks . get ( id ) , result ) ; } } logger . debug ( "all tasks completed" ) ; List < T > values = new ArrayList < T > ( ) ; for ( int i = 0 ; i < results . size ( ) ; ++ i ) { values . add ( results . get ( i ) ) ; } return values ; } | Waits for all tasks to complete before returning ; if observers are provided they are called each time a task completes . |
28,831 | public static final Color fromString ( String value ) { if ( Strings . isValid ( value ) ) { Regex regex = new Regex ( COLOR_REGEX , false ) ; if ( regex . matches ( value . trim ( ) ) ) { int r = - 1 , g = - 1 , b = - 1 ; String [ ] matches = regex . getAllMatches ( value ) . get ( 0 ) ; if ( matches [ 0 ] != null && matches [ 0 ] . equals ( "#" ) ) { if ( matches [ 1 ] . length ( ) == 3 ) { r = Integer . decode ( "0X" + matches [ 5 ] + matches [ 5 ] ) ; g = Integer . decode ( "0X" + matches [ 6 ] + matches [ 6 ] ) ; b = Integer . decode ( "0X" + matches [ 7 ] + matches [ 7 ] ) ; } else if ( matches [ 1 ] . length ( ) == 6 ) { r = Integer . decode ( "0X" + matches [ 2 ] ) ; g = Integer . decode ( "0X" + matches [ 3 ] ) ; b = Integer . decode ( "0X" + matches [ 4 ] ) ; } } else if ( matches [ 8 ] != null && matches [ 8 ] . equalsIgnoreCase ( "rgb" ) ) { r = Integer . parseInt ( matches [ 9 ] ) ; g = Integer . parseInt ( matches [ 10 ] ) ; b = Integer . parseInt ( matches [ 11 ] ) ; } if ( 0 <= r && r <= 255 && 0 <= g && g <= 255 && 0 <= b && b <= 255 ) { return new Color ( r , g , b ) ; } } } return null ; } | Parses an input string and returns the corresponding colour object . |
28,832 | public static long copy ( final File input , final OutputStream output ) throws IOException { long size = 0L ; InputStream file_input = null ; try { file_input = new FileInputStream ( input ) ; size = copy ( file_input , output ) ; } finally { try { file_input . close ( ) ; } catch ( Exception ex ) { } } return size ; } | Reads the contents from the file and writes them to the specified stream . |
28,833 | public static long copy ( final InputStream input , final File output ) throws IOException { OutputStream stream_output = null ; long size = 0L ; try { stream_output = new FileOutputStream ( output ) ; size = copy ( input , stream_output ) ; } finally { try { stream_output . close ( ) ; } catch ( Exception ex ) { } } return size ; } | Reads the contents from the specified stream and writes them to the file . |
28,834 | public static long copy ( final InputStream input , final OutputStream output ) throws IOException { _LOG_ . debug ( "begin copy" ) ; @ SuppressWarnings ( "resource" ) BufferedInputStream b_input = ( BufferedInputStream . class . isInstance ( input ) ? BufferedInputStream . class . cast ( input ) : new BufferedInputStream ( input ) ) ; @ SuppressWarnings ( "resource" ) BufferedOutputStream b_output = ( BufferedOutputStream . class . isInstance ( output ) ? BufferedOutputStream . class . cast ( output ) : new BufferedOutputStream ( output ) ) ; byte [ ] buffer = new byte [ 512 ] ; long size = 0 ; try { while ( true ) { int n = b_input . read ( buffer ) ; if ( n == - 1 ) { break ; } b_output . write ( buffer , 0 , n ) ; size += n ; } } finally { try { b_output . flush ( ) ; } catch ( Exception ex ) { } } _LOG_ . debug ( "end copy: #bytes=" + size ) ; return size ; } | Reads the contents from the specified input stream and writes them to the output stream . In this method the given streams are not closed . |
28,835 | public static long copy ( final Reader input , final Writer output ) throws IOException { _LOG_ . debug ( "begin copy" ) ; @ SuppressWarnings ( "resource" ) BufferedReader b_input = ( BufferedReader . class . isInstance ( input ) ? BufferedReader . class . cast ( input ) : new BufferedReader ( input ) ) ; @ SuppressWarnings ( "resource" ) BufferedWriter b_output = ( BufferedWriter . class . isInstance ( output ) ? BufferedWriter . class . cast ( output ) : new BufferedWriter ( output ) ) ; char [ ] buffer = new char [ 512 ] ; long size = 0 ; try { while ( true ) { int n = b_input . read ( buffer ) ; if ( n == - 1 ) { break ; } b_output . write ( buffer , 0 , n ) ; size += n ; } } finally { try { b_output . flush ( ) ; } catch ( Exception ex ) { } } _LOG_ . debug ( "end copy: #bytes=" + size ) ; return size ; } | Reads the contents from the specified input and writes them to the output . In this method the given streams are not closed . |
28,836 | public static String readCharacters ( final File file ) throws IOException { Reader reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( file ) , Charset . forName ( "UTF-8" ) ) ) ; StringWriter sw = new StringWriter ( ) ; Writer writer = new BufferedWriter ( sw ) ; copy ( reader , writer ) ; String characters = sw . toString ( ) ; return characters ; } | Reads the contents characters from the file . |
28,837 | public VpnGateway createVpnGateway ( String endpoint , String name , String description , VpnProtocol protocol , String bgpAsn ) throws CloudException , InternalException { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "ENTER: " + AzureVPNSupport . class . getName ( ) + ".createVPNGateway()" ) ; } try { ProviderContext ctx = provider . getContext ( ) ; if ( ctx == null ) { throw new AzureConfigException ( "No context was specified for this request" ) ; } AzureMethod method = new AzureMethod ( provider ) ; StringBuilder xml = new StringBuilder ( ) ; xml . append ( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" ) ; xml . append ( "<NetworkConfiguration xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" ) ; xml . append ( "<VirtualNetworkConfiguration>" ) ; xml . append ( "<LocalNetworkSites>" ) ; xml . append ( "<LocalNetworkSite name=\"" + name + "\">" ) ; xml . append ( "<AddressSpace>" ) ; xml . append ( "<AddressPrefix>" + endpoint + "/32" + "</AddressPrefix>" ) ; xml . append ( "</AddressSpace>" ) ; xml . append ( "<VPNGatewayAddress>" + endpoint + "</VPNGatewayAddress>" ) ; xml . append ( "</LocalNetworkSite>" ) ; xml . append ( "</LocalNetworkSites>" ) ; xml . append ( "</VirtualNetworkConfiguration>" ) ; xml . append ( "</NetworkConfiguration>" ) ; if ( logger . isDebugEnabled ( ) ) { try { method . parseResponse ( xml . toString ( ) , false ) ; } catch ( Exception e ) { logger . warn ( "Unable to parse outgoing XML locally: " + e . getMessage ( ) ) ; logger . warn ( "XML:" ) ; logger . warn ( xml . toString ( ) ) ; } } String resourceDir = NETWORKING_SERVICES + "/media" ; method . post ( ctx . getAccountNumber ( ) , resourceDir , xml . toString ( ) ) ; return null ; } finally { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "EXIT: " + AzureVPNSupport . class . getName ( ) + ".createVPNGateway()" ) ; } } } | Create local network for connecting VPN? |
28,838 | List < Annotation > getAnnotations ( Multimap < String , Annotation > groups , TokenMatcher matcher ) { if ( relationType == null ) { return getAnnotationStream ( groups , matcher ) . filter ( constraint ) . collect ( Collectors . toList ( ) ) ; } return getAnnotationStream ( groups , matcher ) . flatMap ( a -> { if ( relationType . equals ( Types . DEPENDENCY ) ) { return a . children ( ) . stream ( ) . filter ( a2 -> a2 . dependencyRelation ( ) . v1 . equals ( relationValue ) ) ; } return a . sources ( relationType , relationValue ) . stream ( ) ; } ) . flatMap ( a -> { if ( annotationType == null ) { return Stream . of ( a ) ; } return a . get ( annotationType ) . stream ( ) ; } ) . filter ( constraint ) . collect ( Collectors . toList ( ) ) ; } | Gets annotations . |
28,839 | public static < T > SNAXParser < T > createParser ( XMLInputFactory factory , NodeModel < T > model ) { return new SNAXParser < T > ( factory , model ) ; } | Return a new SNAXParser using the specified model . |
28,840 | public void parse ( Reader reader , T data ) throws XMLStreamException , SNAXUserException { init ( reader , data ) ; for ( XMLEvent event = xmlReader . nextEvent ( ) ; xmlReader . hasNext ( ) ; event = xmlReader . nextEvent ( ) ) { processEvent ( event ) ; } } | Parse a data stream represented by a Reader to completion . This will process the entire document and trigger any ElementHandler calls that result from applying the selectors defined in the NodeModel . The data parameter will be passed back as an argument to all ElementHandler calls . |
28,841 | public static boolean isParseable ( Object input ) { return ( null != input ) && ( isWrapperType ( input . getClass ( ) ) || allPrimitiveTypes ( ) . contains ( input . getClass ( ) ) || ( String . class . isInstance ( input ) && ( Strs . inRange ( '0' , '9' ) . matchesAllOf ( MINUS_STRING . matcher ( ( String ) input ) . replaceFirst ( Strs . EMPTY ) ) ) ) ) ; } | Check if the given input is able parse to number or boolean |
28,842 | protected void init ( Class < T > cls , Key ... keys ) { readDataSource = Execution . getDataSourceName ( cls . getName ( ) , true ) ; writeDataSource = Execution . getDataSourceName ( cls . getName ( ) , false ) ; if ( readDataSource == null ) { readDataSource = writeDataSource ; } if ( writeDataSource == null ) { writeDataSource = readDataSource ; } Properties props = new Properties ( ) ; try { InputStream is = DaseinSequencer . class . getResourceAsStream ( DaseinSequencer . PROPERTIES ) ; if ( is != null ) { props . load ( is ) ; } } catch ( Exception e ) { logger . error ( "Problem reading " + DaseinSequencer . PROPERTIES + ": " + e . getMessage ( ) , e ) ; } database = props . getProperty ( "dasein.persist.handlersocket.database" ) ; handlerSocketHost = props . getProperty ( "dasein.persist.handlersocket.host" ) ; port = Integer . valueOf ( props . getProperty ( "dasein.persist.handlersocket.port" ) ) ; poolSize = Integer . valueOf ( props . getProperty ( "dasein.persist.handlersocket.poolSize" ) ) ; List < String > targetColumns = new ArrayList < String > ( ) ; Class < ? > clazz = cls ; while ( clazz != null && ! clazz . equals ( Object . class ) ) { Field [ ] fields = clazz . getDeclaredFields ( ) ; for ( Field f : fields ) { int m = f . getModifiers ( ) ; if ( Modifier . isTransient ( m ) || Modifier . isStatic ( m ) ) { continue ; } if ( f . getType ( ) . getName ( ) . equals ( Collection . class . getName ( ) ) ) { continue ; } if ( ! f . getType ( ) . getName ( ) . equals ( Translator . class . getName ( ) ) ) { targetColumns . add ( f . getName ( ) ) ; types . put ( f . getName ( ) , f . getType ( ) ) ; } } clazz = clazz . getSuperclass ( ) ; } columns = new String [ targetColumns . size ( ) ] ; databaseColumns = new String [ targetColumns . size ( ) ] ; for ( int i = 0 ; i < targetColumns . size ( ) ; i ++ ) { columns [ i ] = targetColumns . get ( i ) ; databaseColumns [ i ] = getSqlName ( targetColumns . get ( i ) ) ; } } | Constructs a new persistent factory for objects of the specified class with the named unique identifier attributes as well as with reading the persistence properties file to find out the HandlerSocket host database port and pool size . |
28,843 | public Collection < T > hsFind ( final String index , final Operator operator , final int limit , final int offset , final String ... indexValues ) throws PersistenceException { if ( indexValues == null || indexValues . length == 0 ) { throw new PersistenceException ( "You must specify index values to use in the lookup!" ) ; } FindOperator findOperator ; Collection < T > results = new ArrayList < T > ( ) ; ResultSet rs = null ; switch ( operator ) { case EQUALS : findOperator = FindOperator . EQ ; break ; case GREATER_THAN : findOperator = FindOperator . GT ; break ; case GREATER_THAN_OR_EQUAL_TO : findOperator = FindOperator . GE ; break ; case LESS_THAN : findOperator = FindOperator . LT ; break ; case LESS_THAN_OR_EQUAL_TO : findOperator = FindOperator . LE ; break ; default : throw new PersistenceException ( "Operator " + operator + " not supported!" ) ; } try { IndexSession session = getSession ( index , databaseColumns ) ; rs = session . find ( indexValues , findOperator , limit , offset ) ; while ( rs != null && rs . next ( ) ) { HashMap < String , Object > state = new HashMap < String , Object > ( ) ; for ( int i = 1 ; i <= columns . length ; i ++ ) { Object ob = getValue ( columns [ i - 1 ] , i , rs ) ; state . put ( columns [ i - 1 ] , ob ) ; } results . add ( getCache ( ) . find ( state ) ) ; } } catch ( Exception e ) { logger . warn ( e . getMessage ( ) , e ) ; throw new PersistenceException ( e . getMessage ( ) ) ; } finally { try { if ( rs != null ) { rs . close ( ) ; } } catch ( SQLException e ) { throw new PersistenceException ( e . getMessage ( ) ) ; } } return results ; } | Hits the HandlerSocket index directly caching objects it finds . |
28,844 | static int computeManhattan ( IntTuple t0 , IntTuple t1 ) { Utils . checkForEqualSize ( t0 , t1 ) ; int sum = 0 ; for ( int i = 0 ; i < t0 . getSize ( ) ; i ++ ) { int d = t0 . get ( i ) - t1 . get ( i ) ; sum += Math . abs ( d ) ; } return sum ; } | Computes the Manhattan distance between the given tuples |
28,845 | static int computeChebyshev ( IntTuple t0 , IntTuple t1 ) { Utils . checkForEqualSize ( t0 , t1 ) ; int max = 0 ; for ( int i = 0 ; i < t0 . getSize ( ) ; i ++ ) { int d = t0 . get ( i ) - t1 . get ( i ) ; max = Math . max ( max , Math . abs ( d ) ) ; } return max ; } | Computes the Chebyshev distance between the given tuples |
28,846 | public void receive ( byte [ ] byteArray ) throws IOException { if ( interpreter . isInSubProcessMode ( ) ) { if ( ! abortSubprocessModeIfNecessary ( byteArray ) ) { if ( echoEnabled ) { echoBytesToClient ( byteArray ) ; } interpreter . processRawInput ( byteArray ) ; } } else { processInput ( byteArray ) ; } } | Contains the loop that processes incoming bytes . |
28,847 | private void replaceCommandLine ( String replacement ) { int currentCLSize = commandLineBuffer . size ( ) ; commandLineBuffer = new ByteArrayOutputStream ( ) ; for ( int x = 0 ; x < replacement . length ( ) ; x ++ ) { commandLineBuffer . write ( replacement . charAt ( x ) ) ; } String replaceString = '\r' + promptStr ; for ( int x = 0 ; x <= currentCLSize ; x ++ ) { replaceString += ' ' ; } replaceString += '\r' + promptStr + replacement ; ps . print ( replaceString ) ; } | Replaces the current command line on the telnet client with another one . |
28,848 | public void send ( byte [ ] message ) { try { ps . write ( message ) ; } catch ( IOException ioe ) { System . out . println ( new LogEntry ( Level . CRITICAL , "IO exception occurred while writing to client" , ioe ) ) ; connection . close ( "IO exception occurred while writing to client" ) ; } } | Sends a message to the telnet client . |
28,849 | public void beep ( ) { try { os . write ( BEL ) ; } catch ( IOException ioe ) { System . out . println ( new LogEntry ( Level . CRITICAL , "IO exception occurred while writing to client" , ioe ) ) ; connection . close ( "IO exception occurred while writing to client" ) ; } } | Tells the client to make a sound . |
28,850 | private void handleBackKey ( ) throws IOException { if ( commandLineBuffer . size ( ) > 0 && curPos > 0 ) { if ( echoEnabled ) { ps . write ( BACK ) ; } String curLine = overwriteCommandlineSkippingChar ( curPos - 1 ) ; eraseLastCharAndMoveBack ( curLine , curPos ) ; curPos -- ; } } | Rewrites the command line to show changes as a result of hitting the back key even if the cursor is positioned in the middle of the command line |
28,851 | private void handleDeleteKey ( ) throws IOException { if ( commandLineBuffer . size ( ) > 0 && curPos < commandLineBuffer . size ( ) ) { String curLine = overwriteCommandlineSkippingChar ( curPos ) ; eraseLastCharAndMoveBack ( curLine , curPos + 1 ) ; } } | Rewrites the command line to show changes as a result of hitting the delete key when the cursor is positioned in the middle of the command line |
28,852 | public static void run ( VicariousFactory factory ) { TweetProvider provider = factory . getTweetProvider ( ) ; List < Status > originals = null ; try { originals = provider . getTweets ( ) ; if ( originals == null || originals . isEmpty ( ) ) { return ; } } catch ( TwitterException exception ) { exception . printStackTrace ( ) ; return ; } Comparator < Status > comparator = new TweetDateComparator ( ) ; Collections . sort ( originals , comparator ) ; TweetModifier modifier = factory . getTweetModifier ( ) ; List < TweetPair > tweetPairs = new ArrayList < TweetPair > ( ) ; for ( Status original : originals ) { StatusUpdate response = modifier . modify ( original ) ; if ( response != null ) { tweetPairs . add ( new TweetPair ( original , response ) ) ; } } TweetPublisher publisher = factory . getTweetPublisher ( ) ; TweetLogger logger = factory . getTweetLogger ( ) ; try { if ( logger == null ) { for ( TweetPair tweetPair : tweetPairs ) { publisher . publish ( tweetPair . response ) ; } } else { for ( TweetPair tweetPair : tweetPairs ) { publisher . publish ( tweetPair . response , new LoggingListener ( logger , tweetPair . original ) ) ; } } } catch ( TwitterException exception ) { exception . printStackTrace ( ) ; return ; } } | Runs a single iteration of the provide modify publish loop using the implementations provided by the given factory |
28,853 | @ Weight ( Weight . Unit . NORMAL ) public static < T > T [ ] joinArrays ( final T [ ] ... arrays ) { int commonLength = 0 ; for ( final T [ ] array : arrays ) { if ( array != null ) { commonLength += array . length ; } } @ SuppressWarnings ( "unchecked" ) final T [ ] result = ( T [ ] ) Array . newInstance ( arrays . getClass ( ) . getComponentType ( ) . getComponentType ( ) , commonLength ) ; int position = 0 ; for ( final T [ ] array : arrays ) { if ( array != null ) { System . arraycopy ( array , 0 , result , position , array . length ) ; position += array . length ; } } return result ; } | Join arrays provided as parameters all arrays must be the same type null values allowed . |
28,854 | @ Weight ( Weight . Unit . NORMAL ) public static < T > T [ ] append ( final T element , final T [ ] array ) { @ SuppressWarnings ( "unchecked" ) final T [ ] result = ( T [ ] ) Array . newInstance ( array . getClass ( ) . getComponentType ( ) , array . length + 1 ) ; System . arraycopy ( array , 0 , result , 1 , array . length ) ; result [ 0 ] = element ; return result ; } | Append element to the start of an array . |
28,855 | public ResponseBuilder deleteResource ( final Resource res ) { final String baseUrl = getBaseUrl ( ) ; final String identifier = baseUrl + req . getPartition ( ) + req . getPath ( ) ; final Session session = ofNullable ( req . getSession ( ) ) . orElseGet ( HttpSession :: new ) ; checkDeleted ( res , identifier ) ; final EntityTag etag = new EntityTag ( md5Hex ( res . getModified ( ) + identifier ) ) ; checkCache ( req . getRequest ( ) , res . getModified ( ) , etag ) ; LOGGER . debug ( "Deleting {}" , identifier ) ; try ( final TrellisDataset dataset = TrellisDataset . createDataset ( ) ) { audit . ifPresent ( svc -> svc . deletion ( res . getIdentifier ( ) , session ) . stream ( ) . map ( skolemizeQuads ( resourceService , baseUrl ) ) . forEachOrdered ( dataset :: add ) ) ; if ( ACL . equals ( req . getExt ( ) ) ) { try ( final Stream < ? extends Triple > triples = res . stream ( PreferUserManaged ) ) { triples . map ( t -> rdf . createQuad ( PreferUserManaged , t . getSubject ( ) , t . getPredicate ( ) , t . getObject ( ) ) ) . forEachOrdered ( dataset :: add ) ; } } if ( resourceService . put ( res . getIdentifier ( ) , dataset . asDataset ( ) ) ) { return status ( NO_CONTENT ) ; } } LOGGER . error ( "Unable to delete resource at {}" , res . getIdentifier ( ) ) ; return serverError ( ) . entity ( "Unable to delete resource. Please consult the logs for more information" ) ; } | Delete the given resource |
28,856 | public Priority [ ] getPriorities ( ) { List < Priority > actualPriorities = new ArrayList < Priority > ( ) ; for ( String priority : getAvailablePriorities ( ) ) { if ( provider . getNumberOfAnnotations ( priority ) > 0 ) { actualPriorities . add ( Priority . fromString ( priority ) ) ; } } return actualPriorities . toArray ( new Priority [ actualPriorities . size ( ) ] ) ; } | Returns the actually used priorities . |
28,857 | public Collection < String > getAvailablePriorities ( ) { ArrayList < String > priorities = new ArrayList < String > ( ) ; if ( StringUtils . isNotEmpty ( high ) ) { priorities . add ( StringUtils . capitalize ( StringUtils . lowerCase ( Priority . HIGH . name ( ) ) ) ) ; } if ( StringUtils . isNotEmpty ( normal ) ) { priorities . add ( StringUtils . capitalize ( StringUtils . lowerCase ( Priority . NORMAL . name ( ) ) ) ) ; } if ( StringUtils . isNotEmpty ( low ) ) { priorities . add ( StringUtils . capitalize ( StringUtils . lowerCase ( Priority . LOW . name ( ) ) ) ) ; } return priorities ; } | Returns the defined priorities . |
28,858 | public boolean dispatch ( String dispatch , String [ ] parameters ) { String dispatchURL = dispatch ; HttpServletRequest servletRequest = httpRequest . get ( ) ; HttpServletResponse servletResponse = httpResponse . get ( ) ; servletResponse . setContentType ( "text/html; charset=UTF-8" ) ; try { Request request = requestRegistry . getCurrentRequest ( ) ; if ( request != null ) { for ( Object name : request . getAttributeMap ( ) . keySet ( ) ) { Object o = request . getAttributeMap ( ) . get ( name ) ; servletRequest . setAttribute ( name . toString ( ) , o ) ; } } switch ( this . dispatchMode ) { case FORWARD : { ServletSupport . forward ( dispatchURL , servletRequest , servletResponse ) ; } default : { ServletSupport . include ( dispatchURL , servletRequest , servletResponse ) ; } } } catch ( ServletException e ) { throw new ResourceException ( "failed to dispatch servlet request to " + dispatchURL , e ) ; } catch ( IOException e ) { throw new ResourceException ( "failed to dispatch servlet request to " + dispatchURL , e ) ; } return true ; } | Iglu request attributes will be copied to the servlet request . |
28,859 | public InputStream getAsStream ( ) throws CacheException { InputStream stream = null ; try { logger . debug ( "opening connection..." ) ; stream = url . openConnection ( proxy != null ? proxy : Proxy . NO_PROXY ) . getInputStream ( ) ; if ( stream == null ) { logger . error ( "error opening stream" ) ; } else { logger . debug ( "stream opened" ) ; } } catch ( IOException e ) { logger . error ( "error accessing url '{}'" , url ) ; throw new CacheException ( "error accessing url " + url , e ) ; } return stream ; } | Accesses the given URL and returns its contents as a stream . |
28,860 | public int compare ( E entity1 , E entity2 ) { T value = property . get ( entity1 ) ; T value2 = property . get ( entity2 ) ; return value . compareTo ( value2 ) ; } | Compares the specified two entities . |
28,861 | public static < O > boolean eq ( O o1 , O o2 ) { return o1 != null ? o1 . equals ( o2 ) : o2 == null ; } | Verifies input objects are equal . |
28,862 | public static InetAddress forUriString ( String hostAddr ) { Preconditions . checkNotNull ( hostAddr ) ; String ipString ; int expectBytes ; if ( hostAddr . startsWith ( "[" ) && hostAddr . endsWith ( "]" ) ) { ipString = hostAddr . substring ( 1 , hostAddr . length ( ) - 1 ) ; expectBytes = 16 ; } else { ipString = hostAddr ; expectBytes = 4 ; } byte [ ] addr = ipStringToBytes ( ipString ) ; if ( addr == null || addr . length != expectBytes ) { throw new IllegalArgumentException ( String . format ( "Not a valid URI IP literal: '%s'" , hostAddr ) ) ; } return bytesToInetAddress ( addr ) ; } | Returns an InetAddress representing the literal IPv4 or IPv6 host portion of a URL encoded in the format specified by RFC 3986 section 3 . 2 . 2 . |
28,863 | public static Inet4Address get6to4IPv4Address ( Inet6Address ip ) { Preconditions . checkArgument ( is6to4Address ( ip ) , "Address '%s' is not a 6to4 address." , toAddrString ( ip ) ) ; return getInet4Address ( Arrays . copyOfRange ( ip . getAddress ( ) , 2 , 6 ) ) ; } | Returns the IPv4 address embedded in a 6to4 address . |
28,864 | public static TeredoInfo getTeredoInfo ( Inet6Address ip ) { Preconditions . checkArgument ( isTeredoAddress ( ip ) , "Address '%s' is not a Teredo address." , toAddrString ( ip ) ) ; byte [ ] bytes = ip . getAddress ( ) ; Inet4Address server = getInet4Address ( Arrays . copyOfRange ( bytes , 4 , 8 ) ) ; int flags = ByteStreams . newDataInput ( bytes , 8 ) . readShort ( ) & 0xffff ; int port = ~ ByteStreams . newDataInput ( bytes , 10 ) . readShort ( ) & 0xffff ; byte [ ] clientBytes = Arrays . copyOfRange ( bytes , 12 , 16 ) ; for ( int i = 0 ; i < clientBytes . length ; i ++ ) { clientBytes [ i ] = ( byte ) ~ clientBytes [ i ] ; } Inet4Address client = getInet4Address ( clientBytes ) ; return new TeredoInfo ( server , client , port , flags ) ; } | Returns the Teredo information embedded in a Teredo address . |
28,865 | public static Inet4Address getCoercedIPv4Address ( InetAddress ip ) { if ( ip instanceof Inet4Address ) { return ( Inet4Address ) ip ; } byte [ ] bytes = ip . getAddress ( ) ; boolean leadingBytesOfZero = true ; for ( int i = 0 ; i < 15 ; ++ i ) { if ( bytes [ i ] != 0 ) { leadingBytesOfZero = false ; break ; } } if ( leadingBytesOfZero && ( bytes [ 15 ] == 1 ) ) { return LOOPBACK4 ; } else if ( leadingBytesOfZero && ( bytes [ 15 ] == 0 ) ) { return ANY4 ; } Inet6Address ip6 = ( Inet6Address ) ip ; long addressAsLong = 0 ; if ( hasEmbeddedIPv4ClientAddress ( ip6 ) ) { addressAsLong = getEmbeddedIPv4ClientAddress ( ip6 ) . hashCode ( ) ; } else { addressAsLong = ByteBuffer . wrap ( ip6 . getAddress ( ) , 0 , 8 ) . getLong ( ) ; } int coercedHash = Hashing . murmur3_32 ( ) . hashLong ( addressAsLong ) . asInt ( ) ; coercedHash |= 0xe0000000 ; if ( coercedHash == 0xffffffff ) { coercedHash = 0xfffffffe ; } return getInet4Address ( Ints . toByteArray ( coercedHash ) ) ; } | Coerces an IPv6 address into an IPv4 address . |
28,866 | static List < DiffBean > diff ( Map < String , Object > oldObject , Map < String , Object > newObject ) { if ( oldObject == null ) oldObject = Objects . newHashMap ( ) ; if ( newObject == null ) newObject = Objects . newHashMap ( ) ; oldObject = Objects . copy ( oldObject ) ; newObject = Objects . copy ( newObject ) ; final List < DiffBean > diff = Objects . newArrayList ( ) ; Closure < TwoMapDiffBean , Object > itr = new Closure < TwoMapDiffBean , Object > ( ) { public Object call ( final TwoMapDiffBean d ) { ObjectIterator . iterate ( d . getM1 ( ) , new Closure < ObjectIterator . IterateBean , Object > ( ) { public Object call ( ObjectIterator . IterateBean i ) { Object o = i . getValue ( ) ; if ( o instanceof Map ) { } else if ( o instanceof List ) { } else { Object oo = null ; if ( ! Objects . isNullOrEmpty ( i . getPath ( ) ) ) oo = ObjectPath . get ( d . getM2 ( ) , i . getPath ( ) , null ) ; if ( d . isM1Old ( ) ) { if ( ! Objects . equals ( o , oo ) ) { final DiffBean res = new DiffBean ( i . getPath ( ) , o , oo ) ; if ( Objects . find ( diff , new Closure < DiffBean , Boolean > ( ) { public Boolean call ( DiffBean input ) { return input . getPath ( ) . equals ( res . getPath ( ) ) ; } } ) == null ) diff . add ( res ) ; } } else { if ( ! Objects . equals ( o , oo ) ) { final DiffBean res = new DiffBean ( i . getPath ( ) , oo , o ) ; if ( Objects . find ( diff , new Closure < DiffBean , Boolean > ( ) { public Boolean call ( DiffBean input ) { return input . getPath ( ) . equals ( res . getPath ( ) ) ; } } ) == null ) diff . add ( res ) ; } } } return o ; } } ) ; return null ; } } ; itr . call ( new TwoMapDiffBean ( oldObject , newObject , true ) ) ; itr . call ( new TwoMapDiffBean ( newObject , oldObject , false ) ) ; return diff ; } | Get difference between two maps |
28,867 | public AppEngineTransaction beginTransaction ( ) { if ( isTransactional ( ) ) { throw new IllegalStateException ( "Transaction has already started [" + transaction . get ( ) . id ( ) + "]" ) ; } AppEngineTransaction tx = new AppEngineTransaction ( this ) ; transaction . set ( tx ) ; logger . fine ( "Transaction [" + transaction . get ( ) . id ( ) + "] started" ) ; return tx ; } | Begins transaction . You have to do transactional operation after calling this method . |
28,868 | public void close ( ) { AppEngineTransaction tx = transaction . get ( ) ; if ( tx != null ) { tx . rollback ( ) ; } } | Closes this session . |
28,869 | public void update ( Object entity ) { if ( entity == null ) { throw new IllegalArgumentException ( "'entity' must not be [" + entity + "]" ) ; } assertTransactional ( ) ; List < Log > logs = transaction . get ( ) . logs ( ) ; if ( logs . isEmpty ( ) ) { throw new IllegalStateException ( "Log [" + Log . Operation . UPDATE + "] is not allowed: previous operation must be [" + Log . Operation . GET + "]" ) ; } for ( int i = logs . size ( ) - 1 ; i >= 0 ; i -- ) { Log log = logs . get ( i ) ; if ( keyValue ( entity ) . equals ( keyValue ( log . entity ( ) ) ) ) { if ( log . operation ( ) == Log . Operation . GET ) { break ; } else { throw new IllegalStateException ( "Log [" + log . operation ( ) + "] -> [" + Log . Operation . UPDATE + "] is not allowed: previous operation must be [" + Log . Operation . GET + "]" ) ; } } } Transaction tx = transaction . get ( ) . transaction ( ) ; datastore . put ( tx , Translation . toEntities ( entity ) ) ; Log log = new Log ( logs . size ( ) + 1 , Log . Operation . UPDATE , entity ) ; log . state ( State . UNCOMMITTED ) ; logs . add ( log ) ; } | Updates the entity in the datastore with the specified one . This method must be invoked under a transaction . |
28,870 | public void delete ( Object entity ) { if ( entity == null ) { throw new IllegalArgumentException ( "'entity' must not be [" + entity + "]" ) ; } assertTransactional ( ) ; List < Log > logs = transaction . get ( ) . logs ( ) ; if ( logs . isEmpty ( ) ) { throw new IllegalStateException ( "Log [" + Log . Operation . DELETE + "] is not allowed: previous operation must be [" + Log . Operation . GET + "]" ) ; } for ( int i = logs . size ( ) - 1 ; i >= 0 ; i -- ) { Log log = logs . get ( i ) ; if ( keyValue ( entity ) . equals ( keyValue ( log . entity ( ) ) ) ) { if ( log . operation ( ) == Log . Operation . GET ) { break ; } else { throw new IllegalStateException ( "Log [" + log . operation ( ) + "] -> [" + Log . Operation . DELETE + "] is not allowed: previous operation must be [" + Log . Operation . GET + "]" ) ; } } } Transaction tx = transaction . get ( ) . transaction ( ) ; List < Key > keys = new ArrayList < Key > ( ) ; for ( Entity e : Translation . toEntities ( entity ) ) { keys . add ( e . getKey ( ) ) ; } datastore . delete ( tx , keys ) ; Log log = new Log ( logs . size ( ) + 1 , Log . Operation . DELETE , entity ) ; log . state ( State . UNCOMMITTED ) ; logs . add ( log ) ; } | Deletes the specified entity from the datastore . This method must be invoked under a transaction . |
28,871 | public static String getExceptionCause ( final Exception exception ) { if ( exception == null ) { return "" ; } final StringBuilder cause = new StringBuilder ( ) ; Throwable nestedException = ( Throwable ) exception ; while ( nestedException != null ) { cause . append ( "Caused by: " ) . append ( nestedException . toString ( ) ) . append ( " " ) ; nestedException = getInnerException ( nestedException ) ; } return cause . toString ( ) ; } | Get a string that represent the caused by of the exception |
28,872 | public static Exception getLowestException ( final Exception exception , final String exceptionPrefix ) { if ( exception == null ) { return null ; } Throwable nestedException = ( Throwable ) exception ; Exception lastLowException = null ; while ( nestedException != null ) { if ( nestedException . getClass ( ) . toString ( ) . startsWith ( "class " + exceptionPrefix ) ) { lastLowException = ( Exception ) nestedException ; } nestedException = getInnerException ( nestedException ) ; } return lastLowException ; } | Get the most inner exception that is exception from exceptionPrefix type . If the exception does not include inner exception of type exceptionPrefix returns null . |
28,873 | private static Throwable getInnerException ( Throwable exception ) { final Throwable tmpException = exception ; exception = getExceptionCauseUsingWellKnownTypes ( tmpException ) ; if ( exception == null ) { for ( CauseMethodName methodName : CauseMethodName . values ( ) ) { exception = getExceptionCauseUsingMethodName ( tmpException , methodName ) ; if ( exception != null ) { break ; } } } return exception ; } | Get a one level inner exception |
28,874 | private static Throwable getExceptionCauseUsingMethodName ( final Throwable throwable , final CauseMethodName methodName ) { Method method = null ; try { method = throwable . getClass ( ) . getMethod ( methodName . toString ( ) , ( Class [ ] ) null ) ; } catch ( NoSuchMethodException exception ) { } catch ( SecurityException exception ) { } if ( method != null && Throwable . class . isAssignableFrom ( method . getReturnType ( ) ) ) { try { return ( Throwable ) method . invoke ( throwable , new Object [ ] { } ) ; } catch ( IllegalAccessException exception ) { } catch ( IllegalArgumentException exception ) { } catch ( InvocationTargetException exception ) { } } return null ; } | To discover inner exception this method try to use reflection of known methods that could give the nested exception . So it ignore case of NoSuchMethodException SecurityException IllegalAccessException IllegalArgumentException and InvocationTargetException . |
28,875 | public Optional < Identification > getIdentification ( Identifiable identifiable ) { if ( ! registered . containsKey ( identifiable . getID ( ) ) ) { return Optional . empty ( ) ; } AddOnModel registered = addOnInformationManager . getAddonModel ( this . registered . get ( identifiable . getID ( ) ) ) ; AddOnModel requested = addOnInformationManager . getAddonModel ( identifiable ) ; if ( ! ( registered == requested ) ) { return Optional . empty ( ) ; } return Optional . of ( IdentificationImpl . createIdentification ( identifiable , true ) ) ; } | If you have registered with an Identifiable interface you can receive Identification Instances with this method . |
28,876 | public Optional < Identification > getIdentification ( String id ) { return Optional . ofNullable ( registered . get ( id ) ) . map ( IdentificationImpl :: createIdentification ) ; } | If a class has registered with an Identifiable interface you can receive an Identification Instance describing the class by providing his ID . |
28,877 | public boolean registerIdentification ( Identifiable identifiable ) { if ( identifiable == null || identifiable . getID ( ) == null || identifiable . getID ( ) . isEmpty ( ) ) return false ; if ( registered . containsValue ( identifiable ) || registered . containsKey ( identifiable . getID ( ) ) ) { return false ; } registered . put ( identifiable . getID ( ) , identifiable ) ; return true ; } | Registers an Identifiable ID has to be unique . |
28,878 | protected void initialize ( String pFileName , boolean parse ) { this . fileName = pFileName ; Path path = null ; try { path = getPath ( pFileName ) ; List < String > lines = Files . readAllLines ( path , Charset . defaultCharset ( ) ) ; int i = 1 ; for ( String line : lines ) { processLine ( line , i , parse ) ; } } catch ( URISyntaxException | IOException | FileSystemNotFoundException ex ) { LOGGER . severe ( String . format ( "Error with file: %s, path: %s." , pFileName , path ) ) ; LOGGER . severe ( ex . getLocalizedMessage ( ) ) ; } } | Initialize abbreviations . It reads a file and fulfill the abbreviation map . |
28,879 | public Integer lookup ( String entry ) { if ( ! data . containsKey ( entry ) ) { int oldsize = data . size ( ) ; data . put ( entry , data . size ( ) + 1 ) ; String msg = String . format ( "new entry: %s (size: %d -> %d)" , entry , oldsize , data . size ( ) ) ; if ( fileName != null ) { msg += " " + fileName ; } LOGGER . info ( msg ) ; } return data . get ( entry ) ; } | Looking for the abbreviated value of a text . |
28,880 | public void save ( String fileName ) throws FileNotFoundException , UnsupportedEncodingException { try ( PrintWriter writer = new PrintWriter ( fileName , "UTF-8" ) ) { for ( Map . Entry < String , Integer > entry : data . entrySet ( ) ) { writer . println ( String . format ( "%d;%s" , entry . getValue ( ) , entry . getKey ( ) ) ) ; } } } | Save the abbreviations into a file . |
28,881 | private Path getPath ( String fileName ) throws IOException , URISyntaxException { Path path ; URL url = getClass ( ) . getClassLoader ( ) . getResource ( fileName ) ; if ( url == null ) { throw new IOException ( String . format ( "File %s is not existing" , fileName ) ) ; } URI uri = url . toURI ( ) ; Map < String , String > env = new HashMap < > ( ) ; if ( uri . toString ( ) . contains ( "!" ) ) { String [ ] parts = uri . toString ( ) . split ( "!" ) ; if ( fs == null ) { fs = FileSystems . newFileSystem ( URI . create ( parts [ 0 ] ) , env ) ; } path = fs . getPath ( parts [ 1 ] ) ; } else { path = Paths . get ( uri ) ; } return path ; } | A get a java . nio . file . Path object from a file name . |
28,882 | private String fetchRemoteIfNecessary ( String s ) { if ( s . startsWith ( "s3" ) ) { String [ ] bucketAndKey = parseBucketKeyAndFileName ( s ) ; String bucket = bucketAndKey [ 0 ] ; String key = bucketAndKey [ 1 ] ; String fileName = bucketAndKey [ 2 ] ; log . info ( "KeyTool - fetching " + s ) ; S3Object obj = s3Client . getObject ( bucket , key ) ; log . info ( "KeyTool - fetched " + s ) ; quickState . put ( s , "fetched" ) ; File f = new File ( _keyDir , fileName ) ; FileOutputStream os = null ; log . info ( "KeyTool - output file " + f . getAbsolutePath ( ) ) ; try { S3ObjectInputStream is = obj . getObjectContent ( ) ; log . info ( "KeyTool - fetching " + s ) ; os = new FileOutputStream ( f ) ; IOUtils . copy ( is , os ) ; log . info ( "local path now " + f . getAbsolutePath ( ) ) ; return f . getAbsolutePath ( ) ; } catch ( Exception ex ) { log . info ( "KeyTool - failed to write to " + f . getAbsolutePath ( ) ) ; throw new RuntimeException ( ex ) ; } finally { if ( os != null ) { IOUtils . closeQuietly ( os ) ; } } } return s ; } | review - remove the need for a keys dir - keep keys in memory |
28,883 | private String [ ] parseBucketKeyAndFileName ( String s ) { String [ ] ret = new String [ 3 ] ; s = s . substring ( "s3://" . length ( ) ) ; int index = s . indexOf ( "/" ) ; String bucket = s . substring ( 0 , index ) ; String key = s . substring ( index + 1 ) ; String fn = s . substring ( s . lastIndexOf ( "/" ) + 1 ) ; ret [ 0 ] = bucket ; ret [ 1 ] = key ; ret [ 2 ] = fn ; return ret ; } | rushing this morning - MA |
28,884 | public Response getPartitions ( final UriInfo uriInfo , final HttpHeaders headers ) { final IRI identifier = rdf . createIRI ( properties . getProperty ( "baseUrl" , uriInfo . getBaseUri ( ) . toString ( ) ) ) ; LOGGER . debug ( "Request for root resource at: {}" , identifier . getIRIString ( ) ) ; final List < Triple > graph = new ArrayList < > ( ) ; partitions . entrySet ( ) . stream ( ) . map ( e -> rdf . createIRI ( e . getValue ( ) + e . getKey ( ) ) ) . map ( obj -> rdf . createTriple ( identifier , LDP . contains , obj ) ) . forEach ( graph :: add ) ; properties . stringPropertyNames ( ) . stream ( ) . filter ( propMapping :: containsKey ) . map ( name -> rdf . createTriple ( identifier , propMapping . get ( name ) , isUrl ( properties . getProperty ( name ) ) ? rdf . createIRI ( properties . getProperty ( name ) ) : rdf . createLiteral ( properties . getProperty ( name ) ) ) ) . forEach ( graph :: add ) ; final RDFSyntax syntax = getSyntax ( headers . getAcceptableMediaTypes ( ) , empty ( ) ) . orElseThrow ( NotAcceptableException :: new ) ; final IRI profile = ofNullable ( getProfile ( headers . getAcceptableMediaTypes ( ) , syntax ) ) . orElseGet ( ( ) -> getDefaultProfile ( syntax , identifier ) ) ; final StreamingOutput stream = new StreamingOutput ( ) { public void write ( final OutputStream out ) throws IOException { ioService . write ( graph . stream ( ) , out , syntax , profile ) ; } } ; return ok ( ) . header ( ALLOW , join ( "," , HttpMethod . GET , HEAD , OPTIONS ) ) . link ( LDP . Resource . getIRIString ( ) , "type" ) . link ( LDP . RDFSource . getIRIString ( ) , "type" ) . type ( syntax . mediaType ) . entity ( stream ) . build ( ) ; } | Get a representation of the root resource |
28,885 | @ Action ( domainEvent = DownloadLayoutEvent . class , semantics = SemanticsOf . SAFE , restrictTo = RestrictTo . PROTOTYPING ) @ ActionLayout ( contributed = Contributed . AS_ACTION , cssClassFa = "fa-download" ) @ MemberOrder ( sequence = "500.900" ) public Clob downloadLayout ( final Object domainObject ) { return developerUtilitiesService . downloadLayout ( domainObject ) ; } | Download the JSON layout of the domain object s type . |
28,886 | void prepareForWrite ( long xaDataRecorderId ) throws IOException , InterruptedException { this . dataLogger . reopen ( AccessMode . WRITE ) ; this . writeStartSequence ( xaDataRecorderId ) ; } | prepares the Logger for writing . The current content is removed . |
28,887 | public void put ( Object entity ) { ResourceManager < Transaction > manager = new AppEngineResourceManager ( datastore , datastore . beginTransaction ( ) , transaction ) ; manager . put ( entity ) ; Log log = new Log ( transaction . logs ( ) . size ( ) + 1 , Log . Operation . PUT , entity ) ; log . state ( State . UNCOMMITTED ) ; transaction . logs ( ) . add ( log ) ; managers . put ( keyValue ( entity ) , manager ) ; logger . fine ( "Transaction [" + transaction . id ( ) + "]: Entity [" + entity + "] has been put" ) ; } | Puts the specified entity instance into the datastore newly within the current transaction . |
28,888 | public void update ( Object entity ) { ResourceManager < Transaction > manager = managers . get ( keyValue ( entity ) ) ; if ( manager == null ) { throw new IllegalStateException ( "Log [" + Log . Operation . UPDATE + "] is not allowed: previous operation must be [" + Log . Operation . GET + "]" ) ; } manager . update ( entity ) ; Log log = new Log ( transaction . logs ( ) . size ( ) + 1 , Log . Operation . UPDATE , entity ) ; log . state ( State . UNCOMMITTED ) ; transaction . logs ( ) . add ( log ) ; logger . fine ( "Transaction [" + transaction . id ( ) + "]: Entity [" + entity + "] has been updated" ) ; } | Updates the entity in the datastore with the specified one within the current transaction . |
28,889 | public void rollback ( ) { for ( ResourceManager < Transaction > manager : managers . values ( ) ) { Transaction transaction = manager . transaction ( ) ; if ( transaction . isActive ( ) ) { try { transaction . rollback ( ) ; } catch ( Exception e ) { logger . warning ( "Transaction [" + transaction . getId ( ) + "]: Rollback failed due to [" + e + "]; Consistency will be ensured in read" ) ; } } } } | Rolls back every operation in the current transaction . |
28,890 | protected static SQLEnum value ( Class < ? extends SQLEnum > clazz , String value ) { if ( value == null ) { return null ; } value = value . trim ( ) ; if ( valuesCache . containsKey ( clazz ) ) { Map < String , SQLEnum > map2 = valuesCache . get ( clazz ) ; if ( map2 . containsKey ( value ) ) { return map2 . get ( value ) ; } } return null ; } | Hay un problema se puede llamar a este metodo antes de cargar la clase hija por lo que habria un proiblema |
28,891 | protected Object callNativeFunction ( HttpServletRequest request , HttpServletResponse response ) { ServletWebRequest servletWebRequest = new ServletWebRequest ( request ) ; AtmosRequest atmosRequest = new AtmosRequest ( servletWebRequest ) ; AtmosResponse atmosResponse = new AtmosResponse ( ) ; Context context = Context . enter ( ) ; ScriptableObject scope = ( ScriptableObject ) context . initStandardObjects ( global ) ; injectPathVariables ( servletWebRequest , scope ) ; atmosFunction . setParentScope ( scope ) ; Object result = atmosFunction . call ( context , scope , atmosFunction , new Object [ ] { atmosRequest , atmosResponse } ) ; processCookie ( atmosResponse , response , scope ) ; processSession ( atmosRequest , request , scope ) ; processRedirectOrForwardPath ( atmosResponse , scope ) ; return result ; } | Call Javascript Native Function |
28,892 | public String getRedirectUrl ( ) throws XMLStreamException , IOException { String url = this . settings . getIdpSsoTargetUrl ( ) ; url += "?SAMLRequest=" ; url += URLEncoder . encode ( this . getXmlBase64Request ( ) , "UTF-8" ) ; if ( this . parameters != null ) { for ( Map . Entry < String , String > param : this . parameters . entrySet ( ) ) { String key = URLEncoder . encode ( param . getKey ( ) , "UTF-8" ) ; String val = URLEncoder . encode ( param . getValue ( ) , "UTF-8" ) ; url += "&" + key + "=" + val ; } } return url ; } | Return the full IDP redirect url with encoded SAML request |
28,893 | void connect ( SocketAddress socketAddress , boolean useSSL ) { ChannelFactory channelFactory = new NioClientSocketChannelFactory ( Executors . newCachedThreadPool ( ) , Executors . newCachedThreadPool ( ) ) ; ChannelPipeline clientPipeline = NettyChannelPipeline . newPipeline ( connection ) ; SslHandler sslHandler = null ; if ( useSSL ) { sslHandler = getClientSSLHandler ( ) ; clientPipeline . addFirst ( "ssl" , sslHandler ) ; } bootstrap = new ClientBootstrap ( channelFactory ) ; bootstrap . setOption ( "tcpNoDelay" , true ) ; bootstrap . setPipeline ( clientPipeline ) ; final CountDownLatch connectedLatch = new CountDownLatch ( 1 ) ; ConnectionStateListener connectedListener = new ConnectionStateListener ( ) { public void onConnectionConnected ( ) { connectedLatch . countDown ( ) ; } public void onConnectionClosing ( ) { } public void onConnectionClosed ( ) { } } ; connection . addConnectionStateListener ( connectedListener ) ; try { ChannelFuture future = bootstrap . connect ( socketAddress ) ; log . debug ( "connecting" ) ; future . await ( ) ; if ( future . isSuccess ( ) ) { connectedLatch . await ( ) ; log . debug ( "connected successfully" ) ; if ( useSSL ) { doSSLHandshake ( sslHandler ) ; } connected = true ; } else { log . debug ( "connection failed" ) ; throw new ConnectionException ( future . getCause ( ) ) ; } } catch ( InterruptedException e ) { throw new ConnectionException ( "Interrupted while connecting" ) ; } finally { connection . removeConnectionStateListener ( connectedListener ) ; } } | Connect to the remote server and perform the SSL handshake if SSL is being used . |
28,894 | public void quit ( String reason ) { if ( ! connected ) { throw new NotConnectedException ( ) ; } Message quit = new Message ( MessageType . QUIT , reason ) ; ChannelFuture future = connection . send ( quit ) ; future . addListener ( new ChannelFutureListener ( ) { public void operationComplete ( ChannelFuture future ) throws Exception { connection . close ( ) ; } } ) ; } | Quit from the server and close all network connections |
28,895 | public Channel join ( String channelName ) { if ( ! connected ) { throw new NotConnectedException ( ) ; } ChannelImpl channel = new ChannelImpl ( this , channelName ) ; if ( channel . join ( ) ) { return channel ; } return null ; } | Join the given channel . Create a new channel object for this connection join the channel and return the IRCChannel object . |
28,896 | public NegateMultiPos < S , Integer , Integer > before ( int rightIndex ) { return new NegateMultiPos < S , Integer , Integer > ( 0 , rightIndex ) { protected S result ( ) { return aQueue ( 'J' , left , right , pos , position , null , plusminus , filltgt ) ; } } ; } | Sets the substring in the beginning and given right index as the search string |
28,897 | public NegateMultiPos < S , Integer , Character > after ( int leftIndex ) { return new NegateMultiPos < S , Integer , Character > ( leftIndex , null ) { protected S result ( ) { return aQueue ( 'K' , left , right , pos , position , null , plusminus , filltgt ) ; } } ; } | Sets the substring in given left index and the ending as the search string |
28,898 | public AsymmMultiPos < S , String , String > betn ( String left , String right ) { return new AsymmMultiPos < S , String , String > ( left , right ) { protected S result ( ) { if ( Strs . isEmpty ( asymmLR ) ) { return aQueue ( 'S' , left , right , pos , position , inclusive , plusminus , filltgt ) ; } else { return aQueue ( 'Z' , left , right , pos , asymmLR , inclusive , plusminus , filltgt ) ; } } } ; } | Sets the substrings in given left tag and right tag as the search string |
28,899 | public InclusMultiPos < S , String , String > before ( String right ) { return new InclusMultiPos < S , String , String > ( right , null ) { protected S result ( ) { return aQueue ( 'B' , left , right , pos , position , inclusive , plusminus , filltgt ) ; } } ; } | Sets the substrings in given left tag and ending as the search string |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.