기존 자산 페치

다음을 참조하십시오.

서버에서 자산을 검색하려면 먼저 com.ibm.ram.client.RAMAsset 오브젝트가 필요합니다. 이 오브젝트는 자산의 메타데이터를 나타냅니다. 이 오브젝트에서 getContents() 메소드를 사용하여 자산을 RAS 파일로 가져올 수 있습니다.

서버에서 자산을 페치하는 방법은 여러 가지입니다. 이를 직접 수행하려면 RAMSession.getAsset(AssetIdentification)을 사용하여 GUID 및 버전에 의해 자산을 검색하십시오. 와일드 카드 '*'를 사용하여 패턴과 일치하는 최신 버전을 페치할 수 있습니다(자산 버전화 참조).
                // Fetch an asset by GUID and version (this just pulls down the asset's metadata)
                RAMAsset asset = session.getAsset(new AssetIdentification("{AC0D54C1-E349-69EC-030F-E51CB557B0D7}", "7.1"));
일단 자산이 있으면 Getter 및 Setter를 통해 특성을 가져올/설정할 수 있습니다. 예를 들어, 다음과 같습니다.
                // Verify the asset's metadata
                assertEquals("RAM Client API Javadoc", asset.getName());
                assertEquals("Javadoc for the Rational Asset Manager Client API", asset.getDescription());
                assertEquals("Documentation", asset.getAssetType().getName());
                assertEquals("RAM Development", asset.getCommunity().getName());
                assertEquals("Kevin Jones", asset.getOwners()[0].getName());
자산을 RAS 파일로 다운로드하려면 getContents() 메소드를 사용하십시오.
                // Download the content as a .ras file
                ZipInputStream in = null;
                File file = null;
                FileOutputStream output = null;
                byte[] buffer = new byte[100000];
                try {
                        file = new File("D:\\temp\\newAsset.ras"); //$NON-NLS-1$
                        output = new FileOutputStream(file);
                        in = new ZipInputStream(asset.getContents());

                        int read;
                        int start = 0;
                        while ((read = in.read(buffer, start, buffer.length - start)) > -1) {
                                start += read;
                                if (start >= buffer.length) {
                                        output.write(buffer);
                                        start = 0;
                                }
                        }
                        if (start > 0)
                                output.write(buffer, 0, start);
                } finally {
                        try {
                                if (in != null)
                                        in.close();
                        } catch (IOException e) {
                        }
                        try {
                                if (output != null)
                                        output.close();
                        } catch (IOException e) {
                        }
                }

피드백