From 2eefde9b080fc48254db0f92c499f5b169752c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zl=C3=A1mal?= Date: Wed, 8 Feb 2023 08:46:01 +0100 Subject: [PATCH] refactor(fbmi_doors): removed unused service --- gen/fbmi_doors | 108 ------------------------------------------------ send/fbmi_doors | 4 -- 2 files changed, 112 deletions(-) delete mode 100755 gen/fbmi_doors delete mode 100755 send/fbmi_doors diff --git a/gen/fbmi_doors b/gen/fbmi_doors deleted file mode 100755 index 7e763afb..00000000 --- a/gen/fbmi_doors +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use perunServicesInit; -use perunServicesUtils; - -sub getEpuid; -sub fillAffiliations; - -local $::SERVICE_NAME = "fbmi_doors"; -local $::PROTOCOL_VERSION = "1.0.0"; -my $SCRIPT_VERSION = "1.0.0"; - -perunServicesInit::init; -my $DIRECTORY = perunServicesInit::getDirectory; -my $data = perunServicesInit::getHashedDataWithGroups; - -my $fileName = "$DIRECTORY/$::SERVICE_NAME".".csv"; - -#Constants -our $A_USER_ID; *A_USER_ID = \'urn:perun:user:attribute-def:core:id'; -our $A_MEMBER_MAIL; *A_MEMBER_MAIL = \'urn:perun:member:attribute-def:def:mail'; -our $A_USER_EPUIDS; *A_USER_EPUIDS = \'urn:perun:user:attribute-def:virt:epuids'; -our $A_USER_AFFILIATIONS; *A_USER_AFFILIATIONS = \'urn:perun:user:attribute-def:virt:eduPersonScopedAffiliations'; - -our $A_RESOURCE_NAME; *A_RESOURCE_NAME = \'urn:perun:resource:attribute-def:core:name'; -our $A_GROUP_NAME; *A_GROUP_NAME = \'urn:perun:group:attribute-def:core:name'; - -# TODO - probably handle group expirations and status? - -my $userStruct = {}; - -foreach my $resourceId ( $data->getResourceIds() ) { - - my $resourceName = $data->getResourceAttributeValue( resource => $resourceId, attrName => $A_RESOURCE_NAME); - - foreach my $groupId ( $data->getGroupIdsForResource( resource => $resourceId ) ) { - - my $groupName = $data->getGroupAttributeValue( group => $groupId, attrName => $A_GROUP_NAME ); - - for my $memberId ( $data->getMemberIdsForResourceAndGroup( resource => $resourceId, group => $groupId )) { - - my $epuidCvut = getEpuid('@cvut.cz', $data->getUserAttributeValue( member => $memberId, attrName => $A_USER_EPUIDS)); - my $epuidCuni = getEpuid('@cuni.cz', $data->getUserAttributeValue( member => $memberId, attrName => $A_USER_EPUIDS)); - - if (defined $epuidCvut) { - - $userStruct->{$epuidCvut}->{'EMAIL'} = $data->getMemberAttributeValue( member => $memberId, attrName => $A_MEMBER_MAIL); - $userStruct->{$epuidCvut}->{'GROUPS'}->{$groupName} = 1; - $userStruct->{$epuidCvut}->{'RESOURCES'}->{$resourceName} = 1; - fillAffiliations($epuidCvut, '@cvut.cz', $data->getUserAttributeValue( member => $memberId, attrName => $A_USER_AFFILIATIONS)); - - } - - if (defined $epuidCuni) { - - $userStruct->{$epuidCuni}->{'EMAIL'} = $data->getMemberAttributeValue( member => $memberId, attrName => $A_MEMBER_MAIL); - $userStruct->{$epuidCuni}->{'GROUPS'}->{$groupName} = 1; - $userStruct->{$epuidCuni}->{'RESOURCES'}->{$resourceName} = 1; - fillAffiliations($epuidCuni, '@cuni.cz', $data->getUserAttributeValue( member => $memberId, attrName => $A_USER_AFFILIATIONS)); - - } - - } - - } - -} - - -open FILE,">:encoding(UTF-8)","$fileName" or die "Cannot open $fileName: $! \n"; -foreach my $epuid (sort keys %$userStruct) { - - my $entry = $userStruct->{$epuid}; - my @affs = sort keys %{$entry->{'AFFILIATIONS'}}; - my @grps = sort keys %{$entry->{'GROUPS'}}; - my @res = sort keys %{$entry->{'RESOURCES'}}; - - print FILE $entry->{'EMAIL'} . ";" . $epuid . ";" . join(",",@affs) . ";" . join(",",@grps) . ";" . join(",",@res) . "\n"; - -} -close (FILE) or die "Cannot close $fileName: $! \n"; - -perunServicesInit::finalize; - -sub fillAffiliations() { - my $epuid = shift @_; - my $scope = shift @_; - my $affiliations = shift @_; - - foreach my $aff (@$affiliations) { - if ($aff =~ /(.*)$scope$/) { - $userStruct->{$epuid}->{"AFFILIATIONS"}->{$aff} = 1; - } - } -} - -sub getEpuid() { - my $scope = shift @_; - my $vals = shift @_; - foreach my $val (@$vals) { - if ($val =~ /(.*)$scope$/) { - return $val; - } - } - return undef; -} diff --git a/send/fbmi_doors b/send/fbmi_doors deleted file mode 100755 index 77161c1c..00000000 --- a/send/fbmi_doors +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -export SERVICE_NAME="fbmi_doors" - -python3 generic_send.py "$1" "$2" "$3"