2626import org .apache .taverna .robundle .manifest .Agent ;
2727import org .apache .taverna .robundle .manifest .Manifest ;
2828import org .apache .taverna .robundle .manifest .PathMetadata ;
29+ import org .apache .taverna .robundle .manifest .Proxy ;
2930import org .commonwl .viewer .services .GitHubService ;
3031import org .eclipse .egit .github .core .RepositoryContents ;
3132import org .slf4j .Logger ;
4950public class ROBundle {
5051
5152 private final Logger logger = LoggerFactory .getLogger (this .getClass ());
52-
5353 private GitHubService githubService ;
5454
5555 private Bundle bundle ;
@@ -139,36 +139,44 @@ private void addFiles(List<RepositoryContents> repoContents, Path path) throws I
139139 } else if (repoContent .getType ().equals ("file" )) {
140140
141141 try {
142- // Where to store the new file in bundle
143- Path bundleFilePath = path .resolve (repoContent .getName ());
144-
145142 // Raw URI of the bundle
146143 GithubDetails githubFile = new GithubDetails (githubInfo .getOwner (),
147144 githubInfo .getRepoName (), githubInfo .getBranch (), repoContent .getPath ());
148145 URI rawURI = new URI ("https://raw.githubusercontent.com/" + githubFile .getOwner () + "/" +
149146 githubFile .getRepoName () + "/" + commitSha + "/" + githubFile .getPath ());
150147
151- // Variable to store file contents
148+ // Variable to store file contents and aggregation
152149 String fileContent = null ;
150+ PathMetadata aggregation ;
153151
154152 // Download or externally link if oversized
155153 if (repoContent .getSize () <= singleFileSizeLimit ) {
156154 // Get the content of this file from Github
157155 fileContent = githubService .downloadFile (githubFile , commitSha );
158156
159157 // Save file to research object bundle
158+ Path bundleFilePath = path .resolve (repoContent .getName ());
160159 Bundles .setStringValue (bundleFilePath , fileContent );
160+
161+ // Set retrieved information for this file in the manifest
162+ aggregation = bundle .getManifest ().getAggregation (bundleFilePath );
163+ aggregation .setRetrievedFrom (rawURI );
164+ aggregation .setRetrievedBy (thisApp );
165+ aggregation .setRetrievedOn (aggregation .getCreatedOn ());
161166 } else {
162- logger .info ("File " + repoContent .getName () + " is too large to download -" +
167+ logger .info ("File " + repoContent .getName () + " is too large to download - " +
163168 FileUtils .byteCountToDisplaySize (repoContent .getSize ()) + "/" +
164169 FileUtils .byteCountToDisplaySize (singleFileSizeLimit ) +
165- " + linking externally to RO bundle" );
166- bundleFilePath = Bundles .setReference (bundleFilePath , rawURI );
170+ ", linking externally to RO bundle" );
171+
172+ // Set information for this file in the manifest
173+ aggregation = bundle .getManifest ().getAggregation (rawURI );
174+ Proxy bundledAs = new Proxy ();
175+ bundledAs .setURI ();
176+ bundledAs .setFolder (path );
177+ aggregation .setBundledAs (bundledAs );
167178 }
168179
169- // Manifest aggregation
170- PathMetadata aggregation = bundle .getManifest ().getAggregation (bundleFilePath );
171-
172180 // Special handling for cwl files
173181 if (FilenameUtils .getExtension (repoContent .getName ()).equals ("cwl" )) {
174182 // Correct mime type (no official standard for yaml)
@@ -188,11 +196,6 @@ private void addFiles(List<RepositoryContents> repoContents, Path path) throws I
188196 authors .addAll (fileAuthors );
189197 aggregation .setAuthoredBy (new ArrayList <Agent >(fileAuthors ));
190198
191- // Set retrieved information for this file in the manifest
192- aggregation .setRetrievedFrom (rawURI );
193- aggregation .setRetrievedBy (thisApp );
194- aggregation .setRetrievedOn (aggregation .getCreatedOn ());
195-
196199 } catch (URISyntaxException ex ) {
197200 logger .error ("Error creating URI for RO Bundle" , ex );
198201 }
0 commit comments