Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Upload some javascript on the project area with api java or rest

Hi everyone I'm back here, I've been around forums and internet in general for days but I'm not finding ideas for what I need.

In short we would like to load some javascript for some condition or setValue, in the projectArea, so not on the tickets as attachments. I hypothesized two ways, the first was to modify the process configuration source, I saw that there is the possibility of doing so but I'm having some difficulties and then I still haven't been able to understand where the js that should be modified are "physically" located . The other solution is to simulate an upload of the resource instead of another, as in the screen: https://ibb.co/9TMbXXf
As you can see from the highlighting, I would like to perform this uplaod from a certain path, but I have not found any ideas to be able to do it. Actually, this operation can only be done on the "client" side and not on the web so I doubt whether it can be done, but it seems impossible to me that it is not provided through any api, whether it is java or rest. Thanks a lot in advance to everyone and sorry for the many questions.

0 votes


Accepted answer

Permanent link

I always found on this forum, a user who created them completely from 0 and encountered problems, but taking advantage of what he had posted here:

I managed to understand that I was doing everything right but I was missing saving the IProcessAttachment for that one failed to see the "loaded" changes.
Thanks so much everyone.
Here is the source if it can be useful to someone else:
FileOutputStream file = om.saveJSSource(projectAreaParent, a, icm, ipA.getName(), monitor);
InputStream inputstream = new FileInputStream("Path"+ ipA.getName());
IContent contenuto = icm.storeContent("application/octet-stream", IContent.ENCODING_UTF_8, LineDelimiter.LINE_DELIMITER_NONE, 
                          inputstream, null, monitor); 
ipA = (IProcessAttachment) processItemService.getMutableCopy(ipA);
ipA.setContent(contenuto);
processItemService.save(ipA, monitor);
projectAreaParent.addAttachment(ipA);
processItemService.save(projectAreaParent, monitor);
    
As you can see I execute the outputStream only because to do the tests I made the modification manually.

Ralph Schoon selected this answer as the correct answer

0 votes


2 other answers

Permanent link

 The upload is stored in the database:



As far as i am aware the Plain Java Client Libraries provide access to the Content manager: ITeamRepository.contentManager(). You can use that to upload information you can also use it to access the process XML that you could theoretically manipulate. I am sure this is not a supported mode of operation.

0 votes

Comments

Yes I had read something about ITeamRepository.contentManager() and I had also read that it was not supported and that the modification is not always effective anyway, because it leads to further modifications often. I have to study what you are talking about well, but do you have any examples? I could not find much unfortunately. Anyway thanks, I will update the post if I find something.

Good evening Ralph sorry I'm late.
So I'll update you, I read the post after I answer.

As for the "download" of the files I found the solution. The problem, however, now I have it for loading it, if I look for a method to load something I understand that you have to use the "storeContent" method, only this has various signatures, some of which are "deprecated" and others not deprecated there is not a shred of description on what it wants, for example there is one that wants String, String and more, the others have come to replace them, but the two strings I have no idea what they can represent, I don't know if you have any ideas or other .... I still continue to try to understand to find a solution. 


Permanent link
I have found a solution.
The method that does what we need is in the IProjectArea class and is called getAttachments ()
Practically this method returns everything that is present on the DB as an attachment then the js the gif and so on. Then, of course, by returning a list you can "manage" as you wish, in fact, by only serving those with the .js extension, I did the following management:

[code]
IProcessAttachmentHandle[] listJs = projectAreaParent.getAttachments();

for (IProcessAttachmentHandle ipAh : listJs) {
  IProcessAttachment ipA = (IProcessAttachment)teamRepository.itemManager().fetchCompleteItem(ipAh, IItemManager.DEFAULT, null);
  if(ipA.getName().contains(".js")){
[/code]
Then of course it is only an example to give the idea, but for those who run into the same "problem" it can be useful.
Now the problem I have, however, in the upload of the same modified file, at the moment I am modifying it by hand, but then it will be modified on the code side with everything necessary, but I cannot show the attachment changes that I set :( I am going crazy....
I will update you if I find a solution to this too, in the meantime thanks to everyone.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,927
× 478
× 411

Question asked: Aug 24 '21, 5:41 a.m.

Question was seen: 1,936 times

Last updated: Aug 26 '21, 1:44 p.m.

Confirmation Cancel Confirm