Plugin development - Is it possible to prevent an Instance to be recorded

Dears,

Is it possible to ignore or prevent storing instances in “OrthancPluginRegisterOnStoredInstanceCallback” or “OrthancPluginRegisterOnChangeCallback” ?
I tried to return a random error code (OrthancPluginErrorCode_InternalError) , I can see an error pop-up in logs but it didnt prevent it to save the instances.

Received on [20190603T102008]
I0603 15:17:41.067457 main.cpp:215] Incoming Store request from AET MARCO on IP 192.168.0.82, calling AET MEDDATBANK
I0603 15:17:41.090073 FilesystemStorage.cpp:118] Creating attachment “ff71e36b-ebc4-4435-b26c-16465f3f4862” of “DICOM” type (size: 1MB)
I0603 15:17:41.091031 FilesystemStorage.cpp:118] Creating attachment “9af413db-d060-4d94-90f5-a2a026bcdd64” of “JSON summary of DICOM” type (size: 1MB)
I0603 15:17:41.153017 ServerContext.cpp:417] New instance stored
E0603 15:17:41.156720 ServerContext.cpp:105] Error in the plugin callback while signaling a change: Internal error (code -1)

Thanks.

Hi, Hadi!

For that you’ll want to implement a custom ReceivedInstanceFilter. The API’s you mentioned are called AFTER the instance has been stored.

For more information please refer to:

https://book.orthanc-server.com/users/lua.html#filtering-incoming-dicom-instances

Or hit reply.

HTH,
Luiz

Thank you Luiz :slight_smile:

Hi, Hadi!

There you go!

To build this particular image and see it in action:

$ cd
$ docker build --build-arg USER=$(whoami) --build-arg UID=$UID -t : .
$ docker run --rm -it :

You’ll notice the image kicks off with the user that built the image, instead of root. Also, you’ll want to download Java 12 to build particualr image because it depends on it. Nothing related to Orthanc, it’s because of the project I’ve been working on.

Notice that “gosu” is used before most commands. It’s this program that switches the UID’s. Side-note-worth-mentioning: since the ENTRYPOINT is a bash script that runs another program, it is imperative that it ends with the “exec” instruction; otherwise shutting down running containers with SIGTERM will not function.

Should you need any help, feel free to reach out.

@Alain Mazy feel free to use these images as you see fit on a contribution basis! =)

HTH

configure-docker-user.sh (343 Bytes)

Dockerfile (1.65 KB)

docker-run.sh (89 Bytes)

I’m sorry , I just realised I replied the wrong thread. 1000 appologies!