From 0f968e64546acaf1983fbde894fd3fa8725d6674 Mon Sep 17 00:00:00 2001
From: Michael Davis <michael.davis@cern.ch>
Date: Thu, 28 Nov 2019 16:31:20 +0100
Subject: [PATCH] [frontend] Renames CTA_* xattrs to sys.* xattrs

Renames CTA_ArchiveFileID to sys.archive.file_id
Renames CTA_StorageClass to sys.archive.storage.class
---
 cmdline/EosCtaStub.cpp                        |  4 +--
 .../ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh |  2 +-
 .../cc7/opt/run/bin/eos_configure_preprod.sh  |  2 +-
 xroot_plugins/XrdSsiCtaRequestMessage.cpp     | 30 +++++++++----------
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/cmdline/EosCtaStub.cpp b/cmdline/EosCtaStub.cpp
index 19b7909111..253286d56c 100644
--- a/cmdline/EosCtaStub.cpp
+++ b/cmdline/EosCtaStub.cpp
@@ -239,11 +239,11 @@ void fillNotification(cta::eos::Notification &notification, int argc, const char
       }
       else if(argstr == "--diskfilepath")        notification.mutable_file()->set_lpath(argval);
       else if(argstr == "--storageclass")        {
-         google::protobuf::MapPair<std::string,std::string> sc("CTA_StorageClass", argval);
+         google::protobuf::MapPair<std::string,std::string> sc("sys.archive.storage_class", argval);
          notification.mutable_file()->mutable_xattr()->insert(sc);
       }
       else if(argstr == "--id")                  {
-         google::protobuf::MapPair<std::string,std::string> id("CTA_ArchiveFileId", argval);
+         google::protobuf::MapPair<std::string,std::string> id("sys.archive.file_id", argval);
          notification.mutable_file()->mutable_xattr()->insert(id);
       }
       else throw std::runtime_error("Unrecognised key " + argstr);
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
index 789c31cde9..e5f251d6fe 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
@@ -264,7 +264,7 @@ fi
   eos mkdir ${CTA_TEST_DIR}
   eos chmod 555 ${CTA_TEST_DIR}
   eos attr set sys.acl=g:eosusers:rwx!d,u:poweruser1:rwx+dp,u:poweruser2:rwx+dp /eos/ctaeos/cta
-  eos attr set CTA_StorageClass=ctaStorageClass ${CTA_TEST_DIR}
+  eos attr set sys.archive.storage_class=ctaStorageClass ${CTA_TEST_DIR}
     
   # Link the attributes of CTA worklow directory to the test directory
   eos attr link ${CTA_WF_DIR} ${CTA_TEST_DIR}
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/eos_configure_preprod.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/eos_configure_preprod.sh
index d784ef2981..1727bcf4e0 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/eos_configure_preprod.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/eos_configure_preprod.sh
@@ -5,7 +5,7 @@ eos mkdir ${PREPROD_DIR}
 eos chmod 555 ${PREPROD_DIR}
 eos attr set sys.acl=g:eosusers:rwx!d,u:poweruser1:rwx+dp,u:poweruser2:rwx+dp ${PREPROD_DIR}
 
-eos attr set CTA_StorageClass=ctaStorageClass ${PREPROD_DIR}
+eos attr set sys.archive.storage_class=ctaStorageClass ${PREPROD_DIR}
 
 eos attr set sys.workflow.sync::create.default="proto" ${PREPROD_DIR}
 eos attr set sys.workflow.sync::closew.default="proto" ${PREPROD_DIR}
diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp
index a6627fe0bb..bc300a336f 100644
--- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp
+++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp
@@ -331,13 +331,13 @@ void RequestMessage::processCREATE(const cta::eos::Notification &notification, c
    requester.name  = notification.cli().user().username();
    requester.group = notification.cli().user().groupname();
 
-   const auto storageClassItor = notification.file().xattr().find("CTA_StorageClass");
+   const auto storageClassItor = notification.file().xattr().find("sys.archive_storage_class");
    if(notification.file().xattr().end() == storageClassItor) {
-     throw PbException(std::string(__FUNCTION__) + ": CTA_StorageClass extended attribute is not set");
+     throw PbException(std::string(__FUNCTION__) + ": sys.archive_storage_class extended attribute is not set");
    }
    const std::string storageClass = storageClassItor->second;
    if(storageClass.empty()) {
-     throw PbException(std::string(__FUNCTION__) + ": CTA_StorageClass extended attribute is set to an empty string");
+     throw PbException(std::string(__FUNCTION__) + ": sys.archive_storage_class extended attribute is set to an empty string");
    }
 
    cta::utils::Timer t;
@@ -353,10 +353,10 @@ void RequestMessage::processCREATE(const cta::eos::Notification &notification, c
    m_lc.log(cta::log::INFO, "In RequestMessage::processCREATE(): assigning new archive file ID.");
 
    // Set ArchiveFileId in xattrs
-   response.mutable_xattr()->insert(google::protobuf::MapPair<std::string,std::string>("CTA_ArchiveFileId", std::to_string(archiveFileId)));
+   response.mutable_xattr()->insert(google::protobuf::MapPair<std::string,std::string>("sys.archive.file_id", std::to_string(archiveFileId)));
    
    // Set the storage class in xattrs
-   response.mutable_xattr()->insert(google::protobuf::MapPair<std::string,std::string>("CTA_StorageClass", storageClass));
+   response.mutable_xattr()->insert(google::protobuf::MapPair<std::string,std::string>("sys.archive_storage_class", storageClass));
 
    // Set response type
    response.set_type(cta::xrd::Response::RSP_SUCCESS);
@@ -374,9 +374,9 @@ void RequestMessage::processCLOSEW(const cta::eos::Notification &notification, c
    checkIsNotEmptyString(notification.transport().report_url(),   "notification.transport.report_url");
 
    // Unpack message
-   const auto storageClassItor = notification.file().xattr().find("CTA_StorageClass");
+   const auto storageClassItor = notification.file().xattr().find("sys.archive_storage_class");
    if(notification.file().xattr().end() == storageClassItor) {
-     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named CTA_StorageClass");
+     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named sys.archive_storage_class");
    }
 
    cta::common::dataStructures::ArchiveRequest request;
@@ -399,9 +399,9 @@ void RequestMessage::processCLOSEW(const cta::eos::Notification &notification, c
    // CTA Archive ID is an EOS extended attribute, i.e. it is stored as a string, which
    // must be converted to a valid uint64_t
 
-   const auto archiveFileIdItor = notification.file().xattr().find("CTA_ArchiveFileId");
+   const auto archiveFileIdItor = notification.file().xattr().find("sys.archive.file_id");
    if(notification.file().xattr().end() == archiveFileIdItor) {
-     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named CTA_ArchiveFileId");
+     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named sys.archive.file_id");
    }
    const std::string archiveFileIdStr = archiveFileIdItor->second;
    uint64_t archiveFileId = 0;
@@ -449,9 +449,9 @@ void RequestMessage::processPREPARE(const cta::eos::Notification &notification,
 
    // CTA Archive ID is an EOS extended attribute, i.e. it is stored as a string, which must be
    // converted to a valid uint64_t
-   const auto archiveFileIdItor = notification.file().xattr().find("CTA_ArchiveFileId");
+   const auto archiveFileIdItor = notification.file().xattr().find("sys.archive.file_id");
    if(notification.file().xattr().end() == archiveFileIdItor) {
-     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named CTA_ArchiveFileId");
+     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named sys.archive.file_id");
    }
    const std::string archiveFileIdStr = archiveFileIdItor->second;
    if((request.archiveFileID = strtoul(archiveFileIdStr.c_str(), nullptr, 10)) == 0)
@@ -498,9 +498,9 @@ void RequestMessage::processABORT_PREPARE(const cta::eos::Notification &notifica
 
    // CTA Archive ID is an EOS extended attribute, i.e. it is stored as a string, which must be
    // converted to a valid uint64_t
-   const auto archiveFileIdItor = notification.file().xattr().find("CTA_ArchiveFileId");
+   const auto archiveFileIdItor = notification.file().xattr().find("sys.archive.file_id");
    if(notification.file().xattr().end() == archiveFileIdItor) {
-     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named CTA_ArchiveFileId");
+     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named sys.archive.file_id");
    }
    const std::string archiveFileIdStr = archiveFileIdItor->second;
    if((request.archiveFileID = strtoul(archiveFileIdStr.c_str(), nullptr, 10)) == 0)
@@ -550,9 +550,9 @@ void RequestMessage::processDELETE(const cta::eos::Notification &notification, c
    // CTA Archive ID is an EOS extended attribute, i.e. it is stored as a string, which
    // must be converted to a valid uint64_t
 
-   const auto archiveFileIdItor = notification.file().xattr().find("CTA_ArchiveFileId");
+   const auto archiveFileIdItor = notification.file().xattr().find("sys.archive.file_id");
    if(notification.file().xattr().end() == archiveFileIdItor) {
-     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named CTA_ArchiveFileId");
+     throw PbException(std::string(__FUNCTION__) + ": Failed to find the extended attribute named sys.archive.file_id");
    }
    const std::string archiveFileIdStr = archiveFileIdItor->second;
    if((request.archiveFileID = strtoul(archiveFileIdStr.c_str(), nullptr, 10)) == 0)
-- 
GitLab