It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to load a resource and use it's content?

Hey all together,

1.: I want to include a .txt (which has only names inside) file to my plugin resources.
2.: Then I want to use the content of this file to fill a table in a .vm (velocity template).
3.: Also I need to get the content in an webworkAction.java file.

I tried it myself, but none of this works. I suppose it's because of an wrong path.
This is what I've done:

atlassian-plugin.xml:

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2"> 
<plugin-info>
...
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>

</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="VersionManager"/>
<!-- add our web resources -->
<web-resource key="VersionManager-resources" name="VersionManager Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="VersionManager.css" location="css/VersionManager.css"/>
<resource type="download" name="VersionManager.js" location="js/VersionManager.js"/>
<resource type="download" name="images/" location="/images"/>
<resource type="download" name="projects" location="projectsData/projects.txt"/>
<resource type="download" name="date-picker" location="com.atlassian.auiplugin:aui-date-picker"/>
<context>atl.general</context>
<context>VersionManager</context>
</web-resource>
...

 

pom.xml:

 <instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>de.inn.VersionManager.api,</Export-Package>
<!-- Add package import here -->
<Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", *</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>

 


.vm:

...
set (projectText = $projects)
...
<html>...<body>
<p id="projectsText"></p>
</body></html>
...
$action.loadProjects();

 

webworkAction.java:

...
public void loadProjects() {

InputStream test1 = com.atlassian.core.util.ClassLoaderUtils.getResourceAsStream("org.springframework.osgi:projects", this.getClass());
URL test2 = getClass().getResource("projects");

System.out.println(test1);
System.out.println(test2);
}
...

 

jira-question.jpg

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

308 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you