Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening a .aasx file generated by this library creates a .aasx.cpgz file on MacOS #271

Closed
eamon0989 opened this issue Mar 19, 2024 · 1 comment

Comments

@eamon0989
Copy link

I've been trying to create a .aasx file using this library, and attach a json file as a submodel. When I save the output of this code to a test.aasx file and try to unzip it using Archive Utility, instead of creating a test folder, it instead creates a test.aasx.cpgz which cannot be opened.

When trying to open an example .aasx file from the samples provided here using Archive Utility, it opens as expected and allows me to view the contents.

When trying to open the test.aasx file in Package explorer, it fails with the following error:

Inner message: While opening aasx C:\Users\HannesStiebitzhofer\AppData\Local\Temp\tmp7B2A.aasx from source local file: C:\Users\HannesStiebitzhofer\Dropbox\AASX\aas4.aasx buffered to: C:\Users\HannesStiebitzhofer\AppData\Local\Temp\tmp7B2A.aasx at \AdminShellPackageEnv.cs:line 456 gave: While reading the AASX C:\Users\HannesStiebitzhofer\AppData\Local\Temp\tmp7B2A.aasx at \AdminShellPackageEnv.cs:line 393 gave: Unable to find AASX origin. Aborting!

The aasx/aasx-origin file is where it should be, and contains the text: Intentionally empty..

I also tried running the tests in AASXSerializer and wrote the file that was generated and ran into the same issue.

Here is my code:

        JsonDeserializer jsonDeserializer = new JsonDeserializer();
        Submodel submodel = jsonDeserializer.read(json, Submodel.class);

        AssetAdministrationShell assetAdministrationShell = new DefaultAssetAdministrationShell.Builder()
                .build();

        var env = new DefaultEnvironment.Builder()
                .assetAdministrationShells(assetAdministrationShell)
                .submodels(submodel)
                .build();

        List<InMemoryFile> fileList = new ArrayList<>();

        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        new AASXSerializer().write(env, fileList, outStream);

        var bytes = outStream.toByteArray();
        Files.write(Path.of("./test2.aasx"), bytes);

I have tried this both with and without attaching the json as a submodel.

I am attaching the output .aasx in case it can help with debugging. I renamed the extension to .zip as github would not accept a .aasx file. I would appreciate any pointers if I am doing anything wrong. I am new to Java so my code may not be the best. Thanks!
test2.zip

@FrankSchnicke
Copy link
Contributor

When I save the output of this code to a test.aasx file and try to unzip it using Archive Utility, instead of creating a test folder, it instead creates a test.aasx.cpgz which cannot be opened.

This is most likely a quirk of the tool that you are using. Maybe the AASX Package Explorer provides some meta data that AAS4J is not providing. With other tools, e.g., 7zip, everything is behaving as expected.

When trying to open the test.aasx file in Package explorer, it fails with the following error:

This is a bug in the AASX Package Explorer that was fixed but got reintroduced in the latest release. You can use the version provided here in the meantime:
https://github.com/admin-shell-io/aasx-package-explorer/releases/tag/v2024-02-27.alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants