Example #1
0
    if ($SQLResponse_array[0] != "") {
        $SQLResponse = array_merge($SQLResponse, $SQLResponse_array);
    } else {
        $trovato = true;
    }
}
for ($uu = 0; $uu < count($SQLResponse); $uu++) {
    $value = $SQLResponse[$uu][0];
    fwrite($fp_SQLResponse, "\n{$value}\n");
}
fclose($fp_SQLResponse);
####################################################
#### CONTROLLO COME PRIMA COSA CHE LA SQL ABBIA RISULTATO
if (empty($SQLResponse)) {
    #### STRINGA DI ERRORE
    $failure_response = "[EMPTY RESULT] - STORED QUERY[  " . avoidHtmlEntitiesInterpretation($SQLQuery) . " ] DID NOT GIVE ANY RESULTS IN THIS REGISTRY";
    ### RESTITUISCE IL MESSAGGIO DI SUCCESS IN SOAP
    ### ANCHE SE IL RISULTATO DELLA QUERY DA DB È VUOTO
    $SOAPED_failure_response = makeSoapedSuccessStoredQueryResponse($Action, $MessageID, "");
    $file_input = $idfile . "-SOAPED_NORESULTS_response.xml";
    writeTmpQueryFiles($SOAPED_failure_response, $file_input, true);
    SendResponseFile($tmpQueryService_path . $file_input);
    //SendResponse($SOAPED_failure_response,"application/soap+xml",(string)filesize($tmpQueryService_path.$idfile."-SOAPED_NORESULTS_response.xml"));
    exit;
}
//END OF if(empty($SQLResponse))
####### QUI SONO SICURO CHE LE QUERY DA ALMENO UN RISULTATO
$ebXML_Response_string = "";
$ebXML_Response_SOAPED_string = "";
##### COMINCIO A COSTRUIRE L'ebXML DI RISPOSTA
############### DISTINGUO I CASI A SECONDA DEGLI ATTRIBUTI
Example #2
0
function validate_XDSDocumentEntryUniqueId($dom, $connessione)
{
    //      $fp_uniqueIdQuery = fopen("tmp/DocumentEntryUniqueIdQuery","w+");
    $ebxml_value = array();
    ##### RADICE DEL DOCUMENTO ebXML
    $root_ebXML = $dom->document_element();
    ##### ARRAY DEI NODI ExtrinsicObject
    $dom_ebXML_ExtrinsicObject_node_array = $root_ebXML->get_elements_by_tagname("ExtrinsicObject");
    #### CICLO SU OGNI ExtrinsicObject ####
    $isEmpty = false;
    $failure = "";
    for ($index = 0; $index < count($dom_ebXML_ExtrinsicObject_node_array); $index++) {
        ##### NODO ExtrinsicObject RELATIVO AL DOCUMENTO NUMERO $index
        $ExtrinsicObject_node = $dom_ebXML_ExtrinsicObject_node_array[$index];
        #### ARRAY DEI FIGLI DEL NODO ExtrinsicObject ##############
        $ExtrinsicObject_child_nodes = $ExtrinsicObject_node->child_nodes();
        #################################################################
        ################# PROCESSO TUTTI I NODI FIGLI DI ExtrinsicObject
        for ($k = 0; $k < count($ExtrinsicObject_child_nodes); $k++) {
            #### SINGOLO NODO FIGLIO DI ExtrinsicObject
            $ExtrinsicObject_child_node = $ExtrinsicObject_child_nodes[$k];
            #### NOME DEL NODO
            $ExtrinsicObject_child_node_tagname = $ExtrinsicObject_child_node->node_name();
            if ($ExtrinsicObject_child_node_tagname == 'ExternalIdentifier') {
                $externalidentifier_node = $ExtrinsicObject_child_node;
                $value_value = avoidHtmlEntitiesInterpretation($externalidentifier_node->get_attribute('value'));
                #### NODI FIGLI DI EXTERNALIDENTIFIER
                $externalidentifier_child_nodes = $externalidentifier_node->child_nodes();
                //print_r($name_node);
                for ($q = 0; $q < count($externalidentifier_child_nodes); $q++) {
                    $externalidentifier_child_node = $externalidentifier_child_nodes[$q];
                    $externalidentifier_child_node_tagname = $externalidentifier_child_node->node_name();
                    if ($externalidentifier_child_node_tagname == 'Name') {
                        $name_node = $externalidentifier_child_node;
                        $LocalizedString_nodes = $name_node->child_nodes();
                        //print_r($LocalizedString_nodes);
                        for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                            $LocalizedString_node = $LocalizedString_nodes[$p];
                            //->node_name();
                            $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                            if ($LocalizedString_node_tagname == 'LocalizedString') {
                                $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                                if (strpos(strtolower(trim($LocalizedString_value)), strtolower('DocumentEntry.uniqueId'))) {
                                    $ebxml_value[$index] = $value_value;
                                }
                            }
                        }
                    }
                }
            }
            //END OF if($ExtrinsicObject_child_node_tagname=='ExternalIdentifier')
        }
        //QUERY AL DB
        $query = "SELECT XDSDOCUMENTENTRY_UNIQUEID FROM DOCUMENTS WHERE XDSDOCUMENTENTRY_UNIQUEID = '" . $ebxml_value[$index] . "'";
        ### EFFETTUO LA QUERY ED OTTENGO IL RISULTATO
        $res = query_select2($query, $connessione);
        //array bidimensionale
        //Qui dovrei verificare che l'hash sia differente ma dato che non salvo l'hash non posso verificarlo
        //$isEmptyUniqueId = ((empty($res)) || $isEmpty);
        $isEmptyUniqueId = true;
        if (!$isEmptyUniqueId) {
            ###---> uniqueId già presente --> eccezione
            $errorcode[] = "XDSNonIdenticalHash";
            $error_message[] = "ExternalIdentifier XDSDocumentEntry.uniqueId '" . $ebxml_value[$index] . "' (urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab) already exists in registry";
            $uniqueId_response = makeSoapedFailureResponse($error_message, $errorcode);
            writeTimeFile($_SESSION['idfile'] . "--Repository: uniqueId_failure_response");
            $file_input = $_SESSION['idfile'] . "-uniqueId_failure_response-" . $_SESSION['idfile'];
            writeTmpFiles($uniqueId_response, $file_input);
            SendResponse($uniqueId_response);
            exit;
        }
    }
    //END OF for($index=0;$index<(count($dom_ebXML_ExtrinsicObject_node_array));$index++)
    $ret = array($isEmptyUniqueId, $ebxml_value);
    return $ret;
}
Example #3
0
function validate_XDSDocumentEntryUniqueId($dom, $connessione)
{
    $ebxml_value = '';
    ##### RADICE DEL DOCUMENTO ebXML
    $root_ebXML = $dom->document_element();
    ##### ARRAY DEI NODI ExtrinsicObject
    $dom_ebXML_ExtrinsicObject_node_array = $root_ebXML->get_elements_by_tagname("ExtrinsicObject");
    #### CICLO SU OGNI ExtrinsicObject ####
    $isEmpty = false;
    $failure = "";
    for ($index = 0; $index < count($dom_ebXML_ExtrinsicObject_node_array); $index++) {
        ##### NODO ExtrinsicObject RELATIVO AL DOCUMENTO NUMERO $index
        $ExtrinsicObject_node = $dom_ebXML_ExtrinsicObject_node_array[$index];
        #### ARRAY DEI FIGLI DEL NODO ExtrinsicObject ##############
        $ExtrinsicObject_child_nodes = $ExtrinsicObject_node->child_nodes();
        #################################################################
        ################# PROCESSO TUTTI I NODI FIGLI DI ExtrinsicObject
        for ($k = 0; $k < count($ExtrinsicObject_child_nodes); $k++) {
            #### SINGOLO NODO FIGLIO DI ExtrinsicObject
            $ExtrinsicObject_child_node = $ExtrinsicObject_child_nodes[$k];
            #### NOME DEL NODO
            $ExtrinsicObject_child_node_tagname = $ExtrinsicObject_child_node->node_name();
            if ($ExtrinsicObject_child_node_tagname == 'ExternalIdentifier') {
                $externalidentifier_node = $ExtrinsicObject_child_node;
                $value_value = avoidHtmlEntitiesInterpretation($externalidentifier_node->get_attribute('value'));
                #### NODI FIGLI DI EXTERNALIDENTIFIER
                $externalidentifier_child_nodes = $externalidentifier_node->child_nodes();
                //print_r($name_node);
                for ($q = 0; $q < count($externalidentifier_child_nodes); $q++) {
                    $externalidentifier_child_node = $externalidentifier_child_nodes[$q];
                    $externalidentifier_child_node_tagname = $externalidentifier_child_node->node_name();
                    if ($externalidentifier_child_node_tagname == 'Name') {
                        $name_node = $externalidentifier_child_node;
                        $LocalizedString_nodes = $name_node->child_nodes();
                        //print_r($LocalizedString_nodes);
                        for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                            $LocalizedString_node = $LocalizedString_nodes[$p];
                            //->node_name();
                            $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                            if ($LocalizedString_node_tagname == 'LocalizedString') {
                                $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                                if (strpos(strtolower(trim($LocalizedString_value)), strtolower('DocumentEntry.uniqueId'))) {
                                    $ebxml_value = $value_value;
                                }
                            }
                        }
                    }
                }
            }
            //END OF if($ExtrinsicObject_child_node_tagname=='ExternalIdentifier')
        }
        //QUERY AL DB
        $query = "SELECT XDSDOCUMENTENTRY_UNIQUEID FROM DOCUMENTS WHERE XDSDOCUMENTENTRY_UNIQUEID = '{$ebxml_value}'";
        ### EFFETTUO LA QUERY ED OTTENGO IL RISULTATO
        $res = query_select2($query, $connessione);
        //array bidimensionale
        $isEmpty = empty($res) || $isEmpty;
        if (!$isEmpty) {
            $failure = $failure . "\nExternalIdentifier XDSDocumentEntry.uniqueId {$ebxml_value} (urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab) already exists in registry\n";
        }
    }
    //END OF for($index=0;$index<(count($dom_ebXML_ExtrinsicObject_node_array));$index++)
    $ret = array($isEmpty, $failure, $ebxml_value);
    return $ret;
}
function mantainMetadata($ExtrinsicObject_node, $file_name, $document_URI)
{
    include "config/REP_configuration.php";
    #### RICAVO ATTRIBUTO id DI ExtrinsicObject
    $ExtrinsicObject_id_attr = $ExtrinsicObject_node->get_attribute('id');
    #### FIGLI DI ExtrinsicObject
    $ExtrinsicObject_child_nodes = $ExtrinsicObject_node->child_nodes();
    $count = 0;
    for ($i = 0; $i < count($ExtrinsicObject_child_nodes); $i++) {
        ### SINGOLO NODO FIGLIO
        $ExtrinsicObject_child_node = $ExtrinsicObject_child_nodes[$i];
        ### TAGNAME DEL SINGOLO NODO FIGLIO
        $ExtrinsicObject_child_node_tagname = $ExtrinsicObject_child_node->node_name();
        if ($ExtrinsicObject_child_node_tagname == 'Slot') {
            $slot_node = $ExtrinsicObject_child_node;
            $value_name = $slot_node->get_attribute('name');
            if (strtoupper($value_name) == "HASH") {
                #### NODI FIGLI DI SLOT
                $slot_child_nodes = $slot_node->child_nodes();
                for ($q = 0; $q < count($slot_child_nodes); $q++) {
                    $slot_child_node = $slot_child_nodes[$q];
                    $slot_child_node_tagname = $slot_child_node->node_name();
                    if ($slot_child_node_tagname == 'ValueList') {
                        $valuelist_node = $slot_child_node;
                        $valuelist_child_nodes = $valuelist_node->child_nodes();
                        ## UN SOLO VALUE
                        if (count($valuelist_child_nodes) == 3) {
                            $value_node = $valuelist_child_nodes[1];
                            $hash = $value_node->get_content();
                        }
                    }
                }
            }
            //END OF if(strtoupper($value_name)== "HASH")
            if (strtoupper($value_name) == "SIZE") {
                #### NODI FIGLI DI SLOT
                $slot_child_nodes = $slot_node->child_nodes();
                for ($q = 0; $q < count($slot_child_nodes); $q++) {
                    $slot_child_node = $slot_child_nodes[$q];
                    $slot_child_node_tagname = $slot_child_node->node_name();
                    if ($slot_child_node_tagname == 'ValueList') {
                        $valuelist_node = $slot_child_node;
                        $valuelist_child_nodes = $valuelist_node->child_nodes();
                        ## UN SOLO VALUE
                        if (count($valuelist_child_nodes) == 3) {
                            $value_node = $valuelist_child_nodes[1];
                            $size = $value_node->get_content();
                        }
                    }
                }
            }
            //END OF if(strtoupper($value_name)== "SIZE")
            if (strtoupper($value_name) == "URI") {
                #### NODI FIGLI DI SLOT
                $slot_child_nodes = $slot_node->child_nodes();
                for ($q = 0; $q < count($slot_child_nodes); $q++) {
                    $slot_child_node = $slot_child_nodes[$q];
                    $slot_child_node_tagname = $slot_child_node->node_name();
                    if ($slot_child_node_tagname == 'ValueList') {
                        $valuelist_node = $slot_child_node;
                        $valuelist_child_nodes = $valuelist_node->child_nodes();
                        ## UN SOLO VALUE
                        if (count($valuelist_child_nodes) == 3) {
                            $value_node = $valuelist_child_nodes[1];
                            $Document_URI = $value_node->get_content();
                        }
                    }
                }
            }
            //END OF if(strtoupper($value_name)== "URI")
        }
        //END OF if($ExtrinsicObject_child_node_tagname=='Slot')
        if ($ExtrinsicObject_child_node_tagname == 'Classification' && $count == 0) {
            $next_node = $ExtrinsicObject_child_node;
            $count++;
        }
        //END OF if($ExtrinsicObject_child_node_tagname=='Classification')
        if ($ExtrinsicObject_child_node_tagname == 'ExternalIdentifier') {
            $externalidentifier_node = $ExtrinsicObject_child_node;
            $value_value = avoidHtmlEntitiesInterpretation($externalidentifier_node->get_attribute('value'));
            #### NODI FIGLI DI EXTERNALIDENTIFIER
            $externalidentifier_child_nodes = $externalidentifier_node->child_nodes();
            for ($q = 0; $q < count($externalidentifier_child_nodes); $q++) {
                $externalidentifier_child_node = $externalidentifier_child_nodes[$q];
                $externalidentifier_child_node_tagname = $externalidentifier_child_node->node_name();
                if ($externalidentifier_child_node_tagname == 'Name') {
                    $name_node = $externalidentifier_child_node;
                    $LocalizedString_nodes = $name_node->child_nodes();
                    for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                        $LocalizedString_node = $LocalizedString_nodes[$p];
                        //->node_name();
                        $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                        if ($LocalizedString_node_tagname == 'LocalizedString') {
                            $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                            if (strpos(strtolower(trim($LocalizedString_value)), strtolower('DocumentEntry.uniqueId'))) {
                                $ebxml_value = $value_value;
                            }
                        }
                    }
                }
            }
        }
        //END OF if($ExtrinsicObject_child_node_tagname=='ExternalIdentifier')
    }
    //END OF for($i=0;$i<(count($ExtrinsicObject_child_nodes));$i++)
    ############### TABELLA DOCUMENTS ##############
    #### RECUPERO DATA E ORA ATTUALI
    /*$today = date("Y-m-d");
    	$cur_hour = date("H:i:s");
    	$datetime = $today." ".$cur_hour;
    
    	$insert_into_DOCUMENTS = "INSERT INTO DOCUMENTS (XDSDocumentEntry_uniqueId,ExtrinsicObject_id,file_system_id,size,hash,URI,TEXT,DATE) VALUES ('$ebxml_value','$ExtrinsicObject_id_attr','$file_name','$size','$hash','$Document_URI','".adjustString($allegato_STRING)."','$datetime')";*/
}
Example #5
0
function controllaQuery($SQLQuery)
{
    $errorcode = array();
    $error_message = array();
    $isQueryAllowed = true;
    ###DEFAULT
    $queryError = "";
    $pos_1 = strpos(strtoupper($SQLQuery), "SELECT");
    $pos_2 = strpos(strtoupper($SQLQuery), "*");
    //$pos_3=strpos(strtoupper($SQLQuery),"%");
    //$pos_4=strpos(strtoupper($SQLQuery),"LIKE");
    ## Notate l'uso di ===
    ### Il == non avrebbe risposto come atteso
    ##### ACCETTO SOLO QUERY DEL TIPO:  SELECT eo.id  FROM....
    if (!($pos_1 === 0) || $pos_2) {
        $isQueryAllowed = false;
        $errorcode[] = "XDSSqlError";
        $error_message[] = "[ERROR: NOT PROPER QUERY] - YOU ARE NOT ALLOWED TO PERFORM THIS KIND OF QUERY TO THIS REGISTRY[  " . avoidHtmlEntitiesInterpretation($SQLQuery) . " ]";
        $query_not_allowed_response = makeSoapedFailureResponse($error_message, $errorcode);
        writeTimeFile($_SESSION['idfile'] . "--StoredQuery: Query NOT allowed");
        $file_input = $_SESSION['idfile'] . "-query_not_allowed.xml";
        writeTmpQueryFiles($query_not_allowed_response, $file_input, true);
        SendResponseFile($_SESSION['tmpQueryService_path'] . $file_input);
        //SendResponse($query_not_allowed_response);
        exit;
    } else {
        writeTimeFile($_SESSION['idfile'] . "--StoredQuery: Query allowed");
    }
    $ret = array($isQueryAllowed, $queryError);
    return $ret;
}
Example #6
0
function fill_RegistryPackage_tables($dom, $language, $connessione)
{
    #### LANGUAGECODE
    $lang = $language;
    ##### NODEREPRESENTATION
    $value_nodeRepresentation_assigned = '';
    ##### ARRAY DELL'ATTRIBUTO ID DI REGISTRYPACKAGE
    $RegistryPackage_id_array = array();
    $simbolic_RegistryPackage_id_array = array();
    #### FOLDERID DA NON INSERIRE
    $RegistryPackage_Fol_id_array = array();
    ##### ARRAY DEGLI ATTRIBUTI DEL NODO REGISTRYPACKAGE
    $DB_array_registrypackage_attributes = array();
    ##### RADICE DEL DOCUMENTO ebXML
    $root_ebXML = $dom->document_element();
    ##### ARRAY DEI NODI REGISTRYPACKAGE
    $dom_ebXML_RegistryPackage_node_array = $root_ebXML->get_elements_by_tagname("RegistryPackage");
    ##### ARRAY FOR ATNA
    $atna_value = array();
    #### CICLO SU OGNI RegistryPackage ####
    for ($index = 0; $index < count($dom_ebXML_RegistryPackage_node_array); $index++) {
        ##### NODO REGISTRYPACKAGE RELATIVO AL DOCUMENTO NUMERO $index
        $RegistryPackage_node = $dom_ebXML_RegistryPackage_node_array[$index];
        ### Setto di default che RegistryPackage non è un folder già presente
        $isEmpty_F = true;
        ##### NODO REGISTRYPACKAGE RELATIVO AL DOCUMENTO NUMERO $index
        $RegistryPackage_node = $dom_ebXML_RegistryPackage_node_array[$index];
        #### ARRAY DEI FIGLI DEL NODO REGISTRYPACKAGE ##############
        $RegistryPackage_child_nodes = $RegistryPackage_node->child_nodes();
        #################################################################
        ################# PROCESSO TUTTI I NODI FIGLI DI REGISTRYPACKAGE
        for ($k = 0; $k < count($RegistryPackage_child_nodes); $k++) {
            #### SINGOLO NODO FIGLIO DI REGISTRYPACKAGE
            $RegistryPackage_child_node = $RegistryPackage_child_nodes[$k];
            #### NOME DEL NODO
            $RegistryPackage_child_node_tagname = $RegistryPackage_child_node->node_name();
            ########## Versione 2.1 per gestione Folder.uniqueid #############
            if ($RegistryPackage_child_node_tagname == 'ExternalIdentifier') {
                $externalidentifier_node = $RegistryPackage_child_node;
                $value_value = avoidHtmlEntitiesInterpretation($externalidentifier_node->get_attribute('value'));
                #### NODI FIGLI DI EXTERNALIDENTIFIER
                $externalidentifier_child_nodes = $externalidentifier_node->child_nodes();
                for ($q = 0; $q < count($externalidentifier_child_nodes); $q++) {
                    $externalidentifier_child_node = $externalidentifier_child_nodes[$q];
                    $externalidentifier_child_node_tagname = $externalidentifier_child_node->node_name();
                    if ($externalidentifier_child_node_tagname == 'Name') {
                        $name_node = $externalidentifier_child_node;
                        $LocalizedString_nodes = $name_node->child_nodes();
                        for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                            $LocalizedString_node = $LocalizedString_nodes[$p];
                            //->node_name();
                            $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                            if ($LocalizedString_node_tagname == 'LocalizedString') {
                                $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                                if (strpos(strtolower(trim($LocalizedString_value)), strtolower('Folder.uniqueId'))) {
                                    $ebxml_value = $value_value;
                                    ### QUERY AL DB
                                    $query = "SELECT registryObject FROM ExternalIdentifier WHERE value = '{$ebxml_value}' and identificationScheme = 'urn:uuid:75df8f67-9973-4fbe-a900-df66cefecc5a'";
                                    $res = query_select2($query, $connessione);
                                    //array bidimensionale
                                    writeSQLQuery($res . ": " . $query);
                                    $isEmpty_F = empty($res);
                                    $value_RegistryPackage_id = $res[0][0];
                                    //$RegistryPackage_Fol_id_array[]=$simbolic_RegistryPackage_id_fol;
                                }
                            }
                        }
                    }
                }
            }
        }
        ###############################################################################
        if ($isEmpty_F) {
            ############## RECUPERO TUTTI GLI ATTRIBUTI DEL NODO REGISTRYPACKAGE
            $value_RegistryPackage_id = "urn:uuid:" . idrandom();
            $simbolic_RegistryPackage_id = $RegistryPackage_node->get_attribute('id');
            $simbolic_RegistryPackage_id_array[] = $RegistryPackage_node->get_attribute('id');
            #############################################################
            ####NOTA BENE NEL CASO NON SIMBOLICO(VEDI SOLINFO)
            if (!isSimbolic($simbolic_RegistryPackage_id)) {
                $value_RegistryPackage_id = $simbolic_RegistryPackage_id;
            }
            #############################################################
            $RegistryPackage_id_array[$simbolic_RegistryPackage_id] = $value_RegistryPackage_id;
            $value_accessControlPolicy = $RegistryPackage_node->get_attribute('accessControlPolicy');
            if ($value_accessControlPolicy == '') {
                $value_accessControlPolicy = "NULL";
            }
            $value_objectType = $RegistryPackage_node->get_attribute('objectType');
            if ($value_objectType == '' || $value_objectType == 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage') {
                $value_objectType = "RegistryPackage";
            }
            $value_expiration = $RegistryPackage_node->get_attribute('expiration');
            if ($value_expiration == '') {
                $value_expiration = "CURRENT_TIMESTAMP";
            }
            $value_majorVersion = $RegistryPackage_node->get_attribute('majorVersion');
            if ($value_majorVersion == '') {
                $value_majorVersion = "0";
            }
            $value_minorVersion = $RegistryPackage_node->get_attribute('minorVersion');
            if ($value_minorVersion == '') {
                $value_minorVersion = "1";
            }
            $value_stability = $RegistryPackage_node->get_attribute('stability');
            if ($value_stability == '') {
                $value_stability = "NULL";
            }
            $value_status = $RegistryPackage_node->get_attribute('status');
            if ($value_status == '') {
                //$value_status = "Approved";
                $value_status = "NotCompleted";
            }
            $value_userVersion = $RegistryPackage_node->get_attribute('userVersion');
            if ($value_userVersion == '') {
                $value_userVersion = "NULL";
            }
            $DB_array_registrypackage_attributes['accessControlPolicy'] = $value_accessControlPolicy;
            $DB_array_registrypackage_attributes['id'] = $value_RegistryPackage_id;
            $DB_array_registrypackage_attributes['objectType'] = $value_objectType;
            $DB_array_registrypackage_attributes['expiration'] = $value_expiration;
            $DB_array_registrypackage_attributes['majorVersion'] = $value_majorVersion;
            $DB_array_registrypackage_attributes['minorVersion'] = $value_minorVersion;
            $DB_array_registrypackage_attributes['stability'] = $value_stability;
            $DB_array_registrypackage_attributes['status'] = $value_status;
            $DB_array_registrypackage_attributes['userVersion'] = $value_userVersion;
            ####### QUI ORA POSSO RIEMPIRE IL DB
            $INSERT_INTO_RegistryPackage = "INSERT INTO RegistryPackage (id,accessControlPolicy,objectType,expiration,majorVersion,minorVersion,stability,status,userVersion) VALUES\n('" . $DB_array_registrypackage_attributes['id'] . "','" . $DB_array_registrypackage_attributes['accessControlPolicy'] . "','" . $DB_array_registrypackage_attributes['objectType'] . "'," . $DB_array_registrypackage_attributes['expiration'] . ",'" . $DB_array_registrypackage_attributes['majorVersion'] . "','" . $DB_array_registrypackage_attributes['minorVersion'] . "','" . $DB_array_registrypackage_attributes['stability'] . "','" . $DB_array_registrypackage_attributes['status'] . "','" . $DB_array_registrypackage_attributes['userVersion'] . "')";
            $ris = query_exec2($INSERT_INTO_RegistryPackage, $connessione);
            writeSQLQuery($ris . ": " . $INSERT_INTO_RegistryPackage);
            ############## FINE RECUPERO TUTTI GLI ATTRIBUTI DEL NODO REGISTRYPACKAGE
            #### ARRAY DEI FIGLI DEL NODO REGISTRYPACKAGE ##############
            $RegistryPackage_child_nodes = $RegistryPackage_node->child_nodes();
            #################################################################
            ################# PROCESSO TUTTI I NODI FIGLI DI REGISTRYPACKAGE
            $value_parent = $value_RegistryPackage_id;
            for ($k = 0; $k < count($RegistryPackage_child_nodes); $k++) {
                #### SINGOLO NODO FIGLIO DI REGISTRYPACKAGE
                $RegistryPackage_child_node = $RegistryPackage_child_nodes[$k];
                #### NOME DEL NODO
                $RegistryPackage_child_node_tagname = $RegistryPackage_child_node->node_name();
                #### NODO NAME
                if ($RegistryPackage_child_node_tagname == 'Name') {
                    $name_node = $RegistryPackage_child_node;
                    $DB_array_name = array();
                    $LocalizedString_nodes = $name_node->child_nodes();
                    for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                        $LocalizedString_node = $LocalizedString_nodes[$p];
                        //->node_name();
                        $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                        if ($LocalizedString_node_tagname == 'LocalizedString') {
                            $LocalizedString_charset = $LocalizedString_node->get_attribute('charset');
                            if ($LocalizedString_charset == '') {
                                $LocalizedString_charset = "UTF-8";
                            }
                            $LocalizedString_lang = $LocalizedString_node->get_attribute('lang');
                            if ($LocalizedString_lang == '') {
                                $LocalizedString_lang = $lang;
                            }
                            $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                            if ($LocalizedString_value == '') {
                                $LocalizedString_value = "NOT DECLARED";
                            }
                            ### CASO DI FOLDER
                            $lastUpdateTime = true;
                            ###NON MODIFICARE!!!
                            $DB_array_name['charset'] = $LocalizedString_charset;
                            $DB_array_name['lang'] = $LocalizedString_lang;
                            $DB_array_name['value'] = $LocalizedString_value;
                        }
                        //END OF if($LocalizedString_node_tagname == 'LocalizedString')
                    }
                    //END OF for($p = 0;$p < count($val_list_node);$p++)
                    //$value_parent = $value_RegistryPackage_id;
                    $DB_array_name['parent'] = $value_parent;
                    //print_r($DB_array_name);
                    ##### SONO PRONTO A SCRIVERE NEL DB
                    $INSERT_INTO_Name = "INSERT INTO Name (charset,lang,value,parent) VALUES ('" . trim($DB_array_name['charset']) . "','" . trim($DB_array_name['lang']) . "','" . trim(adjustString($DB_array_name['value'])) . "','" . trim($DB_array_name['parent']) . "')";
                    $ris = query_exec2($INSERT_INTO_Name, $connessione);
                    writeSQLQuery($ris . ": " . $INSERT_INTO_Name);
                } else {
                    if ($RegistryPackage_child_node_tagname == 'Description') {
                        $description_node = $RegistryPackage_child_node;
                        $DB_array_description = array();
                        $LocalizedString_nodes = $description_node->child_nodes();
                        if (count($LocalizedString_nodes) != 0) {
                            //print_r($LocalizedString_nodes);
                            for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                                $LocalizedString_node = $LocalizedString_nodes[$p];
                                $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                                if ($LocalizedString_node_tagname == 'LocalizedString') {
                                    $LocalizedString_charset = $LocalizedString_node->get_attribute('charset');
                                    if ($LocalizedString_charset == '') {
                                        $LocalizedString_charset = "UTF-8";
                                    }
                                    $LocalizedString_lang = $LocalizedString_node->get_attribute('lang');
                                    if ($LocalizedString_lang == '') {
                                        $LocalizedString_lang = $lang;
                                    }
                                    $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                                    if ($LocalizedString_value == '') {
                                        $LocalizedString_value = "NOT DECLARED";
                                    }
                                    $DB_array_description['charset'] = $LocalizedString_charset;
                                    $DB_array_description['lang'] = $LocalizedString_lang;
                                    $DB_array_description['value'] = $LocalizedString_value;
                                }
                                //END OF if($LocalizedString_node_tagname == 'LocalizedString')
                            }
                            //END OF for($p = 0;$p < count($val_list_node);$p++)
                            //$value_parent = $id;
                            $DB_array_description['parent'] = $value_parent;
                        } else {
                            $DB_array_description['charset'] = "UTF-8";
                            $DB_array_description['lang'] = "it-it";
                            $DB_array_description['value'] = "NOT DECLARED";
                            $DB_array_description['parent'] = $value_parent;
                        }
                        ##### SONO PRONTO A SCRIVERE NEL DB
                        $INSERT_INTO_Description = "INSERT INTO Description (charset,lang,value,parent) VALUES ('" . trim($DB_array_description['charset']) . "','" . trim($DB_array_description['lang']) . "','" . trim(adjustString($DB_array_description['value'])) . "','" . trim($DB_array_description['parent']) . "')";
                        $ris = query_exec2($INSERT_INTO_Description, $connessione);
                        writeSQLQuery($ris . ": " . $INSERT_INTO_Description);
                    } else {
                        if ($RegistryPackage_child_node_tagname == 'Slot') {
                            $slot_node = $RegistryPackage_child_node;
                            $DB_array_slot_attributes = array();
                            $value_name = $slot_node->get_attribute('name');
                            if ($value_name == '') {
                                $value_name = "NOT DECLARED";
                            }
                            $value_slotType = $slot_node->get_attribute('slotType');
                            if ($value_slotType == '') {
                                $value_slotType = "NULL";
                            }
                            $DB_array_slot_attributes['name'] = $value_name;
                            $DB_array_slot_attributes['slotType'] = $value_slotType;
                            $DB_array_slot_attributes['value'] = '';
                            $DB_array_slot_attributes['parent'] = $value_parent;
                            #### NODI FIGLI DI SLOT
                            $slot_child_nodes = $slot_node->child_nodes();
                            for ($q = 0; $q < count($slot_child_nodes); $q++) {
                                $slot_child_node = $slot_child_nodes[$q];
                                $slot_child_node_tagname = $slot_child_node->node_name();
                                if ($slot_child_node_tagname == 'ValueList') {
                                    $valuelist_node = $slot_child_node;
                                    $valuelist_child_nodes = $valuelist_node->child_nodes();
                                    for ($r = 0; $r < count($valuelist_child_nodes); $r++) {
                                        $value_node = $valuelist_child_nodes[$r];
                                        $value_node_tagname = $value_node->node_name();
                                        if ($value_node_tagname == 'Value' && $value_name != "lastUpdateTime") {
                                            $value_value = $value_node->get_content();
                                            $DB_array_slot_attributes['value'] = $value_value;
                                            ##### SONO PRONTO A SCRIVERE NEL DB
                                            $INSERT_INTO_Slot = "INSERT INTO Slot (name,slotType,value,parent) VALUES ('" . trim($DB_array_slot_attributes['name']) . "','" . trim($DB_array_slot_attributes['slotType']) . "','" . trim(adjustString($DB_array_slot_attributes['value'])) . "','" . trim($DB_array_slot_attributes['parent']) . "')";
                                            $ris = query_exec2($INSERT_INTO_Slot, $connessione);
                                            writeSQLQuery($ris . ": " . $INSERT_INTO_Slot);
                                        }
                                    }
                                }
                            }
                        } else {
                            if ($RegistryPackage_child_node_tagname == 'Classification') {
                                $classification_node = $RegistryPackage_child_node;
                                $DB_array_classification_attributes = array();
                                $value_id = $classification_node->get_attribute('id');
                                if ($value_id == '' || isSimbolic($value_id)) {
                                    $value_id = "urn:uuid:" . idrandom();
                                }
                                $value_classifiedObject = $value_RegistryPackage_id;
                                $value_accessControlPolicy = $classification_node->get_attribute('accessControlPolicy');
                                if ($value_accessControlPolicy == '') {
                                    $value_accessControlPolicy = "NULL";
                                }
                                $value_objectType = $classification_node->get_attribute('objectType');
                                if ($value_objectType == '' || $value_objectType == 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification') {
                                    $value_objectType = "Classification";
                                }
                                $value_classificationNode = $classification_node->get_attribute('classificationNode');
                                $value_classificationScheme = $classification_node->get_attribute('classificationScheme');
                                if ($value_classificationNode == '') {
                                    $queryForName_value = "SELECT Name_value FROM ClassificationScheme WHERE ClassificationScheme.id = '{$value_classificationScheme}'";
                                    $risName_value = query_select2($queryForName_value, $connessione);
                                    writeSQLQuery($risName_value . ": " . $queryForName_value);
                                    $name_value = $risName_value[0][0];
                                    $name_value = substr($name_value, 0, strpos($name_value, '.'));
                                    $queryForClassificationNode = "SELECT id FROM ClassificationNode WHERE ClassificationNode.code = '{$name_value}'";
                                    $ris_code = query_select2($queryForClassificationNode, $connessione);
                                    writeSQLQuery($ris_code . ": " . $queryForClassificationNode);
                                    $value_classificationNode = $ris_code[0][0];
                                }
                                if ($value_classificationScheme == '') {
                                    $queryForClassificationNode = "SELECT code FROM ClassificationNode WHERE ClassificationNode.id = '{$value_classificationNode}'";
                                    $ris_classificationNode = query_select2($queryForClassificationNode, $connessione);
                                    writeSQLQuery($ris_classificationNode . ": " . $queryForClassificationNode);
                                    $code_classificationNode = $ris_classificationNode[0][0];
                                    #### FOLDER
                                    if ($code_classificationNode == "XDSFolder") {
                                        $queryForClassificationScheme = "SELECT id FROM ClassificationScheme WHERE ClassificationScheme. Name_value = 'XDSFolder.codeList'";
                                        $ris_ClassificationScheme = query_select2($queryForClassificationScheme, $connessione);
                                        writeSQLQuery($ris_ClassificationScheme . ": " . $queryForClassificationScheme);
                                        $value_classificationScheme = $ris_ClassificationScheme[0][0];
                                    } else {
                                        if ($code_classificationNode == "XDSSubmissionSet") {
                                            $queryForClassificationScheme = "SELECT id FROM ClassificationScheme WHERE ClassificationScheme. Name_value = 'XDSSubmissionSet.contentTypeCode'";
                                            $ris_ClassificationScheme = query_select2($queryForClassificationScheme, $connessione);
                                            writeSQLQuery($ris_ClassificationScheme . ": " . $queryForClassificationScheme);
                                            $value_classificationScheme = $ris_ClassificationScheme[0][0];
                                        }
                                    }
                                    //END OF if($code_classificationNode=="XDSSubmissionSet")
                                }
                                //END OF if($value_classificationScheme == '')
                                $value_nodeRepresentation = $classification_node->get_attribute('nodeRepresentation');
                                ## SALVO IL VALORE DI nodeRepresentation DICHIARATO NEL SUBMISSIONSET
                                if ($value_nodeRepresentation != '' && $value_classificationScheme == 'urn:uuid:aa543740-bdda-424e-8c96-df4873be8500') {
                                    $value_nodeRepresentation_assigned = $value_nodeRepresentation;
                                }
                                ## CASO DI nodeRepresentation NON DICHIARATO (ES. FOLDER)
                                if ($value_nodeRepresentation == '') {
                                    $value_nodeRepresentation = $value_nodeRepresentation_assigned;
                                }
                                $DB_array_classification_attributes['classificationScheme'] = $value_classificationScheme;
                                $DB_array_classification_attributes['accessControlPolicy'] = $value_accessControlPolicy;
                                $DB_array_classification_attributes['id'] = $value_id;
                                $DB_array_classification_attributes['objectType'] = $value_objectType;
                                $DB_array_classification_attributes['classifiedObject'] = $value_classifiedObject;
                                $DB_array_classification_attributes['classificationNode'] = $value_classificationNode;
                                $DB_array_classification_attributes['nodeRepresentation'] = $value_nodeRepresentation;
                                //print_r($DB_array_classification_attributes);
                                ##### SONO PRONTO A SCRIVERE NEL DB
                                $INSERT_INTO_Classification = "INSERT INTO Classification (id,accessControlPolicy,objectType,classificationNode,classificationScheme,classifiedObject,nodeRepresentation) VALUES ('" . trim($DB_array_classification_attributes['id']) . "','" . trim($DB_array_classification_attributes['accessControlPolicy']) . "','" . trim($DB_array_classification_attributes['objectType']) . "','" . trim($DB_array_classification_attributes['classificationNode']) . "','" . trim($DB_array_classification_attributes['classificationScheme']) . "','" . trim($DB_array_classification_attributes['classifiedObject']) . "','" . trim($DB_array_classification_attributes['nodeRepresentation']) . "')";
                                $ris = query_exec2($INSERT_INTO_Classification, $connessione);
                                writeSQLQuery($ris . ": " . $INSERT_INTO_Classification);
                                #### NODI FIGLI DI CLASSIFICATION
                                $classification_child_nodes = $classification_node->child_nodes();
                                for ($q = 0; $q < count($classification_child_nodes); $q++) {
                                    $classification_child_node = $classification_child_nodes[$q];
                                    $classification_child_node_tagname = $classification_child_node->node_name();
                                    if ($classification_child_node_tagname == 'Name') {
                                        $name_node = $classification_child_node;
                                        $DB_array_name = array();
                                        $LocalizedString_nodes = $name_node->child_nodes();
                                        //print_r($LocalizedString_nodes);
                                        for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                                            $LocalizedString_node = $LocalizedString_nodes[$p];
                                            //->node_name();
                                            $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                                            if ($LocalizedString_node_tagname == 'LocalizedString') {
                                                $LocalizedString_charset = $LocalizedString_node->get_attribute('charset');
                                                if ($LocalizedString_charset == '') {
                                                    $LocalizedString_charset = "UTF-8";
                                                }
                                                $LocalizedString_lang = $LocalizedString_node->get_attribute('lang');
                                                if ($LocalizedString_lang == '') {
                                                    $LocalizedString_lang = $lang;
                                                }
                                                $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                                                if ($LocalizedString_value == '') {
                                                    $LocalizedString_value = "NOT DECLARED";
                                                }
                                                $DB_array_name['charset'] = $LocalizedString_charset;
                                                $DB_array_name['lang'] = $LocalizedString_lang;
                                                $DB_array_name['value'] = $LocalizedString_value;
                                            }
                                            //END OF if($LocalizedString_node_tagname == 'LocalizedString')
                                        }
                                        //END OF for($p = 0;$p < count($val_list_node);$p++)
                                        //$value_parent = $id;
                                        $DB_array_name['parent'] = $value_id;
                                        //print_r($DB_array_name);
                                        ##### SONO PRONTO A SCRIVERE NEL DB
                                        $INSERT_INTO_Name = "INSERT INTO Name (charset,lang,value,parent) VALUES ('" . trim($DB_array_name['charset']) . "','" . trim($DB_array_name['lang']) . "','" . trim(adjustString($DB_array_name['value'])) . "','" . trim($DB_array_name['parent']) . "')";
                                        $ris = query_exec2($INSERT_INTO_Name, $connessione);
                                        writeSQLQuery($ris . ": " . $INSERT_INTO_Name);
                                    }
                                    //END OF if($classification_child_node_tagname=='Name')
                                }
                                for ($rs = 0; $rs < count($classification_child_nodes); $rs++) {
                                    $classification_child_node = $classification_child_nodes[$rs];
                                    $classification_child_node_tagname = $classification_child_node->node_name();
                                    if ($classification_child_node_tagname == 'Slot') {
                                        $slot_node = $classification_child_node;
                                        $DB_array_slot_attributes = array();
                                        $value_name = $slot_node->get_attribute('name');
                                        if ($value_name == '') {
                                            $value_name = "NOT DECLARED";
                                        }
                                        $value_slotType = $slot_node->get_attribute('slotType');
                                        if ($value_slotType == '') {
                                            $value_slotType = "NULL";
                                        }
                                        $DB_array_slot_attributes['name'] = $value_name;
                                        $DB_array_slot_attributes['slotType'] = $value_slotType;
                                        $DB_array_slot_attributes['value'] = '';
                                        $DB_array_slot_attributes['parent'] = $value_id;
                                        $slot_child_nodes = $slot_node->child_nodes();
                                        for ($q = 0; $q < count($slot_child_nodes); $q++) {
                                            $slot_child_node = $slot_child_nodes[$q];
                                            $slot_child_node_tagname = $slot_child_node->node_name();
                                            if ($slot_child_node_tagname == 'ValueList') {
                                                $valuelist_node = $slot_child_node;
                                                $valuelist_child_nodes = $valuelist_node->child_nodes();
                                                for ($r = 0; $r < count($valuelist_child_nodes); $r++) {
                                                    $value_node = $valuelist_child_nodes[$r];
                                                    $value_node_tagname = $value_node->node_name();
                                                    if ($value_node_tagname == 'Value') {
                                                        $value_value = $value_node->get_content();
                                                        $DB_array_slot_attributes['value'] = $value_value;
                                                        ##### SONO PRONTO A SCRIVERE NEL DB
                                                        $INSERT_INTO_Slot = "INSERT INTO Slot (name,slotType,value,parent) VALUES ('" . trim($DB_array_slot_attributes['name']) . "','" . trim($DB_array_slot_attributes['slotType']) . "','" . trim(adjustString($DB_array_slot_attributes['value'])) . "','" . trim($DB_array_slot_attributes['parent']) . "')";
                                                        $ris = query_exec2($INSERT_INTO_Slot, $connessione);
                                                        writeSQLQuery($ris . ": " . $INSERT_INTO_Slot);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //END OF if($classification_child_node_tagname=='Slot')
                                }
                            } else {
                                if ($RegistryPackage_child_node_tagname == 'ExternalIdentifier') {
                                    //$ExternalIdentifier_count++;
                                    $externalidentifier_node = $RegistryPackage_child_node;
                                    $DB_array_externalidentifier_attributes = array();
                                    $value_accessControlPolicy = $externalidentifier_node->get_attribute('accessControlPolicy');
                                    if ($value_accessControlPolicy == '') {
                                        $value_accessControlPolicy = "NULL";
                                    }
                                    $value_id = $externalidentifier_node->get_attribute('id');
                                    if ($value_id == '' || isSimbolic($value_id)) {
                                        $value_id = "urn:uuid:" . idrandom();
                                    }
                                    $value_objectType = $externalidentifier_node->get_attribute('objectType');
                                    if ($value_objectType == '' || $value_objectType == 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier') {
                                        $value_objectType = "ExternalIdentifier";
                                    }
                                    $value_registryObject = $value_RegistryPackage_id;
                                    // 			$value_registryObject= $externalidentifier_node->get_attribute('registryObject');
                                    // 			if($value_registryObject == '')
                                    // 			{
                                    // 				$value_registryObject = "NOT DECLARED";
                                    // 			}
                                    $value_identificationScheme = $externalidentifier_node->get_attribute('identificationScheme');
                                    #### DALL'identificationScheme RICONOSCO IL TIPO DI REGISTRYPACKAGE
                                    $queryForName_value = "SELECT Name_value FROM ClassificationScheme WHERE ClassificationScheme.id = '{$value_identificationScheme}'";
                                    $risName_value = query_select2($queryForName_value, $connessione);
                                    $name_value = $risName_value[0][0];
                                    $name_value = substr($name_value, 0, strpos($name_value, '.'));
                                    $query_for_objectType = "SELECT id FROM ClassificationNode WHERE ClassificationNode.code = '{$name_value}'";
                                    $objectType_arr = query_select2($query_for_objectType, $connessione);
                                    writeSQLQuery($objectType_arr . ": " . $query_for_objectType);
                                    $objectType = $objectType_arr[0][0];
                                    #### CASO DI FOLDER
                                    if ($name_value == 'XDSFolder' && $lastUpdateTime) {
                                        //$datetime="00000000000000";
                                        $today = date("Ymd");
                                        $cur_hour = date("His");
                                        $datetime = $today . $cur_hour;
                                        $insert_lastUpdateTime_Slot = "INSERT INTO Slot (name,slotType,value,parent) VALUES ('lastUpdateTime','NULL','{$datetime}','{$value_parent}')";
                                        $ris = query_exec2($insert_lastUpdateTime_Slot, $connessione);
                                        writeSQLQuery($ris . ": " . $insert_lastUpdateTime_Slot);
                                        $lastUpdateTime = false;
                                    }
                                    //END OF if($name_value=='XDSFolder')
                                    ####UPDATE DELL'OBJECTTYPE
                                    $update_objectType = "UPDATE RegistryPackage SET RegistryPackage.objectType = '{$objectType}' WHERE RegistryPackage.id = '{$value_RegistryPackage_id}'";
                                    $ris = query_exec2($update_objectType, $connessione);
                                    writeSQLQuery($ris . ": " . $update_objectType);
                                    //$value_value= avoidHtmlEntitiesInterpretation($externalidentifier_node->get_attribute('value'));
                                    $value_value = $externalidentifier_node->get_attribute('value');
                                    if ($value_value == '') {
                                        $value_value = "NOT DECLARED";
                                    }
                                    $DB_array_externalidentifier_attributes['accessControlPolicy'] = $value_accessControlPolicy;
                                    $DB_array_externalidentifier_attributes['id'] = $value_id;
                                    $DB_array_externalidentifier_attributes['objectType'] = $value_objectType;
                                    $DB_array_externalidentifier_attributes['registryObject'] = $value_registryObject;
                                    $DB_array_externalidentifier_attributes['identificationScheme'] = $value_identificationScheme;
                                    $DB_array_externalidentifier_attributes['value'] = $value_value;
                                    //print_r($DB_array_externalidentifier_attributes);
                                    ##### SONO PRONTO A SCRIVERE NEL DB
                                    $INSERT_INTO_ExternalIdentifier = "INSERT INTO ExternalIdentifier (id,accessControlPolicy,objectType,registryObject,identificationScheme,value) VALUES ('" . trim($DB_array_externalidentifier_attributes['id']) . "','" . trim($DB_array_externalidentifier_attributes['accessControlPolicy']) . "','" . trim($DB_array_externalidentifier_attributes['objectType']) . "','" . trim($DB_array_externalidentifier_attributes['registryObject']) . "','" . trim($DB_array_externalidentifier_attributes['identificationScheme']) . "','" . trim(adjustString($DB_array_externalidentifier_attributes['value'])) . "')";
                                    $ris = query_exec2($INSERT_INTO_ExternalIdentifier, $connessione);
                                    writeSQLQuery($ris . ": " . $INSERT_INTO_ExternalIdentifier);
                                    $atna_value_index = trim($DB_array_externalidentifier_attributes['identificationScheme']);
                                    $atna_value[$atna_value_index] = trim(adjustString($DB_array_externalidentifier_attributes['value']));
                                    #### NODI FIGLI DI EXTERNALIDENTIFIER
                                    $externalidentifier_child_nodes = $externalidentifier_node->child_nodes();
                                    //print_r($name_node);
                                    for ($q = 0; $q < count($externalidentifier_child_nodes); $q++) {
                                        $externalidentifier_child_node = $externalidentifier_child_nodes[$q];
                                        $externalidentifier_child_node_tagname = $externalidentifier_child_node->node_name();
                                        if ($externalidentifier_child_node_tagname == 'Name') {
                                            $name_node = $externalidentifier_child_node;
                                            $DB_array_name = array();
                                            $LocalizedString_nodes = $name_node->child_nodes();
                                            //print_r($LocalizedString_nodes);
                                            for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                                                $LocalizedString_node = $LocalizedString_nodes[$p];
                                                //->node_name();
                                                $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                                                if ($LocalizedString_node_tagname == 'LocalizedString') {
                                                    $LocalizedString_charset = $LocalizedString_node->get_attribute('charset');
                                                    if ($LocalizedString_charset == '') {
                                                        $LocalizedString_charset = "UTF-8";
                                                    }
                                                    $LocalizedString_lang = $LocalizedString_node->get_attribute('lang');
                                                    if ($LocalizedString_lang == '') {
                                                        $LocalizedString_lang = $lang;
                                                    }
                                                    $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                                                    if ($LocalizedString_value == '') {
                                                        $LocalizedString_value = "NOT DECLARED";
                                                    }
                                                    $DB_array_name['charset'] = $LocalizedString_charset;
                                                    $DB_array_name['lang'] = $LocalizedString_lang;
                                                    $DB_array_name['value'] = $LocalizedString_value;
                                                }
                                                //END OF if($LocalizedString_node_tagname == 'LocalizedString')
                                            }
                                            //END OF for($p = 0;$p < count($val_list_node);$p++)
                                            //$value_parent = $id;
                                            $DB_array_name['parent'] = $value_id;
                                        }
                                    }
                                    //print_r($DB_array_name);
                                    ##### SONO PRONTO A SCRIVERE NEL DB
                                    $INSERT_INTO_Name = "INSERT INTO Name (charset,lang,value,parent) VALUES ('" . trim($DB_array_name['charset']) . "','" . trim($DB_array_name['lang']) . "','" . trim(adjustString($DB_array_name['value'])) . "','" . trim($DB_array_name['parent']) . "')";
                                    $ris = query_exec2($INSERT_INTO_Name, $connessione);
                                    writeSQLQuery($ris . ": " . $INSERT_INTO_Name);
                                }
                            }
                        }
                    }
                }
                //END OF if($RegistryPackage_child_node_tagname=='ExternalIdentifier')
            }
            //END OF for($k=0;$k<count($RegistryPackage_child_nodes);$k++)
            ################# FINE PROCESSO TUTTI I NODI FIGLI DI REGISTRYPACKAGE
        } else {
            $simbolic_RegistryPackage_id_fol = $RegistryPackage_node->get_attribute('id');
            $RegistryPackage_Fol_id_array[] = $simbolic_RegistryPackage_id_fol;
            $RegistryPackage_id_array[$simbolic_RegistryPackage_id_fol] = $value_RegistryPackage_id;
        }
    }
    //END OF for($index=0;$index<(count($dom_ebXML_RegistryPackage_node_array));$index++)
    $RegistryPackage_id_array['nodeRepresentation'] = $value_nodeRepresentation_assigned;
    //return $RegistryPackage_id_array;
    return array($RegistryPackage_id_array, $atna_value, $simbolic_RegistryPackage_id_array, $RegistryPackage_Fol_id_array);
}
function modifyMetadata($dom_ebXML, $ExtrinsicObject_node, $URI, $hash, $size, $namespacerim)
{
    #### ATTENZIONE NO include_once !!!
    include "config/REP_configuration.php";
    #### RICAVO ATTRIBUTO id DI ExtrinsicObject
    $ExtrinsicObject_id_attr = $ExtrinsicObject_node->get_attribute('id');
    #### FIGLI DI ExtrinsicObject
    $ExtrinsicObject_child_nodes = $ExtrinsicObject_node->child_nodes();
    $count = 0;
    for ($i = 0; $i < count($ExtrinsicObject_child_nodes); $i++) {
        ### SINGOLO NODO FIGLIO
        $ExtrinsicObject_child_node = $ExtrinsicObject_child_nodes[$i];
        ### TAGNAME DEL SINGOLO NODO FIGLIO
        $ExtrinsicObject_child_node_tagname = $ExtrinsicObject_child_node->node_name();
        if ($ExtrinsicObject_child_node_tagname == 'Classification' && $count == 0) {
            $next_node = $ExtrinsicObject_child_node;
            $count++;
        }
        //END OF if($ExtrinsicObject_child_node_tagname=='Classification')
        if ($ExtrinsicObject_child_node_tagname == 'ExternalIdentifier') {
            $externalidentifier_node = $ExtrinsicObject_child_node;
            $value_value = avoidHtmlEntitiesInterpretation($externalidentifier_node->get_attribute('value'));
            #### NODI FIGLI DI EXTERNALIDENTIFIER
            $externalidentifier_child_nodes = $externalidentifier_node->child_nodes();
            for ($q = 0; $q < count($externalidentifier_child_nodes); $q++) {
                $externalidentifier_child_node = $externalidentifier_child_nodes[$q];
                $externalidentifier_child_node_tagname = $externalidentifier_child_node->node_name();
                if ($externalidentifier_child_node_tagname == 'Name') {
                    $name_node = $externalidentifier_child_node;
                    $LocalizedString_nodes = $name_node->child_nodes();
                    for ($p = 0; $p < count($LocalizedString_nodes); $p++) {
                        $LocalizedString_node = $LocalizedString_nodes[$p];
                        //->node_name();
                        $LocalizedString_node_tagname = $LocalizedString_node->node_name();
                        if ($LocalizedString_node_tagname == 'LocalizedString') {
                            $LocalizedString_value = $LocalizedString_node->get_attribute('value');
                            if (strpos(strtolower(trim($LocalizedString_value)), strtolower('DocumentEntry.uniqueId'))) {
                                $ebxml_value = $value_value;
                            }
                        }
                    }
                }
            }
        }
        //END OF if($ExtrinsicObject_child_node_tagname=='ExternalIdentifier')
    }
    //END OF for($i=0;$i<(count($ExtrinsicObject_child_nodes));$i++)
    ########## CALCOLO URL DEL DOCUMENTO
    #### CREO IL NUOVO ELEMENTO SLOT
    $new_element_Slot = $dom_ebXML->create_element_ns($namespacerim, 'Slot', 'rim');
    $new_element_Slot->set_attribute("name", "URI");
    #### CREO IL NODO SLOT
    $new_node_Slot = $ExtrinsicObject_node->insert_before($new_element_Slot, $next_node);
    $ValueList_node = $dom_ebXML->create_element_ns($namespacerim, "ValueList", 'rim');
    $new_node_Slot->append_child($ValueList_node);
    $Value_node = $dom_ebXML->create_element_ns($namespacerim, "Value", 'rim');
    $ValueList_node->append_child($Value_node);
    #######################################################################
    #### MODIFICO IL DOM
    //$new_URI_node = $dom_ebXML->create_text_node($Document_URI);#<<=== URI
    $new_URI_node = $dom_ebXML->create_text_node($URI);
    #<<=== URI
    $Value_node->append_child($new_URI_node);
    ########################## FINE BLOCCO PER L'URI ########################
    ################# CALCOLO L'HASH DEL DOCUMENTO
    #### CREO IL NUOVO ELEMENTO SLOT
    $new_element_Slot = $dom_ebXML->create_element_ns($namespacerim, 'Slot', 'rim');
    $new_element_Slot->set_attribute("name", "hash");
    #### CREO IL NODO SLOT
    $new_node_Slot = $ExtrinsicObject_node->insert_before($new_element_Slot, $next_node);
    $ValueList_node = $dom_ebXML->create_element_ns($namespacerim, "ValueList", 'rim');
    $new_node_Slot->append_child($ValueList_node);
    $Value_node = $dom_ebXML->create_element_ns($namespacerim, "Value", 'rim');
    $ValueList_node->append_child($Value_node);
    #### MODIFICO IL DOM
    $new_HASH_node = $dom_ebXML->create_text_node($hash);
    #<<=== HASH
    $Value_node->append_child($new_HASH_node);
    //========================= FINE BLOCCO PER L'HASH ============================//
    ############### CALCOLO DEL SIZE
    #### CREO IL NUOVO ELEMENTO SLOT
    $new_element_Slot = $dom_ebXML->create_element_ns($namespacerim, 'Slot', 'rim');
    $new_element_Slot->set_attribute("name", "size");
    #### CREO IL NODO SLOT
    $new_node_Slot = $ExtrinsicObject_node->insert_before($new_element_Slot, $next_node);
    $ValueList_node = $dom_ebXML->create_element_ns($namespacerim, "ValueList", 'rim');
    $new_node_Slot->append_child($ValueList_node);
    $Value_node = $dom_ebXML->create_element_ns($namespacerim, "Value", 'rim');
    $ValueList_node->append_child($Value_node);
    #### MODIFICO IL DOM
    $new_SIZE_node = $dom_ebXML->create_text_node($size);
    #<<=== SIZE
    $Value_node->append_child($new_SIZE_node);
    //====================== FINE BLOCCO PER IL SIZE =========================//
    ##############################################################################
    return $dom_ebXML;
}