Trigger Application Cleanup

Post Reply
User avatar
JimmyHartington
Advanced member
Posts: 453
Joined: Tue Mar 22, 2011 7:38 am

Trigger Application Cleanup

Post by JimmyHartington »

Is there a way to trigger the Application Cleanup in Switch in a flow?

In one of my flows I do some cleanup of files available in a Checkpoint.
This happens with an Inject Wildcard element. So the file is moved from the Checkpoint backing folder.
And this does not force an update in the web-client of the Checkpoint. This only happens if I run the Application Cleanup manually.

So if I do not run the cleanup my users end up seeing duplicates.
Image
r.zegwaard
Member
Posts: 102
Joined: Fri Jul 08, 2011 10:31 am
Location: The Netherlands

Re: Trigger Application Cleanup

Post by r.zegwaard »

Following...
User avatar
magnussandstrom
Advanced member
Posts: 510
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Trigger Application Cleanup

Post by magnussandstrom »

I guess you struggeling with a similar problem as Vitor?

viewtopic.php?t=5069
User avatar
JimmyHartington
Advanced member
Posts: 453
Joined: Tue Mar 22, 2011 7:38 am

Re: Trigger Application Cleanup

Post by JimmyHartington »

Some of it is the same in regards to seeing a "ghost" job in the Switch Portal.
But I can not use the replace job.
Because some files are removed from other flows where some processing has been done.
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Trigger Application Cleanup

Post by freddyp »

The conceptually correct way of removing a job from a checkpoint is to provide an outgoing connection e.g. called "Has been replaced", and to route the job to that output using the Switch REST API: https://www.enfocus.com/manuals/Develop ... b-RouteJob
User avatar
JimmyHartington
Advanced member
Posts: 453
Joined: Tue Mar 22, 2011 7:38 am

Re: Trigger Application Cleanup

Post by JimmyHartington »

So in my case where I right now find a file in a folder based on the filename, this would be the process?
  • Call the API to list jobs in a certain checkpoint.
  • In this list find the job by filename.
  • Get the ID.
  • Use the ID to route the job through the right connector.
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Trigger Application Cleanup

Post by freddyp »

I have never done this myself, but from looking at the documentation I would say It is the other way around: you start from the job. That should not be problem because you know the ID of the job. There is a call to list the properties of a job (Client module-Jobs-List). In the return value there is a field with the ID of the checkpoint where the job sits (if applicable) and all the IDs of the outgoing connections, well basically everything you need.

I have some code lying around how to encrypt the password for logging in to the Switch REST API so you do not have to figure that out:

Code: Select all

const crypto = require("crypto");

//make sure this is not prettified and spaces are added to the beginning of the lines!!!!
const switchPublicKey = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/ZW93qx1U6iGDwFWjYRpgS6/l
vFV/VGEM7wV14Gr4ZZxpZto3rpot3As4Cn0a++LwVh1oSidmiRWnHcKBDCmov8IL
fJ6SckFV41WZWibx8eSTCfn6zlrQ6QgJC2jdpLbWewxhox58zVXk5iK67GOKqbE/
HzSFJVdqIyjNX0/IpQIDAQAB
-----END PUBLIC KEY-----`;

  //encryption of the password to be included somewhere in your code
  let password = "probably comes from a property";
  const buffer = Buffer.from(password);
  const encryptObj = {key: switchPublicKey, padding: crypto.constants.RSA_PKCS1_PADDING};
  const encrypted = crypto.publicEncrypt(encryptObj, buffer);
  const b64 = encrypted.toString("base64");
  password = "!@$" + b64;
User avatar
JimmyHartington
Advanced member
Posts: 453
Joined: Tue Mar 22, 2011 7:38 am

Re: Trigger Application Cleanup

Post by JimmyHartington »

In my case it is a new job, which triggers the removal of another job in a checkpoint.
So I do not know the ID of the job at the checkpoint.
I also has 5 checkpoints where a job can reside at a given point in time.

But thanks for the code. I will try look into it when I have more time on hand.
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Trigger Application Cleanup

Post by freddyp »

Right, but if you do not specify an ID when listing jobs you get them all and you can loop over them and filter out the ones that are in a checkpoint, etc.
Post Reply