idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
28,500 | public ZipMessage addEntry ( File file ) { try { addEntry ( new Entry ( file ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read zip entry content from given file" , e ) ; } return this ; } | Adds new zip archive entry . Entry can be a file or directory . In case of directory all files will be automatically added to the zip archive . Directory structures are retained throughout this process . | 58 | 37 |
28,501 | public ZipMessage addEntry ( String fileName , byte [ ] content ) { Entry entry = new Entry ( fileName ) ; entry . setContent ( content ) ; addEntry ( entry ) ; return this ; } | Adds new zip archive entry with given content . | 44 | 9 |
28,502 | protected void handleInboundSoapMessage ( final org . springframework . ws . soap . SoapMessage soapMessage , final SoapMessage message , final WebServiceEndpointConfiguration endpointConfiguration ) { handleInboundNamespaces ( soapMessage , message ) ; handleInboundSoapHeaders ( soapMessage , message ) ; handleInboundAttachments ( soapMessage , message ) ; if ( endpointConfiguration . isHandleMimeHeaders ( ) ) { handleInboundMimeHeaders ( soapMessage , message ) ; } } | Method handles SOAP specific message information such as SOAP action headers and SOAP attachments . | 111 | 18 |
28,503 | protected void handleInboundHttpHeaders ( final SoapMessage message , final WebServiceEndpointConfiguration endpointConfiguration ) { final TransportContext transportContext = TransportContextHolder . getTransportContext ( ) ; if ( transportContext == null ) { log . warn ( "Unable to get complete set of http request headers - no transport context available" ) ; return ; } final WebServiceConnection connection = transportContext . getConnection ( ) ; if ( connection instanceof HttpServletConnection ) { final UrlPathHelper pathHelper = new UrlPathHelper ( ) ; final HttpServletConnection servletConnection = ( HttpServletConnection ) connection ; final HttpServletRequest httpServletRequest = servletConnection . getHttpServletRequest ( ) ; message . setHeader ( SoapMessageHeaders . HTTP_REQUEST_URI , pathHelper . getRequestUri ( httpServletRequest ) ) ; message . setHeader ( SoapMessageHeaders . HTTP_CONTEXT_PATH , pathHelper . getContextPath ( httpServletRequest ) ) ; final String queryParams = pathHelper . getOriginatingQueryString ( httpServletRequest ) ; message . setHeader ( SoapMessageHeaders . HTTP_QUERY_PARAMS , queryParams != null ? queryParams : "" ) ; message . setHeader ( SoapMessageHeaders . HTTP_REQUEST_METHOD , httpServletRequest . getMethod ( ) ) ; if ( endpointConfiguration . isHandleAttributeHeaders ( ) ) { final Enumeration < String > attributeNames = httpServletRequest . getAttributeNames ( ) ; while ( attributeNames . hasMoreElements ( ) ) { final String attributeName = attributeNames . nextElement ( ) ; final Object attribute = httpServletRequest . getAttribute ( attributeName ) ; message . setHeader ( attributeName , attribute ) ; } } } else { log . warn ( "Unable to get complete set of http request headers" ) ; try { message . setHeader ( SoapMessageHeaders . HTTP_REQUEST_URI , connection . getUri ( ) ) ; } catch ( final URISyntaxException e ) { log . warn ( "Unable to get http request uri from http connection" , e ) ; } } } | Reads information from Http connection and adds them as Http marked headers to internal message representation . | 484 | 20 |
28,504 | protected void handleInboundSoapHeaders ( final org . springframework . ws . soap . SoapMessage soapMessage , final SoapMessage message ) { try { final SoapHeader soapHeader = soapMessage . getSoapHeader ( ) ; if ( soapHeader != null ) { final Iterator < ? > iter = soapHeader . examineAllHeaderElements ( ) ; while ( iter . hasNext ( ) ) { final SoapHeaderElement headerEntry = ( SoapHeaderElement ) iter . next ( ) ; MessageHeaderUtils . setHeader ( message , headerEntry . getName ( ) . getLocalPart ( ) , headerEntry . getText ( ) ) ; } if ( soapHeader . getSource ( ) != null ) { final StringResult headerData = new StringResult ( ) ; final TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; final Transformer transformer = transformerFactory . newTransformer ( ) ; transformer . transform ( soapHeader . getSource ( ) , headerData ) ; message . addHeaderData ( headerData . toString ( ) ) ; } } if ( StringUtils . hasText ( soapMessage . getSoapAction ( ) ) ) { if ( soapMessage . getSoapAction ( ) . equals ( "\"\"" ) ) { message . setHeader ( SoapMessageHeaders . SOAP_ACTION , "" ) ; } else { if ( soapMessage . getSoapAction ( ) . startsWith ( "\"" ) && soapMessage . getSoapAction ( ) . endsWith ( "\"" ) ) { message . setHeader ( SoapMessageHeaders . SOAP_ACTION , soapMessage . getSoapAction ( ) . substring ( 1 , soapMessage . getSoapAction ( ) . length ( ) - 1 ) ) ; } else { message . setHeader ( SoapMessageHeaders . SOAP_ACTION , soapMessage . getSoapAction ( ) ) ; } } } } catch ( final TransformerException e ) { throw new CitrusRuntimeException ( "Failed to read SOAP header source" , e ) ; } } | Reads all soap headers from web service message and adds them to message builder as normal headers . Also takes care of soap action header . | 450 | 27 |
28,505 | private void handleOutboundMimeMessageHeader ( final org . springframework . ws . soap . SoapMessage message , final String name , final Object value , final boolean handleMimeHeaders ) { if ( ! handleMimeHeaders ) { return ; } if ( message instanceof SaajSoapMessage ) { final SaajSoapMessage soapMsg = ( SaajSoapMessage ) message ; final MimeHeaders headers = soapMsg . getSaajMessage ( ) . getMimeHeaders ( ) ; headers . setHeader ( name , value . toString ( ) ) ; } else if ( message instanceof AxiomSoapMessage ) { log . warn ( "Unable to set mime message header '" + name + "' on AxiomSoapMessage - unsupported" ) ; } else { log . warn ( "Unsupported SOAP message implementation - unable to set mime message header '" + name + "'" ) ; } } | Adds a HTTP message header to the SOAP message . | 203 | 11 |
28,506 | protected void handleInboundMessageProperties ( final MessageContext messageContext , final SoapMessage message ) { if ( messageContext == null ) { return ; } final String [ ] propertyNames = messageContext . getPropertyNames ( ) ; if ( propertyNames != null ) { for ( final String propertyName : propertyNames ) { message . setHeader ( propertyName , messageContext . getProperty ( propertyName ) ) ; } } } | Adds all message properties from web service message to message builder as normal header entries . | 90 | 16 |
28,507 | protected void handleInboundAttachments ( final org . springframework . ws . soap . SoapMessage soapMessage , final SoapMessage message ) { final Iterator < Attachment > attachments = soapMessage . getAttachments ( ) ; while ( attachments . hasNext ( ) ) { final Attachment attachment = attachments . next ( ) ; final SoapAttachment soapAttachment = SoapAttachment . from ( attachment ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "SOAP message contains attachment with contentId '%s'" , soapAttachment . getContentId ( ) ) ) ; } message . addAttachment ( soapAttachment ) ; } } | Adds attachments if present in soap web service message . | 149 | 10 |
28,508 | private String getHeaderName ( String name , Map < String , Object > receivedHeaders , TestContext context , HeaderValidationContext validationContext ) { String headerName = context . resolveDynamicValue ( name ) ; if ( ! receivedHeaders . containsKey ( headerName ) && validationContext . isHeaderNameIgnoreCase ( ) ) { String key = headerName ; log . debug ( String . format ( "Finding case insensitive header for key '%s'" , key ) ) ; headerName = receivedHeaders . entrySet ( ) . parallelStream ( ) . filter ( item -> item . getKey ( ) . equalsIgnoreCase ( key ) ) . map ( Map . Entry :: getKey ) . findFirst ( ) . orElseThrow ( ( ) -> new ValidationException ( "Validation failed: No matching header for key '" + key + "'" ) ) ; log . info ( String . format ( "Found matching case insensitive header name: %s" , headerName ) ) ; } return headerName ; } | Get header name from control message but also check if header expression is a variable or function . In addition to that find case insensitive header name in received message when feature is activated . | 216 | 35 |
28,509 | public WaitHttpConditionBuilder status ( HttpStatus status ) { getCondition ( ) . setHttpResponseCode ( String . valueOf ( status . value ( ) ) ) ; return this ; } | Sets the Http status code to check . | 40 | 10 |
28,510 | public List < MessageValidator < ? extends ValidationContext > > findMessageValidators ( String messageType , Message message ) { List < MessageValidator < ? extends ValidationContext > > matchingValidators = new ArrayList <> ( ) ; for ( MessageValidator < ? extends ValidationContext > validator : messageValidators ) { if ( validator . supportsMessageType ( messageType , message ) ) { matchingValidators . add ( validator ) ; } } if ( matchingValidators . isEmpty ( ) || matchingValidators . stream ( ) . allMatch ( validator -> DefaultMessageHeaderValidator . class . isAssignableFrom ( validator . getClass ( ) ) ) ) { // try to find fallback message validator for given message payload if ( message . getPayload ( ) instanceof String && StringUtils . hasText ( message . getPayload ( String . class ) ) ) { String payload = message . getPayload ( String . class ) . trim ( ) ; if ( payload . startsWith ( "<" ) && ! messageType . equals ( MessageType . XML . name ( ) ) ) { matchingValidators = findFallbackMessageValidators ( MessageType . XML . name ( ) , message ) ; } else if ( ( payload . trim ( ) . startsWith ( "{" ) || payload . trim ( ) . startsWith ( "[" ) ) && ! messageType . equals ( MessageType . JSON . name ( ) ) ) { matchingValidators = findFallbackMessageValidators ( MessageType . JSON . name ( ) , message ) ; } else if ( ! messageType . equals ( MessageType . PLAINTEXT . name ( ) ) ) { matchingValidators = findFallbackMessageValidators ( MessageType . PLAINTEXT . name ( ) , message ) ; } } } if ( matchingValidators . isEmpty ( ) || matchingValidators . stream ( ) . allMatch ( validator -> DefaultMessageHeaderValidator . class . isAssignableFrom ( validator . getClass ( ) ) ) ) { throw new CitrusRuntimeException ( "Could not find proper message validator for message type '" + messageType + "', please define a capable message validator for this message type" ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Found %s message validators for message type: %s" , matchingValidators . size ( ) , messageType ) ) ; } return matchingValidators ; } | Finds matching message validators for this message type . | 533 | 11 |
28,511 | public MessageValidator getDefaultMessageHeaderValidator ( ) { return messageValidators . stream ( ) . filter ( validator -> DefaultMessageHeaderValidator . class . isAssignableFrom ( validator . getClass ( ) ) ) . findFirst ( ) . orElse ( null ) ; } | Gets the default message header validator . | 63 | 9 |
28,512 | private void createJmsTemplate ( ) { Assert . isTrue ( this . connectionFactory != null , "Neither 'jmsTemplate' nor 'connectionFactory' is set correctly." ) ; jmsTemplate = new JmsTemplate ( ) ; jmsTemplate . setConnectionFactory ( this . connectionFactory ) ; if ( this . destination != null ) { jmsTemplate . setDefaultDestination ( this . destination ) ; } else if ( this . destinationName != null ) { jmsTemplate . setDefaultDestinationName ( this . destinationName ) ; } if ( this . destinationResolver != null ) { jmsTemplate . setDestinationResolver ( this . destinationResolver ) ; } jmsTemplate . setPubSubDomain ( pubSubDomain ) ; } | Creates default JmsTemplate instance from connection factory and destination . | 161 | 13 |
28,513 | public FirefoxProfile getFirefoxProfile ( ) { if ( firefoxProfile == null ) { firefoxProfile = new FirefoxProfile ( ) ; firefoxProfile . setAcceptUntrustedCertificates ( true ) ; firefoxProfile . setAssumeUntrustedCertificateIssuer ( false ) ; /* default download folder, set to 2 to use custom download folder */ firefoxProfile . setPreference ( "browser.download.folderList" , 2 ) ; /* comma separated list if MIME types to save without asking */ firefoxProfile . setPreference ( "browser.helperApps.neverAsk.saveToDisk" , "text/plain" ) ; /* do not show download manager */ firefoxProfile . setPreference ( "browser.download.manager.showWhenStarting" , false ) ; } return firefoxProfile ; } | Gets the firefoxProfile . | 177 | 7 |
28,514 | @ Override public void openConnection ( Map < String , String > properties ) throws JdbcServerException { if ( ! endpointConfiguration . isAutoConnect ( ) ) { List < OpenConnection . Property > propertyList = convertToPropertyList ( properties ) ; handleMessageAndCheckResponse ( JdbcMessage . openConnection ( propertyList ) ) ; } if ( connections . get ( ) == endpointConfiguration . getServerConfiguration ( ) . getMaxConnections ( ) ) { throw new JdbcServerException ( String . format ( "Maximum number of connections (%s) reached" , endpointConfiguration . getServerConfiguration ( ) . getMaxConnections ( ) ) ) ; } connections . incrementAndGet ( ) ; } | Opens the connection with the given properties | 150 | 8 |
28,515 | @ Override public void closeConnection ( ) throws JdbcServerException { if ( ! endpointConfiguration . isAutoConnect ( ) ) { handleMessageAndCheckResponse ( JdbcMessage . closeConnection ( ) ) ; } if ( connections . decrementAndGet ( ) < 0 ) { connections . set ( 0 ) ; } } | Closes the connection | 70 | 4 |
28,516 | @ Override public void createPreparedStatement ( String stmt ) throws JdbcServerException { if ( ! endpointConfiguration . isAutoCreateStatement ( ) ) { handleMessageAndCheckResponse ( JdbcMessage . createPreparedStatement ( stmt ) ) ; } } | Creates a prepared statement | 58 | 5 |
28,517 | @ Override public DataSet executeQuery ( String query ) throws JdbcServerException { log . info ( "Received execute query request: " + query ) ; Message response = handleMessageAndCheckResponse ( JdbcMessage . execute ( query ) ) ; return dataSetCreator . createDataSet ( response , getMessageType ( response ) ) ; } | Executes a given query and returns the mapped result | 76 | 10 |
28,518 | @ Override public DataSet executeStatement ( String stmt ) throws JdbcServerException { log . info ( "Received execute statement request: " + stmt ) ; Message response = handleMessageAndCheckResponse ( JdbcMessage . execute ( stmt ) ) ; return dataSetCreator . createDataSet ( response , getMessageType ( response ) ) ; } | Executes the given statement | 79 | 5 |
28,519 | @ Override public int executeUpdate ( String updateSql ) throws JdbcServerException { log . info ( "Received execute update request: " + updateSql ) ; Message response = handleMessageAndCheckResponse ( JdbcMessage . execute ( updateSql ) ) ; return Optional . ofNullable ( response . getHeader ( JdbcMessageHeaders . JDBC_ROWS_UPDATED ) ) . map ( Object :: toString ) . map ( Integer :: valueOf ) . orElse ( 0 ) ; } | Executes the given update | 113 | 5 |
28,520 | @ Override public void setTransactionState ( boolean transactionState ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Received transaction state change: '%s':%n%s" , endpointConfiguration . getServerConfiguration ( ) . getDatabaseName ( ) , String . valueOf ( transactionState ) ) ) ; } this . transactionState = transactionState ; if ( ! endpointConfiguration . isAutoTransactionHandling ( ) && transactionState ) { handleMessageAndCheckResponse ( JdbcMessage . startTransaction ( ) ) ; } } | Sets the transaction state of the database connection | 122 | 9 |
28,521 | @ Override public void commitStatements ( ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Received transaction commit: '%s':%n" , endpointConfiguration . getServerConfiguration ( ) . getDatabaseName ( ) ) ) ; } if ( ! endpointConfiguration . isAutoTransactionHandling ( ) ) { handleMessageAndCheckResponse ( JdbcMessage . commitTransaction ( ) ) ; } } | Commits the transaction statements | 96 | 5 |
28,522 | @ Override public void rollbackStatements ( ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Received transaction rollback: '%s':%n" , endpointConfiguration . getServerConfiguration ( ) . getDatabaseName ( ) ) ) ; } if ( ! endpointConfiguration . isAutoTransactionHandling ( ) ) { handleMessageAndCheckResponse ( JdbcMessage . rollbackTransaction ( ) ) ; } } | Performs a rollback on the current transaction | 99 | 9 |
28,523 | @ Override public void createCallableStatement ( String sql ) { if ( ! endpointConfiguration . isAutoCreateStatement ( ) ) { handleMessageAndCheckResponse ( JdbcMessage . createCallableStatement ( sql ) ) ; } } | Creates a callable statement | 50 | 6 |
28,524 | private MessageType getMessageType ( Message response ) { String messageTypeString = ( String ) response . getHeader ( MessageHeaders . MESSAGE_TYPE ) ; if ( MessageType . knows ( messageTypeString ) ) { return MessageType . valueOf ( messageTypeString . toUpperCase ( ) ) ; } return null ; } | Determines the MessageType of the given response | 73 | 10 |
28,525 | private List < OpenConnection . Property > convertToPropertyList ( Map < String , String > properties ) { return properties . entrySet ( ) . stream ( ) . map ( this :: convertToProperty ) . sorted ( Comparator . comparingInt ( OpenConnection . Property :: hashCode ) ) . collect ( Collectors . toList ( ) ) ; } | Converts a property map propertyKey - > propertyValue to a list of OpenConnection . Properties | 73 | 19 |
28,526 | private OpenConnection . Property convertToProperty ( Map . Entry < String , String > entry ) { OpenConnection . Property property = new OpenConnection . Property ( ) ; property . setName ( entry . getKey ( ) ) ; property . setValue ( entry . getValue ( ) ) ; return property ; } | Converts a Map entry into a OpenConnection . Property | 64 | 11 |
28,527 | private Message handleMessageAndCheckResponse ( Message request ) throws JdbcServerException { Message response = handleMessage ( request ) ; checkSuccess ( response ) ; return response ; } | Handle request message and check response is successful . | 37 | 9 |
28,528 | private void checkSuccess ( Message response ) throws JdbcServerException { OperationResult operationResult = null ; if ( response instanceof JdbcMessage || response . getPayload ( ) instanceof OperationResult ) { operationResult = response . getPayload ( OperationResult . class ) ; } else if ( response . getPayload ( ) != null && StringUtils . hasText ( response . getPayload ( String . class ) ) ) { operationResult = ( OperationResult ) endpointConfiguration . getMarshaller ( ) . unmarshal ( new StringSource ( response . getPayload ( String . class ) ) ) ; } if ( ! success ( response , operationResult ) ) { throw new JdbcServerException ( getExceptionMessage ( response , operationResult ) ) ; } } | Check that response is not having an exception message . | 166 | 10 |
28,529 | public Function getFunction ( String functionName ) throws NoSuchFunctionException { if ( ! members . containsKey ( functionName ) ) { throw new NoSuchFunctionException ( "Can not find function " + functionName + " in library " + name + " (" + prefix + ")" ) ; } return members . get ( functionName ) ; } | Try to find function in library by name . | 72 | 9 |
28,530 | public boolean knowsFunction ( String functionName ) { String functionPrefix = functionName . substring ( 0 , functionName . indexOf ( ' ' ) + 1 ) ; if ( ! functionPrefix . equals ( prefix ) ) { return false ; } return members . containsKey ( functionName . substring ( functionName . indexOf ( ' ' ) + 1 , functionName . indexOf ( ' ' ) ) ) ; } | Does this function library know a function with the given name . | 90 | 12 |
28,531 | public java . lang . Object getResultObject ( ApplicationContext applicationContext ) { if ( object == null ) { return null ; } if ( object . getValueObject ( ) != null ) { return object . getValueObject ( ) ; } try { Class argType = Class . forName ( object . getType ( ) ) ; java . lang . Object value = null ; if ( object . getValue ( ) != null ) { value = object . getValue ( ) ; } else if ( StringUtils . hasText ( object . getRef ( ) ) && applicationContext != null ) { value = applicationContext . getBean ( object . getRef ( ) ) ; } if ( value == null ) { return null ; } else if ( argType . isInstance ( value ) || argType . isAssignableFrom ( value . getClass ( ) ) ) { return argType . cast ( value ) ; } else if ( Map . class . equals ( argType ) ) { String mapString = value . toString ( ) ; Properties props = new Properties ( ) ; try { props . load ( new StringReader ( mapString . substring ( 1 , mapString . length ( ) - 1 ) . replace ( ", " , "\n" ) ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to reconstruct service result object of type map" , e ) ; } Map < String , String > map = new LinkedHashMap <> ( ) ; for ( Map . Entry < java . lang . Object , java . lang . Object > entry : props . entrySet ( ) ) { map . put ( entry . getKey ( ) . toString ( ) , entry . getValue ( ) . toString ( ) ) ; } return map ; } else { try { return new SimpleTypeConverter ( ) . convertIfNecessary ( value , argType ) ; } catch ( ConversionNotSupportedException e ) { if ( String . class . equals ( argType ) ) { return value . toString ( ) ; } throw e ; } } } catch ( ClassNotFoundException e ) { throw new CitrusRuntimeException ( "Failed to construct service result object" , e ) ; } } | Gets this service result as object casted to target type if necessary . | 474 | 15 |
28,532 | public AbstractEndpointBuilder < T > initialize ( ) { if ( getEndpoint ( ) instanceof InitializingBean ) { try { ( ( InitializingBean ) getEndpoint ( ) ) . afterPropertiesSet ( ) ; } catch ( Exception e ) { throw new CitrusRuntimeException ( "Failed to initialize endpoint" , e ) ; } } return this ; } | Initializes the endpoint . | 81 | 5 |
28,533 | public AbstractEndpointBuilder < T > applicationContext ( ApplicationContext applicationContext ) { if ( getEndpoint ( ) instanceof ApplicationContextAware ) { ( ( ApplicationContextAware ) getEndpoint ( ) ) . setApplicationContext ( applicationContext ) ; } if ( getEndpoint ( ) instanceof BeanFactoryAware ) { ( ( BeanFactoryAware ) getEndpoint ( ) ) . setBeanFactory ( applicationContext ) ; } return this ; } | Sets the Spring application context . | 98 | 7 |
28,534 | public ExecuteSQLQueryBuilder validate ( String column , String ... values ) { action . getControlResultSet ( ) . put ( column , Arrays . asList ( values ) ) ; return this ; } | Set expected control result set . Keys represent the column names values the expected values . | 43 | 16 |
28,535 | public FtpServerBuilder server ( org . apache . ftpserver . FtpServer server ) { endpoint . setFtpServer ( server ) ; return this ; } | Sets the ftp server . | 36 | 7 |
28,536 | public Workspace getWorkspace ( long workspaceId ) throws StructurizrClientException { if ( workspaceId <= 0 ) { throw new IllegalArgumentException ( "The workspace ID must be a positive integer." ) ; } try ( CloseableHttpClient httpClient = HttpClients . createSystem ( ) ) { log . info ( "Getting workspace with ID " + workspaceId ) ; HttpGet httpGet = new HttpGet ( url + WORKSPACE_PATH + workspaceId ) ; addHeaders ( httpGet , "" , "" ) ; debugRequest ( httpGet , null ) ; try ( CloseableHttpResponse response = httpClient . execute ( httpGet ) ) { debugResponse ( response ) ; String json = EntityUtils . toString ( response . getEntity ( ) ) ; if ( response . getCode ( ) == HttpStatus . SC_OK ) { archiveWorkspace ( workspaceId , json ) ; if ( encryptionStrategy == null ) { return new JsonReader ( ) . read ( new StringReader ( json ) ) ; } else { EncryptedWorkspace encryptedWorkspace = new EncryptedJsonReader ( ) . read ( new StringReader ( json ) ) ; if ( encryptedWorkspace . getEncryptionStrategy ( ) != null ) { encryptedWorkspace . getEncryptionStrategy ( ) . setPassphrase ( encryptionStrategy . getPassphrase ( ) ) ; return encryptedWorkspace . getWorkspace ( ) ; } else { // this workspace isn't encrypted, even though the client has an encryption strategy set return new JsonReader ( ) . read ( new StringReader ( json ) ) ; } } } else { ApiResponse apiResponse = ApiResponse . parse ( json ) ; throw new StructurizrClientException ( apiResponse . getMessage ( ) ) ; } } } catch ( Exception e ) { log . error ( e ) ; throw new StructurizrClientException ( e ) ; } } | Gets the workspace with the given ID . | 413 | 9 |
28,537 | public void putWorkspace ( long workspaceId , Workspace workspace ) throws StructurizrClientException { if ( workspace == null ) { throw new IllegalArgumentException ( "The workspace must not be null." ) ; } else if ( workspaceId <= 0 ) { throw new IllegalArgumentException ( "The workspace ID must be a positive integer." ) ; } try ( CloseableHttpClient httpClient = HttpClients . createSystem ( ) ) { if ( mergeFromRemote ) { Workspace remoteWorkspace = getWorkspace ( workspaceId ) ; if ( remoteWorkspace != null ) { workspace . getViews ( ) . copyLayoutInformationFrom ( remoteWorkspace . getViews ( ) ) ; workspace . getViews ( ) . getConfiguration ( ) . copyConfigurationFrom ( remoteWorkspace . getViews ( ) . getConfiguration ( ) ) ; } } workspace . setId ( workspaceId ) ; workspace . setThumbnail ( null ) ; workspace . setLastModifiedDate ( new Date ( ) ) ; workspace . setLastModifiedAgent ( STRUCTURIZR_FOR_JAVA_AGENT ) ; workspace . setLastModifiedUser ( getUser ( ) ) ; workspace . countAndLogWarnings ( ) ; HttpPut httpPut = new HttpPut ( url + WORKSPACE_PATH + workspaceId ) ; StringWriter stringWriter = new StringWriter ( ) ; if ( encryptionStrategy == null ) { JsonWriter jsonWriter = new JsonWriter ( false ) ; jsonWriter . write ( workspace , stringWriter ) ; } else { EncryptedWorkspace encryptedWorkspace = new EncryptedWorkspace ( workspace , encryptionStrategy ) ; encryptionStrategy . setLocation ( EncryptionLocation . Client ) ; EncryptedJsonWriter jsonWriter = new EncryptedJsonWriter ( false ) ; jsonWriter . write ( encryptedWorkspace , stringWriter ) ; } StringEntity stringEntity = new StringEntity ( stringWriter . toString ( ) , ContentType . APPLICATION_JSON ) ; httpPut . setEntity ( stringEntity ) ; addHeaders ( httpPut , EntityUtils . toString ( stringEntity ) , ContentType . APPLICATION_JSON . toString ( ) ) ; debugRequest ( httpPut , EntityUtils . toString ( stringEntity ) ) ; log . info ( "Putting workspace with ID " + workspaceId ) ; try ( CloseableHttpResponse response = httpClient . execute ( httpPut ) ) { String json = EntityUtils . toString ( response . getEntity ( ) ) ; if ( response . getCode ( ) == HttpStatus . SC_OK ) { debugResponse ( response ) ; log . info ( json ) ; } else { ApiResponse apiResponse = ApiResponse . parse ( json ) ; throw new StructurizrClientException ( apiResponse . getMessage ( ) ) ; } } } catch ( Exception e ) { log . error ( e ) ; throw new StructurizrClientException ( e ) ; } } | Updates the given workspace . | 637 | 6 |
28,538 | public void write ( Workspace workspace , Writer writer ) { if ( workspace == null ) { throw new IllegalArgumentException ( "A workspace must be provided." ) ; } if ( writer == null ) { throw new IllegalArgumentException ( "A writer must be provided." ) ; } workspace . getViews ( ) . getSystemLandscapeViews ( ) . forEach ( v -> write ( v , writer ) ) ; workspace . getViews ( ) . getSystemContextViews ( ) . forEach ( v -> write ( v , writer ) ) ; workspace . getViews ( ) . getContainerViews ( ) . forEach ( v -> write ( v , writer ) ) ; workspace . getViews ( ) . getComponentViews ( ) . forEach ( v -> write ( v , writer ) ) ; workspace . getViews ( ) . getDynamicViews ( ) . forEach ( v -> write ( v , writer ) ) ; workspace . getViews ( ) . getDeploymentViews ( ) . forEach ( v -> write ( v , writer ) ) ; } | Writes the views in the given workspace as PlantUML definitions to the specified writer . | 233 | 18 |
28,539 | public void toStdOut ( Workspace workspace ) { if ( workspace == null ) { throw new IllegalArgumentException ( "A workspace must be provided." ) ; } StringWriter stringWriter = new StringWriter ( ) ; write ( workspace , stringWriter ) ; System . out . println ( stringWriter . toString ( ) ) ; } | Write the views in the given workspace as PlantUML definitions to stdout . | 71 | 16 |
28,540 | public void write ( View view , Writer writer ) { if ( view == null ) { throw new IllegalArgumentException ( "A view must be provided." ) ; } if ( writer == null ) { throw new IllegalArgumentException ( "A writer must be provided." ) ; } if ( SystemLandscapeView . class . isAssignableFrom ( view . getClass ( ) ) ) { write ( ( SystemLandscapeView ) view , writer ) ; } else if ( SystemContextView . class . isAssignableFrom ( view . getClass ( ) ) ) { write ( ( SystemContextView ) view , writer ) ; } else if ( ContainerView . class . isAssignableFrom ( view . getClass ( ) ) ) { write ( ( ContainerView ) view , writer ) ; } else if ( ComponentView . class . isAssignableFrom ( view . getClass ( ) ) ) { write ( ( ComponentView ) view , writer ) ; } else if ( DynamicView . class . isAssignableFrom ( view . getClass ( ) ) ) { write ( ( DynamicView ) view , writer ) ; } else if ( DeploymentView . class . isAssignableFrom ( view . getClass ( ) ) ) { write ( ( DeploymentView ) view , writer ) ; } } | Writes a single view as a PlantUML diagram definition to the specified writer . | 277 | 17 |
28,541 | public Component getComponentWithName ( String name ) { if ( name == null || name . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A component name must be provided." ) ; } Optional < Component > component = components . stream ( ) . filter ( c -> name . equals ( c . getName ( ) ) ) . findFirst ( ) ; return component . orElse ( null ) ; } | Gets the component with the specified name . | 92 | 9 |
28,542 | public Component getComponentOfType ( String type ) { if ( type == null || type . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A component type must be provided." ) ; } Optional < Component > component = components . stream ( ) . filter ( c -> type . equals ( c . getType ( ) . getType ( ) ) ) . findFirst ( ) ; return component . orElse ( null ) ; } | Gets the component of the specified type . | 97 | 9 |
28,543 | private void findUsesComponentAnnotations ( Component component , String typeName ) { try { Class type = getTypeRepository ( ) . loadClass ( typeName ) ; for ( Field field : type . getDeclaredFields ( ) ) { UsesComponent annotation = field . getAnnotation ( UsesComponent . class ) ; if ( annotation != null ) { String name = field . getType ( ) . getCanonicalName ( ) ; String description = field . getAnnotation ( UsesComponent . class ) . description ( ) ; String technology = annotation . technology ( ) ; Component destination = componentFinder . getContainer ( ) . getComponentOfType ( name ) ; if ( destination != null ) { for ( Relationship relationship : component . getRelationships ( ) ) { if ( relationship . getDestination ( ) == destination && StringUtils . isNullOrEmpty ( relationship . getDescription ( ) ) ) { // only change the details of relationships that have no description component . getModel ( ) . modifyRelationship ( relationship , description , technology ) ; } } } else { log . warn ( "A component of type \"" + name + "\" could not be found." ) ; } } } } catch ( ClassNotFoundException e ) { log . warn ( "Could not load type " + typeName ) ; } } | This will add a description to existing component dependencies where they have been annotated | 279 | 15 |
28,544 | public void setLocation ( Location location ) { if ( location != null ) { this . location = location ; } else { this . location = Location . Unspecified ; } } | Sets the location of this software system . | 36 | 9 |
28,545 | public CodeElement addSupportingType ( String type ) { CodeElement codeElement = new CodeElement ( type ) ; codeElement . setRole ( CodeElementRole . Supporting ) ; this . codeElements . add ( codeElement ) ; return codeElement ; } | Adds a supporting type to this Component . | 54 | 8 |
28,546 | public SystemLandscapeView createSystemLandscapeView ( String key , String description ) { assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; SystemLandscapeView view = new SystemLandscapeView ( model , key , description ) ; view . setViewSet ( this ) ; systemLandscapeViews . add ( view ) ; return view ; } | Creates a system landscape view . | 75 | 7 |
28,547 | public SystemContextView createSystemContextView ( SoftwareSystem softwareSystem , String key , String description ) { assertThatTheSoftwareSystemIsNotNull ( softwareSystem ) ; assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; SystemContextView view = new SystemContextView ( softwareSystem , key , description ) ; view . setViewSet ( this ) ; systemContextViews . add ( view ) ; return view ; } | Creates a system context view where the scope of the view is the specified software system . | 89 | 18 |
28,548 | public ContainerView createContainerView ( SoftwareSystem softwareSystem , String key , String description ) { assertThatTheSoftwareSystemIsNotNull ( softwareSystem ) ; assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; ContainerView view = new ContainerView ( softwareSystem , key , description ) ; view . setViewSet ( this ) ; containerViews . add ( view ) ; return view ; } | Creates a container view where the scope of the view is the specified software system . | 84 | 17 |
28,549 | public ComponentView createComponentView ( Container container , String key , String description ) { assertThatTheContainerIsNotNull ( container ) ; assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; ComponentView view = new ComponentView ( container , key , description ) ; view . setViewSet ( this ) ; componentViews . add ( view ) ; return view ; } | Creates a component view where the scope of the view is the specified container . | 79 | 16 |
28,550 | public DynamicView createDynamicView ( String key , String description ) { assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; DynamicView view = new DynamicView ( model , key , description ) ; view . setViewSet ( this ) ; dynamicViews . add ( view ) ; return view ; } | Creates a dynamic view . | 65 | 6 |
28,551 | public DeploymentView createDeploymentView ( String key , String description ) { assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; DeploymentView view = new DeploymentView ( model , key , description ) ; view . setViewSet ( this ) ; deploymentViews . add ( view ) ; return view ; } | Creates a deployment view . | 69 | 6 |
28,552 | public DeploymentView createDeploymentView ( SoftwareSystem softwareSystem , String key , String description ) { assertThatTheSoftwareSystemIsNotNull ( softwareSystem ) ; assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; DeploymentView view = new DeploymentView ( softwareSystem , key , description ) ; view . setViewSet ( this ) ; deploymentViews . add ( view ) ; return view ; } | Creates a deployment view where the scope of the view is the specified software system . | 88 | 17 |
28,553 | public FilteredView createFilteredView ( StaticView view , String key , String description , FilterMode mode , String ... tags ) { assertThatTheViewIsNotNull ( view ) ; assertThatTheViewKeyIsSpecifiedAndUnique ( key ) ; FilteredView filteredView = new FilteredView ( view , key , description , mode , tags ) ; filteredViews . add ( filteredView ) ; return filteredView ; } | Creates a FilteredView on top of an existing static view . | 90 | 14 |
28,554 | View getViewWithKey ( String key ) { if ( key == null ) { throw new IllegalArgumentException ( "A key must be specified." ) ; } Set < View > views = new HashSet <> ( ) ; views . addAll ( systemLandscapeViews ) ; views . addAll ( systemContextViews ) ; views . addAll ( containerViews ) ; views . addAll ( componentViews ) ; views . addAll ( dynamicViews ) ; views . addAll ( deploymentViews ) ; return views . stream ( ) . filter ( v -> key . equals ( v . getKey ( ) ) ) . findFirst ( ) . orElse ( null ) ; } | Finds the view with the specified key or null if the view does not exist . | 147 | 17 |
28,555 | FilteredView getFilteredViewWithKey ( String key ) { if ( key == null ) { throw new IllegalArgumentException ( "A key must be specified." ) ; } return filteredViews . stream ( ) . filter ( v -> key . equals ( v . getKey ( ) ) ) . findFirst ( ) . orElse ( null ) ; } | Finds the filtered view with the specified key or null if the view does not exist . | 76 | 18 |
28,556 | public String getTags ( ) { Set < String > setOfTags = getTagsAsSet ( ) ; if ( setOfTags . isEmpty ( ) ) { return "" ; } StringBuilder buf = new StringBuilder ( ) ; for ( String tag : setOfTags ) { buf . append ( tag ) ; buf . append ( "," ) ; } String tagsAsString = buf . toString ( ) ; return tagsAsString . substring ( 0 , tagsAsString . length ( ) - 1 ) ; } | Gets the comma separated list of tags . | 108 | 9 |
28,557 | public void addProperty ( String name , String value ) { if ( name == null || name . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A property name must be specified." ) ; } if ( value == null || value . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A property value must be specified." ) ; } properties . put ( name , value ) ; } | Adds a name - value pair property to this element . | 96 | 11 |
28,558 | public Perspective addPerspective ( String name , String description ) { if ( StringUtils . isNullOrEmpty ( name ) ) { throw new IllegalArgumentException ( "A name must be specified." ) ; } if ( StringUtils . isNullOrEmpty ( description ) ) { throw new IllegalArgumentException ( "A description must be specified." ) ; } if ( perspectives . stream ( ) . filter ( p -> p . getName ( ) . equals ( name ) ) . count ( ) > 0 ) { throw new IllegalArgumentException ( "A perspective named \"" + name + "\" already exists." ) ; } Perspective perspective = new Perspective ( name , description ) ; perspectives . add ( perspective ) ; return perspective ; } | Adds a perspective to this model item . | 156 | 8 |
28,559 | public ContainerInstance add ( Container container , boolean replicateContainerRelationships ) { ContainerInstance containerInstance = getModel ( ) . addContainerInstance ( this , container , replicateContainerRelationships ) ; this . containerInstances . add ( containerInstance ) ; return containerInstance ; } | Adds a container instance to this deployment node optionally replicating all of the container - container relationships . | 56 | 19 |
28,560 | public DeploymentNode getDeploymentNodeWithName ( String name ) { if ( name == null || name . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A name must be specified." ) ; } for ( DeploymentNode deploymentNode : getChildren ( ) ) { if ( deploymentNode . getName ( ) . equals ( name ) ) { return deploymentNode ; } } return null ; } | Gets the DeploymentNode with the specified name . | 91 | 11 |
28,561 | public void write ( Workspace workspace , Writer writer ) { if ( workspace != null && writer != null ) { for ( DynamicView view : workspace . getViews ( ) . getDynamicViews ( ) ) { write ( view , writer ) ; } } } | Writes the dynamic views in the given workspace as WebSequenceDiagrams definitions to the specified writer . | 55 | 22 |
28,562 | public void write ( Workspace workspace ) { StringWriter stringWriter = new StringWriter ( ) ; write ( workspace , stringWriter ) ; System . out . println ( stringWriter . toString ( ) ) ; } | Writes the dynamic views in the given workspace as WebSequenceDiagrams definitions to stdout . | 44 | 21 |
28,563 | public void setLogo ( String url ) { if ( url != null && url . trim ( ) . length ( ) > 0 ) { if ( Url . isUrl ( url ) || url . startsWith ( "data:image/" ) ) { this . logo = url . trim ( ) ; } else { throw new IllegalArgumentException ( url + " is not a valid URL." ) ; } } } | Sets the URL of an image representing a logo . | 87 | 11 |
28,564 | @ Nonnull public HttpHealthCheck addHealthCheck ( String name , String url , int interval , long timeout ) { if ( name == null || name . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "The name must not be null or empty." ) ; } if ( url == null || url . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "The URL must not be null or empty." ) ; } if ( ! Url . isUrl ( url ) ) { throw new IllegalArgumentException ( url + " is not a valid URL." ) ; } if ( interval < 0 ) { throw new IllegalArgumentException ( "The polling interval must be zero or a positive integer." ) ; } if ( timeout < 0 ) { throw new IllegalArgumentException ( "The timeout must be zero or a positive integer." ) ; } HttpHealthCheck healthCheck = new HttpHealthCheck ( name , url , interval , timeout ) ; healthChecks . add ( healthCheck ) ; return healthCheck ; } | Adds a new health check . | 229 | 6 |
28,565 | public static Workspace loadWorkspaceFromJson ( File file ) throws Exception { if ( file == null ) { throw new IllegalArgumentException ( "The path to a JSON file must be specified." ) ; } else if ( ! file . exists ( ) ) { throw new IllegalArgumentException ( "The specified JSON file does not exist." ) ; } return new JsonReader ( ) . read ( new FileReader ( file ) ) ; } | Loads a workspace from a JSON definition saved as a file . | 94 | 13 |
28,566 | public static void saveWorkspaceToJson ( Workspace workspace , File file ) throws Exception { if ( workspace == null ) { throw new IllegalArgumentException ( "A workspace must be provided." ) ; } else if ( file == null ) { throw new IllegalArgumentException ( "The path to a JSON file must be specified." ) ; } OutputStreamWriter writer = new OutputStreamWriter ( new FileOutputStream ( file ) , StandardCharsets . UTF_8 ) ; new JsonWriter ( true ) . write ( workspace , writer ) ; writer . flush ( ) ; writer . close ( ) ; } | Saves a workspace to a JSON definition as a file . | 129 | 12 |
28,567 | public static void printWorkspaceAsJson ( Workspace workspace ) { if ( workspace == null ) { throw new IllegalArgumentException ( "A workspace must be provided." ) ; } try { System . out . println ( toJson ( workspace , true ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Prints a workspace as JSON to stdout - useful for debugging purposes . | 75 | 15 |
28,568 | public static String toJson ( Workspace workspace , boolean indentOutput ) throws Exception { if ( workspace == null ) { throw new IllegalArgumentException ( "A workspace must be provided." ) ; } JsonWriter jsonWriter = new JsonWriter ( indentOutput ) ; StringWriter stringWriter = new StringWriter ( ) ; jsonWriter . write ( workspace , stringWriter ) ; stringWriter . flush ( ) ; stringWriter . close ( ) ; return stringWriter . toString ( ) ; } | Serializes the specified workspace to a JSON string . | 103 | 10 |
28,569 | public static Workspace fromJson ( String json ) throws Exception { if ( json == null || json . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A JSON string must be provided." ) ; } StringReader stringReader = new StringReader ( json ) ; return new JsonReader ( ) . read ( stringReader ) ; } | Converts the specified JSON string to a Workspace instance . | 78 | 12 |
28,570 | public Set < Component > findComponents ( ) throws Exception { Set < Component > componentsFound = new HashSet <> ( ) ; for ( ComponentFinderStrategy componentFinderStrategy : componentFinderStrategies ) { componentFinderStrategy . beforeFindComponents ( ) ; } for ( ComponentFinderStrategy componentFinderStrategy : componentFinderStrategies ) { componentsFound . addAll ( componentFinderStrategy . findComponents ( ) ) ; } for ( ComponentFinderStrategy componentFinderStrategy : componentFinderStrategies ) { componentFinderStrategy . afterFindComponents ( ) ; } return componentsFound ; } | Find components using all of the configured component finder strategies in the order they were added . | 144 | 18 |
28,571 | public void exclude ( String ... regexes ) { if ( regexes != null ) { for ( String regex : regexes ) { this . exclusions . add ( Pattern . compile ( regex ) ) ; } } } | Adds one or more regexes to the set of regexes that define which types should be excluded during the component finding process . | 45 | 25 |
28,572 | public TypeRepository getTypeRepository ( ) { if ( typeRepository == null ) { typeRepository = new DefaultTypeRepository ( getPackageNames ( ) , getExclusions ( ) , getUrlClassLoader ( ) ) ; } return typeRepository ; } | Gets the type repository used to analyse java classes . | 57 | 11 |
28,573 | public void setAutomaticLayout ( boolean enable ) { if ( enable ) { this . setAutomaticLayout ( AutomaticLayout . RankDirection . TopBottom , 300 , 600 , 200 , false ) ; } else { this . automaticLayout = null ; } } | Enables the automatic layout for this view with some default settings . | 54 | 13 |
28,574 | public void setAutomaticLayout ( AutomaticLayout . RankDirection rankDirection , int rankSeparation , int nodeSeparation , int edgeSeparation , boolean vertices ) { this . automaticLayout = new AutomaticLayout ( rankDirection , rankSeparation , nodeSeparation , edgeSeparation , vertices ) ; } | Enables the automatic layout for this view with the specified settings . | 67 | 13 |
28,575 | public void remove ( Relationship relationship ) { if ( relationship != null ) { RelationshipView relationshipView = new RelationshipView ( relationship ) ; relationshipViews . remove ( relationshipView ) ; } } | Removes a relationship from this view . | 39 | 8 |
28,576 | public void removeRelationshipsNotConnectedToElement ( Element element ) { if ( element != null ) { getRelationships ( ) . stream ( ) . map ( RelationshipView :: getRelationship ) . filter ( r -> ! r . getSource ( ) . equals ( element ) && ! r . getDestination ( ) . equals ( element ) ) . forEach ( this :: remove ) ; } } | Removes relationships that are not connected to the specified element . | 84 | 12 |
28,577 | public void removeElementsWithNoRelationships ( ) { Set < RelationshipView > relationships = getRelationships ( ) ; Set < String > elementIds = new HashSet <> ( ) ; relationships . forEach ( rv -> elementIds . add ( rv . getRelationship ( ) . getSourceId ( ) ) ) ; relationships . forEach ( rv -> elementIds . add ( rv . getRelationship ( ) . getDestinationId ( ) ) ) ; for ( ElementView elementView : getElements ( ) ) { if ( ! elementIds . contains ( elementView . getId ( ) ) ) { removeElement ( elementView . getElement ( ) ) ; } } } | Removes all elements that have no relationships to other elements in this view . | 151 | 15 |
28,578 | public DeploymentNode getDeploymentNodeWithName ( String name , String environment ) { for ( DeploymentNode deploymentNode : getDeploymentNodes ( ) ) { if ( deploymentNode . getEnvironment ( ) . equals ( environment ) && deploymentNode . getName ( ) . equals ( name ) ) { return deploymentNode ; } } return null ; } | Gets the deployment node with the specified name and environment . | 74 | 12 |
28,579 | public Element getElementWithCanonicalName ( String canonicalName ) { if ( canonicalName == null || canonicalName . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "A canonical name must be specified." ) ; } // canonical names start with a leading slash, so add this if it's missing if ( ! canonicalName . startsWith ( "/" ) ) { canonicalName = "/" + canonicalName ; } for ( Element element : getElements ( ) ) { if ( element . getCanonicalName ( ) . equals ( canonicalName ) ) { return element ; } } return null ; } | Gets the element with the specified canonical name . | 134 | 10 |
28,580 | public void modifyRelationship ( Relationship relationship , String description , String technology ) { if ( relationship == null ) { throw new IllegalArgumentException ( "A relationship must be specified." ) ; } Relationship newRelationship = new Relationship ( relationship . getSource ( ) , relationship . getDestination ( ) , description , technology , relationship . getInteractionStyle ( ) ) ; if ( ! relationship . getSource ( ) . has ( newRelationship ) ) { relationship . setDescription ( description ) ; relationship . setTechnology ( technology ) ; } else { throw new IllegalArgumentException ( "This relationship exists already: " + newRelationship ) ; } } | Provides a way for the description and technology to be modified on an existing relationship . | 136 | 17 |
28,581 | public void setUrl ( String url ) { if ( url != null && url . trim ( ) . length ( ) > 0 ) { if ( Url . isUrl ( url ) ) { this . url = url ; } else { throw new IllegalArgumentException ( url + " is not a valid URL." ) ; } } } | Sets the URL where more information about this element can be found . | 70 | 14 |
28,582 | public Section addSection ( String title , File ... files ) throws IOException { return add ( null , title , files ) ; } | Adds a custom section from one or more files that isn t related to any element in the model . | 27 | 20 |
28,583 | @ Nonnull public Section addSection ( String title , Format format , String content ) { return add ( null , title , format , content ) ; } | Adds a custom section that isn t related to any element in the model . | 31 | 15 |
28,584 | public Image addImage ( File file ) throws IOException { String contentType = ImageUtils . getContentType ( file ) ; String base64Content = ImageUtils . getImageAsBase64 ( file ) ; Image image = new Image ( file . getName ( ) , contentType , base64Content ) ; documentation . addImage ( image ) ; return image ; } | Adds an image from the given file to the workspace . | 78 | 11 |
28,585 | public void addUser ( String username , Role role ) { if ( StringUtils . isNullOrEmpty ( username ) ) { throw new IllegalArgumentException ( "A username must be specified." ) ; } if ( role == null ) { throw new IllegalArgumentException ( "A role must be specified." ) ; } users . add ( new User ( username , role ) ) ; } | Adds a user with the specified username and role . | 82 | 10 |
28,586 | public void add ( Container container , boolean addRelationships ) { if ( container != null && ! container . equals ( getContainer ( ) ) ) { addElement ( container , addRelationships ) ; } } | Adds an individual container to this view . | 43 | 8 |
28,587 | public void add ( Component component , boolean addRelationships ) { if ( component != null ) { if ( ! component . getContainer ( ) . equals ( getContainer ( ) ) ) { throw new IllegalArgumentException ( "Only components belonging to " + container . getName ( ) + " can be added to this view." ) ; } addElement ( component , addRelationships ) ; } } | Adds an individual component to this view . | 83 | 8 |
28,588 | public void removeElementsThatAreUnreachableFrom ( Element element ) { if ( element != null ) { Set < Element > elementsToShow = new HashSet <> ( ) ; Set < Element > elementsVisited = new HashSet <> ( ) ; findElementsToShow ( element , element , elementsToShow , elementsVisited ) ; for ( ElementView elementView : getElements ( ) ) { if ( ! elementsToShow . contains ( elementView . getElement ( ) ) && canBeRemoved ( elementView . getElement ( ) ) ) { removeElement ( elementView . getElement ( ) ) ; } } } } | Removes all elements that cannot be reached by traversing the graph of relationships starting with the specified element . | 136 | 21 |
28,589 | public void addAnimation ( Element ... elements ) { if ( elements == null || elements . length == 0 ) { throw new IllegalArgumentException ( "One or more elements must be specified." ) ; } Set < String > elementIdsInPreviousAnimationSteps = new HashSet <> ( ) ; Set < Element > elementsInThisAnimationStep = new HashSet <> ( ) ; Set < Relationship > relationshipsInThisAnimationStep = new HashSet <> ( ) ; for ( Element element : elements ) { if ( isElementInView ( element ) ) { elementIdsInPreviousAnimationSteps . add ( element . getId ( ) ) ; elementsInThisAnimationStep . add ( element ) ; } } if ( elementsInThisAnimationStep . size ( ) == 0 ) { throw new IllegalArgumentException ( "None of the specified elements exist in this view." ) ; } for ( Animation animationStep : animations ) { elementIdsInPreviousAnimationSteps . addAll ( animationStep . getElements ( ) ) ; } for ( RelationshipView relationshipView : this . getRelationships ( ) ) { if ( ( elementsInThisAnimationStep . contains ( relationshipView . getRelationship ( ) . getSource ( ) ) && elementIdsInPreviousAnimationSteps . contains ( relationshipView . getRelationship ( ) . getDestination ( ) . getId ( ) ) ) || ( elementIdsInPreviousAnimationSteps . contains ( relationshipView . getRelationship ( ) . getSource ( ) . getId ( ) ) && elementsInThisAnimationStep . contains ( relationshipView . getRelationship ( ) . getDestination ( ) ) ) ) { relationshipsInThisAnimationStep . add ( relationshipView . getRelationship ( ) ) ; } } animations . add ( new Animation ( animations . size ( ) + 1 , elementsInThisAnimationStep , relationshipsInThisAnimationStep ) ) ; } | Adds an animation step with the specified elements . | 401 | 9 |
28,590 | public void write ( Workspace workspace , Writer writer ) throws WorkspaceWriterException { if ( workspace == null ) { throw new IllegalArgumentException ( "Workspace cannot be null." ) ; } if ( writer == null ) { throw new IllegalArgumentException ( "Writer cannot be null." ) ; } try { ObjectMapper objectMapper = new ObjectMapper ( ) ; if ( indentOutput ) { objectMapper . enable ( SerializationFeature . INDENT_OUTPUT ) ; } objectMapper . setSerializationInclusion ( JsonInclude . Include . NON_NULL ) ; objectMapper . setSerializationInclusion ( JsonInclude . Include . NON_EMPTY ) ; objectMapper . disable ( SerializationFeature . WRITE_DATES_AS_TIMESTAMPS ) ; objectMapper . setDateFormat ( new ISO8601DateFormat ( ) ) ; writer . write ( objectMapper . writeValueAsString ( workspace ) ) ; } catch ( IOException ioe ) { throw new WorkspaceWriterException ( "Could not write as JSON" , ioe ) ; } } | Writes a workspace definition as a JSON string to the specified Writer object . | 239 | 15 |
28,591 | public List < Section > addSections ( SoftwareSystem softwareSystem , File directory ) throws IOException { if ( softwareSystem == null ) { throw new IllegalArgumentException ( "A software system must be specified." ) ; } return add ( softwareSystem , directory ) ; } | Adds all files in the specified directory each in its own section related to a software system . | 58 | 18 |
28,592 | public static TypeVisibility getVisibility ( TypeRepository typeRepository , String typeName ) { try { Class < ? > type = typeRepository . loadClass ( typeName ) ; int modifiers = type . getModifiers ( ) ; if ( Modifier . isPrivate ( modifiers ) ) { return TypeVisibility . PRIVATE ; } else if ( Modifier . isPublic ( modifiers ) ) { return TypeVisibility . PUBLIC ; } else if ( Modifier . isProtected ( modifiers ) ) { return TypeVisibility . PROTECTED ; } else { return TypeVisibility . PACKAGE ; } } catch ( ClassNotFoundException e ) { log . warn ( "Visibility for type " + typeName + " could not be found." ) ; return null ; } } | Finds the visibility of a given type . | 166 | 9 |
28,593 | public static TypeCategory getCategory ( TypeRepository typeRepository , String typeName ) { try { Class < ? > type = typeRepository . loadClass ( typeName ) ; if ( type . isInterface ( ) ) { return TypeCategory . INTERFACE ; } else if ( type . isEnum ( ) ) { return TypeCategory . ENUM ; } else { if ( Modifier . isAbstract ( type . getModifiers ( ) ) ) { return TypeCategory . ABSTRACT_CLASS ; } else { return TypeCategory . CLASS ; } } } catch ( ClassNotFoundException e ) { log . warn ( "Category for type " + typeName + " could not be found." ) ; return null ; } } | Finds the category of a given type . | 153 | 9 |
28,594 | public static Set < Class < ? > > findTypesAnnotatedWith ( Class < ? extends Annotation > annotation , Set < Class < ? > > types ) { if ( annotation == null ) { throw new IllegalArgumentException ( "An annotation type must be specified." ) ; } return types . stream ( ) . filter ( c -> c . isAnnotationPresent ( annotation ) ) . collect ( Collectors . toSet ( ) ) ; } | Finds the set of types that are annotated with the specified annotation . | 94 | 15 |
28,595 | public static Class findFirstImplementationOfInterface ( Class interfaceType , Set < Class < ? > > types ) { if ( interfaceType == null ) { throw new IllegalArgumentException ( "An interface type must be provided." ) ; } else if ( ! interfaceType . isInterface ( ) ) { throw new IllegalArgumentException ( "The interface type must represent an interface." ) ; } if ( types == null ) { throw new IllegalArgumentException ( "The set of types to search through must be provided." ) ; } for ( Class < ? > type : types ) { boolean isInterface = type . isInterface ( ) ; boolean isAbstract = Modifier . isAbstract ( type . getModifiers ( ) ) ; boolean isAssignable = interfaceType . isAssignableFrom ( type ) ; if ( ! isInterface && ! isAbstract && isAssignable ) { return type ; } } return null ; } | Finds the first implementation of the given interface . | 195 | 10 |
28,596 | public void write ( Workspace workspace , Writer writer ) { workspace . getViews ( ) . getSystemContextViews ( ) . forEach ( v -> write ( v , null , writer ) ) ; workspace . getViews ( ) . getContainerViews ( ) . forEach ( v -> write ( v , v . getSoftwareSystem ( ) , writer ) ) ; workspace . getViews ( ) . getComponentViews ( ) . forEach ( v -> write ( v , v . getContainer ( ) , writer ) ) ; } | Writes the views in the given workspace as DOT notation to the specified Writer . | 115 | 16 |
28,597 | public void addHeader ( String name , String value ) { if ( name == null || name . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "The header name must not be null or empty." ) ; } if ( value == null ) { throw new IllegalArgumentException ( "The header value must not be null." ) ; } this . headers . put ( name , value ) ; } | Adds a HTTP header which will be sent with the HTTP request to the health check URL . | 90 | 18 |
28,598 | public static boolean isUrl ( String urlAsString ) { if ( urlAsString != null && urlAsString . trim ( ) . length ( ) > 0 ) { try { new URL ( urlAsString ) ; return true ; } catch ( MalformedURLException murle ) { return false ; } } return false ; } | Determines whether the supplied string is a valid URL . | 70 | 12 |
28,599 | public Set < Class < ? > > findReferencedTypes ( String typeName ) { Set < Class < ? > > referencedTypes = new HashSet <> ( ) ; // use the cached version if possible if ( referencedTypesCache . containsKey ( typeName ) ) { return referencedTypesCache . get ( typeName ) ; } try { CtClass cc = classPool . get ( typeName ) ; for ( Object referencedType : cc . getRefClasses ( ) ) { String referencedTypeName = ( String ) referencedType ; if ( ! isExcluded ( referencedTypeName ) ) { try { referencedTypes . add ( loadClass ( referencedTypeName ) ) ; } catch ( Throwable t ) { log . debug ( "Could not find " + referencedTypeName + " ... ignoring." ) ; } } } // remove the type itself referencedTypes . remove ( loadClass ( typeName ) ) ; } catch ( Exception e ) { log . debug ( "Error finding referenced types for " + typeName + " ... ignoring." ) ; // since there was an error, we can't find the set of referenced types from it, so... referencedTypesCache . put ( typeName , new HashSet <> ( ) ) ; } // cache for the next time referencedTypesCache . put ( typeName , referencedTypes ) ; return referencedTypes ; } | Finds the set of types referenced by the specified type . | 282 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.