Teneo Developers

Resource file manager

The resource file manager allows you to add files to your solution. These files can then be programmatically accessed and used by your solution.

Please note that there are no limitations to what you can add, meaning that, as the developer, you are responsible for any detrimental impact the added resource files could potentially have on the published application. Please refer to the best practices section below. Remember that it's also important to consider your solution size, as adding large files will increase the size of the solution which can in turn have an impact on deployment. Publishing should be tested thoroughly, to ensure reliable deployment, after substantial resources have been added.

Adding files

To add files, navigate to 'File Resources' from the solution dashboard. While in File Resources, click on the plus icon to create a new file resource. Drag and drop the relevant file to your solution and click 'Save'. If you want to be able to access the file programmatically in your solution, make sure you change the published location path to /script_lib before you save it. After you have updated the published location, give the file a name and click on 'Save'.

Only files added to /script_lib can be programmatically accessed by your solution. For an example, see How to add and use files.

Files that are stored in the root path '/' are accessible publicly for anyone who knows the engine URL. Be careful when placing files there, especially if they contain sensitive data.

Files in a solution are not shared by other solutions; they only exist in the solution they were added to. When the solution is published, it includes all the uploaded files.

File properties

You can see the properties of a file in the resource file manager. On the table you will see the details like the size, the name, and whom it was last modified by.

Editing a file's name or folder

To edit the file's name or its folder, choose the file from the list and the field will now become editable. After you modify it, make sure you hit save.

file-resource-sw-n

Removing files

To delete one or more files, select the bin icon to the right of the file name. This becomes visible when you hover over the file. You will get a prompt asking you if you really want to delete the file(s).

File types that get special treatment

You can add any file to a solution, but some of them are treated specially.

Images

Images like .png, .jpg, and .gif are stored in the /images folder by default. Once the solution is published, the images can be retrieved by appending /images/[imagename].[extension] to the engine URL.

.groovy files

You can add groovy classes by storing the class as a .groovy file with the name of the class. When added to Teneo, the files' path should be set to /script_lib. Once saved, you can call the class from anywhere in the solution. (You don't have to compile the class; it will be compiled when the solution is loaded into memory).

.jar files

If the scripts in your solution need to use classes that are made available in .jar files, you can add these to the resource file manager as well. Once saved, their classes can be used anywhere in the solution. Jar files are stored in the /script_lib folder by default.

.jsp files

Java Server Pages are stored in the /views folder by default. These files can be used to format the Teneo engine response. They can be used by using the url parameter viewtype with the name of your jsp without the extension in requests to engine, like so:

https://some.engine/instance/?viewtype=myjspname&userinput=hello

Java Server Pages can make use of the Teneo engine scripting API. More details here: API's for use in JSP's.

Java libraries

Currently, runtime solutions automatically get access to the Groovy and base Java libraries, together with Jackson and SnakeYAML which can be used in scripting.

Best practices

This is a list of best practices when working with Resource files:

  • Do not include any of the libraries exposed to scripts to a solution.
  • Especially do not add a Java library dependency that includes Groovy.
  • Check if the included Java and Groovy libraries can fulfill your requirements.
  • If you really, really need them, we would recommend building your script as static Java classes in your own JAR library, and use the maven shade plugin to relocate them during building to avoid any potential issues.
  • Overall, you should really analyze what you need when adding JAR resources.