idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
2,100 | private void setReservable ( ChargingStationId chargingStationId , boolean reservable ) { ChargingStation chargingStation = repository . findOne ( chargingStationId . getId ( ) ) ; if ( chargingStation != null ) { chargingStation . setReservable ( reservable ) ; repository . createOrUpdate ( chargingStation ) ; } } | Makes a charging station reservable or not reservable . |
2,101 | public boolean isAuthorized ( ChargingStationId chargingStationId , UserIdentity userIdentity , Class commandClass ) { boolean isAuthorized = commandAuthorizationRepository . find ( chargingStationId . getId ( ) , userIdentity . getId ( ) , commandClass ) != null ; if ( ! isAuthorized ) { isAuthorized = commandAuthoriz... | Checks if a user identity has access to a command class for a certain charging station . |
2,102 | private Boolean messageIdHeaderExists ( List < SoapHeader > headers ) { for ( SoapHeader header : headers ) { if ( header . getName ( ) . getLocalPart ( ) . equalsIgnoreCase ( LOCAL_NAME ) ) { return true ; } } return false ; } | Checks if the MessageID header exists in the list of headers . |
2,103 | public WampMessage parseMessage ( ChargingStationId chargingStationId , Reader reader ) throws IOException { String rawMessage = this . convertToString ( reader ) ; String trimmedMessage = this . removeBrackets ( rawMessage ) ; int payloadStart = trimmedMessage . indexOf ( "{" ) ; String payload = payloadStart > 0 ? tr... | Parses a CALL RESULT or ERROR message and constructs a WampMessage |
2,104 | private String convertToString ( Reader reader ) throws IOException { StringBuilder stringBuilder = new StringBuilder ( ) ; int numChars ; char [ ] chars = new char [ 50 ] ; do { numChars = reader . read ( chars , 0 , chars . length ) ; if ( numChars > 0 ) { stringBuilder . append ( chars , 0 , numChars ) ; } } while (... | Constructs a String by reading the characters from the Reader |
2,105 | private String removeQuotes ( String toReplace ) { String noQuotes = toReplace . replaceAll ( "\"" , "" ) ; noQuotes = noQuotes . replaceAll ( "'" , "" ) ; return noQuotes ; } | Removes all single and double quotes from the given String . |
2,106 | public AuthorizeRequest getAuthorizeRequest ( ) { AuthorizeRequest authorizeRequest = new AuthorizeRequest ( ) ; authorizeRequest . setPmsIdentifier ( this . pmsIdentifier ) ; authorizeRequest . setUserIdentifier ( this . userIdentifier ) ; authorizeRequest . setServiceTypeIdentifier ( ServiceType . fromValue ( this . ... | The type of service this local service provides |
2,107 | protected void extractBeanValues ( final Object source , final String [ ] nameMapping ) throws SuperCsvReflectionException { Objects . requireNonNull ( nameMapping , "the nameMapping array can't be null as it's used to map from fields to columns" ) ; beanValues . clear ( ) ; for ( int i = 0 ; i < nameMapping . length ;... | Extracts the bean values using the supplied name mapping array . |
2,108 | public Reservation findByChargingStationIdEvseIdUserId ( ChargingStationId chargingStationId , EvseId evseid , UserIdentity UserId ) throws NoResultException { EntityManager entityManager = getEntityManager ( ) ; try { return entityManager . createQuery ( "SELECT t FROM io.motown.operatorapi.viewmodel.persistence.entit... | find reservations by chargingstationid evseid and userId |
2,109 | private int numberFromTransactionIdString ( ChargingStationId chargingStationId , String protocol , String transactionId ) { String transactionIdPartBeforeNumber = String . format ( "%s_%s_" , chargingStationId . getId ( ) , protocol ) ; try { return Integer . parseInt ( transactionId . substring ( transactionIdPartBef... | Retrieves the number from a transaction id string . ChargingStationId and protocol are passed to make a better guess at the number . |
2,110 | @ Path ( "/session" ) public Response getSession ( String authorizationIdentifier ) { return Response . ok ( ) . entity ( sourceSessionRepository . findSessionInfoByAuthorizationId ( authorizationIdentifier ) ) . build ( ) ; } | Polling of the sessionInfo |
2,111 | public Evse createEvse ( Long chargingStationTypeId , Evse evse ) throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; if ( getEvseByIdentifier ( chargingStationType , evse . getIdentifier ( ) ) != null ) { throw new Resour... | Creates a Evse in a charging station type . |
2,112 | public Set < Evse > getEvses ( Long chargingStationTypeId ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; return chargingStationType . getEvses ( ) ; } | Gets the Evses of a charging station type . |
2,113 | public ChargingStationType updateChargingStationType ( Long id , ChargingStationType chargingStationType ) { chargingStationType . setId ( id ) ; return chargingStationTypeRepository . createOrUpdate ( chargingStationType ) ; } | Update a charging station type . |
2,114 | public Set < Connector > getConnectors ( Long chargingStationTypeId , Long evseId ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; Evse evse = getEvseById ( chargingStationType , evseId ) ; return evse . getConnectors ( ) ; } | Gets the connectors for a charging station type evse . |
2,115 | public Connector createConnector ( Long chargingStationTypeId , Long evseId , Connector connector ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; Evse evse = getEvseById ( chargingStationType , evseId ) ; Set < Connector > originalConnectors = ImmutableS... | Creates a connector in a charging station type evse . |
2,116 | public Connector updateConnector ( Long chargingStationTypeId , Long evseId , Connector connector ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; Evse evse = getEvseById ( chargingStationType , evseId ) ; Connector existingConnector = getConnectorById ( ... | Update a connector . |
2,117 | public Connector getConnector ( Long chargingStationTypeId , Long evseId , Long id ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; Evse evse = getEvseById ( chargingStationType , evseId ) ; return getConnectorById ( evse , id ) ; } | Find a connector based on its id . |
2,118 | public void deleteConnector ( Long chargingStationTypeId , Long evseId , Long id ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; Evse evse = getEvseById ( chargingStationType , evseId ) ; Connector connector = getConnectorById ( evse , id ) ; evse . getC... | Delete a connector . |
2,119 | public Evse updateEvse ( Long chargingStationTypeId , Evse evse ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; Evse existingEvse = getEvseById ( chargingStationType , evse . getId ( ) ) ; chargingStationType . getEvses ( ) . remove ( existingEvse ) ; ch... | Update an evse . |
2,120 | public Evse getEvse ( Long chargingStationTypeId , Long id ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; return getEvseById ( chargingStationType , id ) ; } | Find an evse based on its id . |
2,121 | public void deleteEvse ( Long chargingStationTypeId , Long id ) { ChargingStationType chargingStationType = chargingStationTypeRepository . findOne ( chargingStationTypeId ) ; chargingStationType . getEvses ( ) . remove ( getEvseById ( chargingStationType , id ) ) ; updateChargingStationType ( chargingStationType . get... | Delete an evse . |
2,122 | public Manufacturer updateManufacturer ( Long id , Manufacturer manufacturer ) { manufacturer . setId ( id ) ; return manufacturerRepository . createOrUpdate ( manufacturer ) ; } | Update a manufacturer . |
2,123 | private Evse getEvseById ( ChargingStationType chargingStationType , Long id ) { for ( Evse evse : chargingStationType . getEvses ( ) ) { if ( id . equals ( evse . getId ( ) ) ) { return evse ; } } throw new EntityNotFoundException ( String . format ( "Unable to find evse with id '%s'" , id ) ) ; } | Gets a Evse by id . |
2,124 | private Evse getEvseByIdentifier ( ChargingStationType chargingStationType , int identifier ) { for ( Evse evse : chargingStationType . getEvses ( ) ) { if ( identifier == evse . getIdentifier ( ) ) { return evse ; } } return null ; } | Gets a Evse by identifier . |
2,125 | public Subscription getSubscriptionFromRequest ( HttpServletRequest request ) { String tokenHeader = request . getHeader ( "Authorization" ) ; if ( tokenHeader == null || tokenHeader . indexOf ( "Token " ) != 0 ) { LOG . info ( "Empty authorizationheader, or header does not start with 'Token ': " + tokenHeader ) ; retu... | Finds Subscription object based on request . |
2,126 | public Endpoint getEndpoint ( ModuleIdentifier identifier ) { for ( Endpoint endpoint : getEndpoints ( ) ) { if ( endpoint . getIdentifier ( ) . equals ( identifier ) ) { return endpoint ; } } return null ; } | returns the Endpoint with the identifier passed as argument if not found returns null |
2,127 | public void startTransaction ( ChargingStationId chargingStationId , EvseId evseId , IdentifyingToken idTag , FutureEventCallback futureEventCallback , AddOnIdentity addOnIdentity ) { ChargingStation chargingStation = this . checkChargingStationExistsAndIsRegisteredAndConfigured ( chargingStationId ) ; if ( evseId . ge... | Generates a transaction identifier and starts a transaction by dispatching a StartTransactionCommand . |
2,128 | public void changeConfiguration ( ChargingStationId chargingStationId , ConfigurationItem configurationItem , CorrelationToken correlationToken , AddOnIdentity addOnIdentity ) { IdentityContext identityContext = new IdentityContext ( addOnIdentity , new NullUserIdentity ( ) ) ; commandGateway . send ( new ChangeConfigu... | Change the configuration in the charging station . It has already happened on the physical charging station but the Domain has not been updated yet . |
2,129 | public Transaction createTransaction ( EvseId evseId ) { Transaction transaction = new Transaction ( ) ; transaction . setEvseId ( evseId ) ; transactionRepository . insert ( transaction ) ; return transaction ; } | Creates a transaction identifier . The EVSE identifier is stored for later usage . |
2,130 | private ChargingStation checkChargingStationExistsAndIsRegisteredAndConfigured ( ChargingStationId chargingStationId ) { ChargingStation chargingStation = chargingStationRepository . findOne ( chargingStationId . getId ( ) ) ; if ( chargingStation == null ) { throw new IllegalStateException ( "Unknown charging station.... | Checks if the charging station exists in the repository and if it has been registered and configured . If not a IllegalStateException will be thrown . |
2,131 | private Version findHighestMutualVersion ( Versions offeredVersions ) { Version highestSupportedVersion = null ; for ( String supportedVersion : Arrays . asList ( AppConfig . SUPPORTED_VERSIONS ) ) { Version match = offeredVersions . find ( supportedVersion ) ; if ( match != null ) { highestSupportedVersion = match ; }... | returns the highest mutual version between the offeredVersions of the partner and the supported versions on our side |
2,132 | private Credentials postCredentials ( Subscription subscription ) { String credentialsUrl = subscription . getEndpoint ( ModuleIdentifier . CREDENTIALS ) . getUrl ( ) ; LOG . info ( "Posting credentials at " + credentialsUrl + " with authorizationToken: " + subscription . getPartnerAuthorizationToken ( ) ) ; Credential... | Posts the credentials of the user with the EMSP credentials endpoint |
2,133 | public void register ( Subscription subscription ) { Endpoint versionsEndpoint = subscription . getEndpoint ( ModuleIdentifier . VERSIONS ) ; if ( versionsEndpoint == null ) { return ; } LOG . info ( "Registering, get versions from endpoint " + versionsEndpoint . getUrl ( ) ) ; Version version = findHighestMutualVersio... | registers with the EMSP with passed as argument the endpoints of this EMSP are stored in the database as well as the definitive token |
2,134 | private String getAuthTokenFromRequest ( HttpServletRequest httpRequest ) { String authToken = httpRequest . getHeader ( AUTH_TOKEN_HEADER_KEY ) ; if ( authToken == null ) { authToken = httpRequest . getParameter ( AUTH_TOKEN_PARAMETER_KEY ) ; } return authToken ; } | Gets the authorization token from the request . First tries the header if that s empty the parameter is checked . |
2,135 | private static int getPreviousPageOffset ( final int offset , final int limit ) { return hasFullPreviousPage ( offset , limit ) ? getPreviousFullPageOffset ( offset , limit ) : getFirstPageOffset ( ) ; } | Gets the previous page offset . |
2,136 | private static long getNextPageOffset ( final int offset , final int limit , final long total ) { return hasFullNextPage ( offset , limit , total ) ? getNextFullPageOffset ( offset , limit ) : getLastPageOffset ( total , limit ) ; } | Gets the next page offset . |
2,137 | public ChargePointService createChargingStationService ( String chargingStationAddress ) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean ( ) ; factory . setServiceClass ( ChargePointService . class ) ; factory . setAddress ( chargingStationAddress ) ; SoapBindingConfiguration conf = new SoapBindingConfigura... | Creates a charging station web service proxy . |
2,138 | public void synchronizeTokens ( Endpoint tokenEndPoint ) { Integer subscriptionId = tokenEndPoint . getSubscriptionId ( ) ; String partnerAuthorizationToken = tokenEndPoint . getSubscription ( ) . getPartnerAuthorizationToken ( ) ; String lastSyncDate = getLastSyncDate ( subscriptionId ) ; int totalCount = 1 ; int numb... | Retrieves tokens from the enpoint passed as argument and stores these in the database |
2,139 | private String getLastSyncDate ( Integer subscriptionId ) { String lastSyncDate = null ; TokenSyncDate tokenSyncDate = ocpiRepository . getTokenSyncDate ( subscriptionId ) ; if ( tokenSyncDate != null ) { lastSyncDate = AppConfig . DATE_FORMAT . format ( tokenSyncDate . getSyncDate ( ) ) ; } return lastSyncDate ; } | Returns the formatted datetime the tokens where last synchronized if it exists otherwise null . |
2,140 | private void updateLastSynchronizationDate ( Date syncDate , Integer subscriptionId ) { TokenSyncDate tokenSyncDate = ocpiRepository . getTokenSyncDate ( subscriptionId ) ; if ( tokenSyncDate == null ) { tokenSyncDate = new TokenSyncDate ( ) ; tokenSyncDate . setSubscriptionId ( subscriptionId ) ; } tokenSyncDate . set... | Updates the last sync date for the passed subscription . |
2,141 | private void insertOrUpdateToken ( io . motown . ocpi . dto . Token tokenUpdate , Integer subscriptionId ) { Token token = ocpiRepository . findTokenByUidAndIssuingCompany ( tokenUpdate . uid , tokenUpdate . issuer ) ; if ( token == null ) { token = new Token ( ) ; token . setUid ( tokenUpdate . uid ) ; token . setSubs... | Inserts a token or updates it if an existing token is found with the same uid and issuing - company |
2,142 | public String getChargingStationAddress ( MessageContext messageContext ) { if ( ! ( messageContext instanceof WrappedMessageContext ) ) { LOG . warn ( "Unable to get message context, or message context is not the right type." ) ; return "" ; } Message message = ( ( WrappedMessageContext ) messageContext ) . getWrapped... | Gets the charging station address from the SOAP From header . |
2,143 | @ Path ( "authenticate" ) @ Produces ( MediaType . APPLICATION_JSON ) public TokenDto authenticate ( @ FormParam ( "username" ) String username , @ FormParam ( "password" ) String password ) { UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken ( username , password ) ; Aut... | Authenticates a user and creates an authentication token . |
2,144 | public static String getUserNameFromToken ( String authToken ) { if ( null == authToken ) { return null ; } return authToken . split ( TOKEN_SEPARATOR ) [ 0 ] ; } | Extracts the user name from token . |
2,145 | public static boolean validateToken ( String authToken , UserDetails userDetails ) { String [ ] parts = authToken . split ( TOKEN_SEPARATOR ) ; long expires = Long . parseLong ( parts [ 1 ] ) ; String signature = parts [ 2 ] ; return expires >= System . currentTimeMillis ( ) && signature . equals ( TokenUtils . compute... | Validates the token signature against the user details and the current system time . |
2,146 | public VasSubscriberService createVasSubscriberService ( String deliveryAddress ) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean ( ) ; factory . setServiceClass ( VasSubscriberService . class ) ; factory . setAddress ( deliveryAddress ) ; SoapBindingConfiguration conf = new SoapBindingConfiguration ( ) ; c... | Creates a vas subscriber web service proxy based on the delivery address . |
2,147 | public Version find ( String versionToFind ) { for ( Version version : list ) { if ( version . version . equals ( versionToFind ) ) { return version ; } } return null ; } | find returns the version object with the version passed as argument |
2,148 | public ChargeMode getChargeModeFromEvses ( Set < Evse > evses ) { ChargeMode chargeMode = ChargeMode . UNSPECIFIED ; for ( Evse evse : evses ) { if ( ! evse . getConnectors ( ) . isEmpty ( ) ) { chargeMode = ChargeMode . fromChargingProtocol ( evse . getConnectors ( ) . get ( 0 ) . getChargingProtocol ( ) ) ; break ; }... | Determines the charge mode based on the first connector because VAS does not support multiple protocols for a single charging station . If no charge mode can be determined UNSPECIFIED will be returned . |
2,149 | public boolean check ( final int nLevel ) { if ( nLevel == FATAL || nLevel == ERROR ) return m_aLogger . isErrorEnabled ( ) ; if ( nLevel == WARN ) return m_aLogger . isWarnEnabled ( ) ; if ( nLevel == INFO ) return m_aLogger . isInfoEnabled ( ) ; if ( nLevel == DEBUG ) return m_aLogger . isDebugEnabled ( ) ; return m_... | Check if a logger is enabled to log at the specified level |
2,150 | public Sheet createNewSheet ( final String sName ) { m_aLastSheet = sName == null ? m_aWB . createSheet ( ) : m_aWB . createSheet ( WorkbookUtil . createSafeSheetName ( sName ) ) ; m_nLastSheetRowIndex = 0 ; m_aLastRow = null ; m_nLastRowCellIndex = 0 ; m_aLastCell = null ; m_nMaxCellIndex = 0 ; return m_aLastSheet ; } | Create a new sheet with an optional name |
2,151 | public void addCellStyle ( final ExcelStyle aExcelStyle ) { ValueEnforcer . notNull ( aExcelStyle , "ExcelStyle" ) ; if ( m_aLastCell == null ) throw new IllegalStateException ( "No cell present for current row!" ) ; CellStyle aCellStyle = m_aStyleCache . getCellStyle ( aExcelStyle ) ; if ( aCellStyle == null ) { aCell... | Set the cell style of the last added cell |
2,152 | public void autoSizeAllColumns ( ) { for ( short nCol = 0 ; nCol < m_nMaxCellIndex ; ++ nCol ) try { m_aLastSheet . autoSizeColumn ( nCol ) ; } catch ( final IllegalArgumentException ex ) { LOGGER . warn ( "Failed to resize column " + nCol + ": column too wide!" ) ; } } | Auto size all columns to be matching width in the current sheet |
2,153 | public ESuccess writeTo ( final File aFile ) { return writeTo ( FileHelper . getOutputStream ( aFile ) ) ; } | Write the current workbook to a file |
2,154 | public ESuccess writeTo ( final IWritableResource aRes ) { return writeTo ( aRes . getOutputStream ( EAppend . TRUNCATE ) ) ; } | Write the current workbook to a writable resource . |
2,155 | public ESuccess writeTo ( final OutputStream aOS ) { try { ValueEnforcer . notNull ( aOS , "OutputStream" ) ; if ( m_nCreatedCellStyles > 0 && LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Writing Excel workbook with " + m_nCreatedCellStyles + " different cell styles" ) ; m_aWB . write ( aOS ) ; return ESuccess . SUC... | Write the current workbook to an output stream . |
2,156 | public byte [ ] getAsByteArray ( ) { try ( final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ( ) ) { if ( writeTo ( aBAOS ) . isFailure ( ) ) return null ; return aBAOS . getBufferOrCopy ( ) ; } } | Helper method to get the whole workbook as a single byte array . |
2,157 | public CloseableHttpClient getHttpClient ( ) { try { URI crxUri = new URI ( props . getPackageManagerUrl ( ) ) ; final AuthScope authScope = new AuthScope ( crxUri . getHost ( ) , crxUri . getPort ( ) ) ; final Credentials credentials = new UsernamePasswordCredentials ( props . getUserId ( ) , props . getPassword ( ) )... | Set up http client with credentials |
2,158 | private Proxy getProxyForUrl ( String requestUrl ) { List < Proxy > proxies = props . getProxies ( ) ; if ( proxies == null || proxies . isEmpty ( ) ) { return null ; } final URI uri = URI . create ( requestUrl ) ; for ( Proxy proxy : proxies ) { if ( ! proxy . isNonProxyHost ( uri . getHost ( ) ) ) { return proxy ; } ... | Get proxy for given URL |
2,159 | private < T > T executeHttpCallWithRetry ( HttpCall < T > call , int runCount ) { try { return call . execute ( ) ; } catch ( PackageManagerHttpActionException ex ) { if ( runCount < props . getRetryCount ( ) ) { log . info ( "ERROR: " + ex . getMessage ( ) ) ; log . debug ( "HTTP call failed." , ex ) ; log . info ( "-... | Execute HTTP call with automatic retry as configured for the MOJO . |
2,160 | public JSONObject executePackageManagerMethodJson ( CloseableHttpClient httpClient , HttpRequestBase method ) { PackageManagerJsonCall call = new PackageManagerJsonCall ( httpClient , method , log ) ; return executeHttpCallWithRetry ( call , 0 ) ; } | Execute CRX HTTP Package manager method and parse JSON response . |
2,161 | public Document executePackageManagerMethodXml ( CloseableHttpClient httpClient , HttpRequestBase method ) { PackageManagerXmlCall call = new PackageManagerXmlCall ( httpClient , method , log ) ; return executeHttpCallWithRetry ( call , 0 ) ; } | Execute CRX HTTP Package manager method and parse XML response . |
2,162 | public String executePackageManagerMethodHtml ( CloseableHttpClient httpClient , HttpRequestBase method ) { PackageManagerHtmlCall call = new PackageManagerHtmlCall ( httpClient , method , log ) ; String message = executeHttpCallWithRetry ( call , 0 ) ; return message ; } | Execute CRX HTTP Package manager method and get HTML response . |
2,163 | public void executePackageManagerMethodHtmlOutputResponse ( CloseableHttpClient httpClient , HttpRequestBase method ) { PackageManagerHtmlMessageCall call = new PackageManagerHtmlMessageCall ( httpClient , method , log ) ; executeHttpCallWithRetry ( call , 0 ) ; } | Execute CRX HTTP Package manager method and output HTML response . |
2,164 | public void waitForBundlesActivation ( CloseableHttpClient httpClient ) { if ( StringUtils . isBlank ( props . getBundleStatusUrl ( ) ) ) { log . debug ( "Skipping check for bundle activation state because no bundleStatusURL is defined." ) ; return ; } final int WAIT_INTERVAL_SEC = 3 ; final long CHECK_RETRY_COUNT = pr... | Wait for bundles to become active . |
2,165 | protected int getRowFirstNonWhite ( StyledDocument doc , int offset ) throws BadLocationException { Element lineElement = doc . getParagraphElement ( offset ) ; int start = lineElement . getStartOffset ( ) ; while ( start + 1 < lineElement . getEndOffset ( ) ) { try { if ( doc . getText ( start , 1 ) . charAt ( 0 ) != ... | iterates through the text to find first nonwhite |
2,166 | public void execute ( ) throws MojoExecutionException , MojoFailureException { if ( isSkip ( ) ) { return ; } PackageDownloader downloader = new PackageDownloader ( getPackageManagerProperties ( ) , getLoggerWrapper ( ) ) ; File outputFileObject = downloader . downloadFile ( getPackageFile ( ) , this . outputFile ) ; i... | Downloads the files |
2,167 | private void unpackFile ( File file ) throws MojoExecutionException { ContentUnpackerProperties props = new ContentUnpackerProperties ( ) ; props . setExcludeFiles ( this . excludeFiles ) ; props . setExcludeNodes ( this . excludeNodes ) ; props . setExcludeProperties ( this . excludeProperties ) ; props . setExcludeMi... | Unpack content package |
2,168 | protected void substituteText ( JTextComponent component , String toAdd ) { String text = completionText ; if ( toAdd != null ) { text += toAdd ; } try { StyledDocument doc = ( StyledDocument ) component . getDocument ( ) ; doc . remove ( dotOffset , caretOffset - dotOffset ) ; doc . insertString ( dotOffset , text , n... | Substitutes the text inside the component . |
2,169 | public void validate ( ) { if ( StringUtils . isEmpty ( name ) || StringUtils . isEmpty ( group ) ) { throw new IllegalArgumentException ( "Package name or group not set." ) ; } if ( filters . isEmpty ( ) ) { throw new IllegalArgumentException ( "No package filter defined / no package root path set." ) ; } if ( created... | Validates that the mandatory properties are set . |
2,170 | public void addContent ( String path , ContentElement content ) throws IOException { String fullPath = buildJcrPathForZip ( path ) + "/" + DOT_CONTENT_XML ; Document doc = xmlContentBuilder . buildContent ( content ) ; writeXmlDocument ( fullPath , doc ) ; } | Add some JCR content structure directly to the package . |
2,171 | private void buildPackageMetadata ( ) throws IOException { metadata . validate ( ) ; buildTemplatedMetadataFile ( META_DIR + "/" + CONFIG_XML ) ; buildPropertiesFile ( META_DIR + "/" + PROPERTIES_XML ) ; buildTemplatedMetadataFile ( META_DIR + "/" + SETTINGS_XML ) ; buildTemplatedMetadataFile ( META_DIR + "/" + PACKAGE... | Build all package metadata files based on templates . |
2,172 | private void buildTemplatedMetadataFile ( String path ) throws IOException { try ( InputStream is = getClass ( ) . getResourceAsStream ( "/content-package-template/" + path ) ) { String xmlContent = IOUtils . toString ( is ) ; for ( Map . Entry < String , Object > entry : metadata . getVars ( ) . entrySet ( ) ) { xmlCo... | Read template file from classpath replace variables and store it in the zip stream . |
2,173 | private void buildPropertiesFile ( String path ) throws IOException { Properties properties = new Properties ( ) ; properties . put ( MetaInf . PACKAGE_FORMAT_VERSION , Integer . toString ( MetaInf . FORMAT_VERSION_2 ) ) ; properties . put ( PackageProperties . NAME_REQUIRES_ROOT , Boolean . toString ( false ) ) ; for ... | Build java Properties XML file . |
2,174 | private void writeXmlDocument ( String path , Document doc ) throws IOException { zip . putNextEntry ( new ZipEntry ( path ) ) ; try { DOMSource source = new DOMSource ( doc ) ; StreamResult result = new StreamResult ( zip ) ; transformer . transform ( source , result ) ; } catch ( TransformerException ex ) { throw new... | Writes an XML document as binary file entry to the ZIP output stream . |
2,175 | private void writeBinaryFile ( String path , InputStream is ) throws IOException { zip . putNextEntry ( new ZipEntry ( path ) ) ; try { IOUtils . copy ( is , zip ) ; } finally { zip . closeEntry ( ) ; } } | Writes an binary file entry to the ZIP output stream . |
2,176 | private Set < String > resolveClass ( String variableName , String text , Document document ) { Set < String > items = new LinkedHashSet < > ( ) ; FileObject fo = getFileObject ( document ) ; ClassPath sourcePath = ClassPath . getClassPath ( fo , ClassPath . SOURCE ) ; ClassPath compilePath = ClassPath . getClassPath (... | This method tries to find the class which is defined for the given filter and returns a set with all methods and fields of the class |
2,177 | public Set < MemberLookupResult > performMemberLookup ( String variable ) { if ( variable . contains ( "." ) ) { return performNestedLookup ( variable ) ; } Set < MemberLookupResult > ret = new LinkedHashSet < > ( ) ; ParsedStatement statement = getParsedStatement ( variable ) ; if ( statement == null ) { return ret ; ... | The actual lookup |
2,178 | private Set < MemberLookupResult > performNestedLookup ( String variable ) { Set < MemberLookupResult > ret = new LinkedHashSet < > ( ) ; String [ ] parts = StringUtils . split ( variable , "." ) ; if ( parts . length > 2 ) { Set < MemberLookupResult > subResult = performNestedLookup ( StringUtils . substringBeforeLast... | performs a nested lookup . E . g for foo . bar it will resolve the type of bar and then get it s methods |
2,179 | private Set < MemberLookupResult > getMethodsFromClassLoader ( String clazzname , String variable ) { final Set < MemberLookupResult > ret = new LinkedHashSet < > ( ) ; try { Class clazz = classPath . getClassLoader ( true ) . loadClass ( clazzname ) ; for ( Method method : clazz . getMethods ( ) ) { if ( method . getR... | Fallback used to load the methods from classloader |
2,180 | public void installFile ( PackageFile packageFile ) { File file = packageFile . getFile ( ) ; if ( ! file . exists ( ) ) { throw new PackageManagerException ( "File does not exist: " + file . getAbsolutePath ( ) ) ; } try ( CloseableHttpClient httpClient = pkgmgr . getHttpClient ( ) ) { pkgmgr . waitForBundlesActivatio... | Deploy file via package manager . |
2,181 | void merge ( DefaultWorkspaceFilter workspaceFilter ) { for ( Filter item : filters ) { PathFilterSet filterSet = toFilterSet ( item ) ; boolean exists = false ; for ( PathFilterSet existingFilterSet : workspaceFilter . getFilterSets ( ) ) { if ( filterSet . equals ( existingFilterSet ) ) { exists = true ; } } if ( ! e... | Merge configured filter paths with existing workspace filter definition . |
2,182 | public static Service identify ( String url ) { Service answer = Service . UNSUPPORTED ; int index = url . indexOf ( COMPOSUM_URL ) ; if ( index > 0 ) { answer = Service . COMPOSUM ; } else { index = url . indexOf ( CRX_URL ) ; if ( index > 0 ) { answer = Service . CRX ; } } return answer ; } | Identifies the Service Vendor based on the given URL |
2,183 | public static String getBaseUrl ( String url , Logger logger ) { String answer = url ; switch ( identify ( url ) ) { case COMPOSUM : answer = url . substring ( 0 , url . indexOf ( COMPOSUM_URL ) ) ; break ; case CRX : answer = url . substring ( 0 , url . indexOf ( CRX_URL ) ) ; break ; default : logger . error ( "Given... | Returns the Base Url of a given URL with based on its Vendors from the URL |
2,184 | public static VendorPackageInstaller getPackageInstaller ( String url ) throws PackageManagerException { VendorPackageInstaller answer ; switch ( identify ( url ) ) { case COMPOSUM : answer = new ComposumPackageInstaller ( url ) ; break ; case CRX : answer = new CrxPackageInstaller ( url ) ; break ; default : throw new... | Provides the Installer of the Service Vendor |
2,185 | public String getI18nXmlString ( ) { Format format = Format . getPrettyFormat ( ) ; XMLOutputter outputter = new XMLOutputter ( format ) ; return outputter . outputString ( buildI18nXml ( ) ) ; } | Build i18n resource XML in Sling i18n Message format . |
2,186 | public String getI18nPropertiesString ( ) throws IOException { Properties i18nProps = new Properties ( ) ; for ( Entry < String , String > entry : properties . entrySet ( ) ) { String key = entry . getKey ( ) ; String escapedKey = validName ( key ) ; i18nProps . put ( escapedKey , entry . getValue ( ) ) ; } try ( ByteA... | Build i18n resource PROPERTIES . |
2,187 | public Document buildContent ( Map < String , Object > content ) { Document doc = documentBuilder . newDocument ( ) ; String primaryType = StringUtils . defaultString ( ( String ) content . get ( PN_PRIMARY_TYPE ) , NT_UNSTRUCTURED ) ; Element jcrRoot = createJcrRoot ( doc , primaryType ) ; exportPayload ( doc , jcrRoo... | Build XML for any JCR content . |
2,188 | public Document buildFilter ( List < PackageFilter > filters ) { Document doc = documentBuilder . newDocument ( ) ; Element workspaceFilterElement = doc . createElement ( "workspaceFilter" ) ; workspaceFilterElement . setAttribute ( "version" , "1.0" ) ; doc . appendChild ( workspaceFilterElement ) ; for ( PackageFilte... | Build filter XML for package metadata files . |
2,189 | public Rule getRule ( Resource resource ) { for ( Rule rule : rules ) { if ( rule . matches ( resource ) ) { return rule ; } } return null ; } | Get rule matching for the given GraniteUI resource . |
2,190 | public File downloadFile ( File file , String ouputFilePath ) { try ( CloseableHttpClient httpClient = pkgmgr . getHttpClient ( ) ) { log . info ( "Download " + file . getName ( ) + " from " + props . getPackageManagerUrl ( ) ) ; HttpPost post = new HttpPost ( props . getPackageManagerUrl ( ) + "/.json?cmd=upload" ) ; ... | Download content package from CRX instance . |
2,191 | private String sortWeakReferenceValues ( String name , String value ) { Set < String > refs = new TreeSet < > ( ) ; DocViewProperty prop = DocViewProperty . parse ( name , value ) ; for ( int i = 0 ; i < prop . values . length ; i ++ ) { refs . add ( prop . values [ i ] ) ; } List < Value > values = new ArrayList < > (... | Sort weak reference values alphabetically to ensure consistent ordering . |
2,192 | public String getMatchingBundle ( Pattern symbolicNamePattern ) { for ( String bundleSymbolicName : bundleSymbolicNames ) { if ( symbolicNamePattern . matcher ( bundleSymbolicName ) . matches ( ) ) { return bundleSymbolicName ; } } return null ; } | Checks if a bundle with the given pattern exists in the bundle list . |
2,193 | protected JavaSource getJavaSourceForClass ( String clazzname ) { String resource = clazzname . replaceAll ( "\\." , "/" ) + ".java" ; FileObject fileObject = classPath . findResource ( resource ) ; if ( fileObject == null ) { return null ; } Project project = FileOwnerQuery . getOwner ( fileObject ) ; if ( project == ... | Resolves the clazzname to a fileobject of the java - file |
2,194 | protected Set < Element > getMembersFromJavaSource ( final String clazzname , final ElementUtilities . ElementAcceptor acceptor ) { final Set < Element > ret = new LinkedHashSet < > ( ) ; JavaSource javaSource = getJavaSourceForClass ( clazzname ) ; if ( javaSource != null ) { try { javaSource . runUserActionTask ( new... | tries to load all members for the given clazzname from javasource files . |
2,195 | public void run ( ) throws MojoExecutionException { if ( skip ) { return ; } if ( tasks == null || tasks . isEmpty ( ) ) { getLog ( ) . warn ( "No Node.js tasks have been defined. Nothing to do." ) ; } ComparableVersion nodeJsVersionComparable = new ComparableVersion ( nodeJsVersion ) ; if ( nodeJsVersionComparable . c... | Installs node js if necessary and performs defined tasks |
2,196 | private void updateNPMExecutable ( NodeInstallationInformation information ) throws MojoExecutionException { getLog ( ) . info ( "Installing specified npm version " + npmVersion ) ; NpmInstallTask npmInstallTask = new NpmInstallTask ( ) ; npmInstallTask . setLog ( getLog ( ) ) ; npmInstallTask . setNpmBundledWithNodeJs... | Makes sure the specified npm version is installed in the base directory regardless in which environment . |
2,197 | private boolean mapProperty ( JSONObject root , JSONObject node , String key , String ... mapping ) throws JSONException { boolean deleteProperty = false ; for ( String value : mapping ) { Matcher matcher = MAPPED_PATTERN . matcher ( value ) ; if ( matcher . matches ( ) ) { deleteProperty = true ; String path = matcher... | Replaces the value of a mapped property with a value from the original tree . |
2,198 | private void rewriteProperty ( JSONObject node , String key , JSONArray rewriteProperty ) throws JSONException { if ( node . get ( cleanup ( key ) ) instanceof String ) { if ( rewriteProperty . length ( ) == 2 ) { if ( rewriteProperty . get ( 0 ) instanceof String && rewriteProperty . get ( 1 ) instanceof String ) { St... | Applies a string rewrite to a property . |
2,199 | private void addCommonAttrMappings ( JSONObject root , JSONObject node ) throws JSONException { for ( String property : GRANITE_COMMON_ATTR_PROPERTIES ) { String [ ] mapping = { "${./" + property + "}" , "${\'./granite:" + property + "\'}" } ; mapProperty ( root , node , "granite:" + property , mapping ) ; } if ( root ... | Adds property mappings on a replacement node for Granite common attributes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.