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 .