Repository: rucio/rucio
Issue: Trying to set is_new on dataset crashes

Motivation
----------
Making the following client call:

`client.set_metadata(scope='cms', name=did, key='is_new', value=True)
`

results in a crash of the server:

```
Traceback (most recent call last):
   File "/usr/lib/python2.7/site-packages/rucio/web/rest/did.py", line 703, in POST
     issuer=ctx.env.get('issuer'), recursive=recursive, vo=ctx.env.get('vo'))
   File "/usr/lib/python2.7/site-packages/rucio/api/did.py", line 421, in set_metadata
     return did.set_metadata(scope=scope, name=name, key=key, value=value, recursive=recursive)
   File "/usr/lib/python2.7/site-packages/rucio/db/sqla/session.py", line 377, in new_funct
     result = function(*args, **kwargs)
   File "/usr/lib/python2.7/site-packages/rucio/core/did.py", line 1241, in set_metadata
     did_meta_plugins.set_metadata(scope=scope, name=name, key=key, value=value, recursive=recursive, session=session)
   File "/usr/lib/python2.7/site-packages/rucio/core/did_meta_plugins/__init__.py", line 103, in set_metadata
     meta_handler.set_metadata(scope, name, key, value, recursive, session=session)
   File "/usr/lib/python2.7/site-packages/rucio/db/sqla/session.py", line 393, in new_funct
     result = function(*args, **kwargs)
   File "/usr/lib/python2.7/site-packages/rucio/core/did_meta_plugins/json_meta.py", line 85, in set_metadata
     raise NotImplementedError

```

This seems to be a regression since this definitely worked before. It seems as if an exception is being thrown because we're not supporting JSON metadata even though this is not JSON metadata. 

The CLI command set-metadata fails with the same error

Modification
------------




Changed files:
lib/rucio/tests/test_meta_did.py, lib/rucio/core/did_meta_plugins/did_column_meta.py

diff --git a/lib/rucio/core/did_meta_plugins/did_column_meta.py b/lib/rucio/core/did_meta_plugins/did_column_meta.py
index 16fb35d05..60a729624 100644
--- a/lib/rucio/core/did_meta_plugins/did_column_meta.py
+++ b/lib/rucio/core/did_meta_plugins/did_column_meta.py
@@ -15,7 +15,7 @@
 #
 # Authors:
 # - Vincent Garonne <vgaronne@gmail.com>, 2013-2018
-# - Martin Barisits <martin.barisits@cern.ch>, 2013-2019
+# - Martin Barisits <martin.barisits@cern.ch>, 2013-2020
 # - Cedric Serfon <cedric.serfon@cern.ch>, 2013-2020
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2013
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2013-2019
@@ -81,6 +81,7 @@ HARDCODED_KEYS = [
     "is_archive",
     "constituent",
     "access_cnt",
+    "is_new",
 
     # Keys used while listing dids
     "created_before",
diff --git a/lib/rucio/tests/test_meta_did.py b/lib/rucio/tests/test_meta_did.py
index bd97a89a9..3d3e22589 100644
--- a/lib/rucio/tests/test_meta_did.py
+++ b/lib/rucio/tests/test_meta_did.py
@@ -1,4 +1,5 @@
-# Copyright 2012-2020 CERN for the benefit of the ATLAS collaboration.
+# -*- coding: utf-8 -*-
+# Copyright 2012-2020 CERN
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
 # - Vincent Garonne <vincent.garonne@cern.ch>, 2012-2014
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2013-2017
 # - Benedikt Ziemons <benedikt.ziemons@cern.ch>, 2020
+# - Martin Barisits <martin.barisits@cern.ch>, 2020
 
 import unittest
 
@@ -56,3 +58,15 @@ class TestMetaDIDClient(unittest.TestCase):
         meta = self.did_client.get_metadata(scope=tmp_scope, name=tmp_dataset)
         assert key in meta
         assert meta[key] == value
+
+    def test_set_is_new_meta(self):
+        """ META DID (CLIENTS):  Try to set is_new metadata"""
+        # Add a scope
+        tmp_scope = 'mock'
+
+        # Add a dataset
+        tmp_dataset = 'dsn_%s' % uuid()
+
+        self.did_client.add_dataset(scope=tmp_scope, name=tmp_dataset)
+
+        self.did_client.set_metadata(scope=tmp_scope, name=tmp_dataset, key='is_new', value=True)