Fetch an existing asset

To retrieve an asset from the server, you first need a com.ibm.ram.client.RAMAsset object. This object represents the metadata of an asset. From this object you can use the getContents() method to get the asset as a RAS file.

There are several ways to fetch an asset from the server. To get to it directly use RAMSession.getAsset(AssetIdentification) to retrieve the asset by GUID and version. You can use the wild card '*' to fetch the latest version matching a pattern (see Versioning an asset).
                // 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"));
Once you have an asset you can get/set properties through the getters and setters. For example:
                // 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());
To download the asset as a RAS file, use the getContents() method:
                // 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) {
                        }
                }

Feedback