Add artifacts to an asset

To add or replace artifacts within an asset, first obtain the artifact root by calling RAMAsset.getArtifactsRoot() which will return a RAMFolderArtifact that represents the top container for all artifacts within the asset. RAMFolderArtifact, LocalFileArtifact, LocalFolderArtifact, LocalArchiveFolderArtifact and RAMURLArtifact can be added to the artifact root (or any other RAMFolder artifact) by using RAMFolderArtifact.addArtifact(Artifact) or RAMFolderArtifact.addArtifact(String path, Artifact).

                //Get the artifact root of the new asset
                RAMFolderArtifact root = (RAMFolderArtifact)newAsset.getArtifactsRoot();
                
                // Create an artifact from a single file
                File file = new File("D:\\mydocs\\readme.txt");
                LocalFileArtifact fileArtifact = new LocalFileArtifact(file);
                fileArtifact.setName("readme.txt");
                root.addArtifact(fileArtifact);

                // Create folder artifact to include all the files in the folder
                File folder = new File("D;\\mydocs\\lib");
                LocalFolderArtifact folderArtifact = new LocalFolderArtifact(folder);
                root.addArtifact(folderArtifact);

                // Create URL artifacts
                RAMURLArtifact ibmLink = new RAMURLArtifact("http://www.example.com");
                ibmLink.setName("IBM");
                root.addArtifact("links", ibmLink);
 
                session.put(newAsset, new NullProgressMonitor());

Feedback