src/snac/server/ServerExecutor.php
/**
     * Parse EAC and return result
     *
     * Parses and EAC-CPF file given on the input and returns the SNAC JSON object
     * as well as any errors that occurred during the conversion process.
     *
     * @param string[] $input Input array from the Server object
     * @return string[] The response to send to the client
     */
Parse EAC and return result
Parses and EAC-CPF file given on the input and returns the SNAC JSON object
as well as any errors that occurred during the conversion process.

@param string[] $input Input array from the Server object
@return string[] The response to send to the client
Parse EAC and return result Parses and EAC - CPF file given on the input and returns the SNAC JSON object as well as any errors that occurred during the conversion process . @param string [] $input Input array from the Server object @return string [] The response to send to the client
public function parseEACCPFToConstellation($input) {
        if (!isset($input["file"]) || !isset($input["file"]["mime-type"]) || !isset($input["file"]["content"])) {
            throw new \snac\exceptions\SNACInputException("No EAC-CPF file specified", 400);
        }
        $file = base64_decode($input["file"]["content"]);
        if (!stristr($file, "<eac-cpf")) {
            throw new \snac\exceptions\SNACInputException("File does not have EAC-CPF tag specified", 400);
        }
        \libxml_use_internal_errors(true);
        $testDoc = \simplexml_load_string($file);
        $testXml = explode("\n", $file);
        if (!$testDoc) {
            $errorText = "";
            $errors = \libxml_get_errors();
            foreach ($errors as $error) {
                 $errorText .= \display_xml_error($error, $xml);
            }
            \libxml_clear_errors();
            throw new \snac\exceptions\SNACInputException("File is not correctly-formatted XML:\n".$errorText, 400);
        }
        $response = array();
        $localVocab = new \snac\util\LocalVocabulary();
        $localVocab->setConstellationStore($this->cStore);
        $parser = new \snac\util\EACCPFParser();
        $parser->setVocabulary($localVocab);
        $constellation = $parser->parse($file);
        $errors = $parser->getMissing();
        $response["constellation"] = $constellation->toArray();
        $response["unparsed"] = $errors;
        if (empty($errors))
            $response["result"] = "success";
        else
            $response["result"] = "failure";
        return $response;
    }
public function parseEACCPFToConstellation ( $ input ) { if ( ! isset ( $ input [ " file " ] ) || ! isset ( $ input [ " file " ] [ " mime-type " ] ) || ! isset ( $ input [ " file " ] [ " content " ] ) ) { throw new \ snac \ exceptions \ SNACInputException ( " No EAC-CPF file specified " , 400 ) ; } $ file = base64_decode ( $ input [ " file " ] [ " content " ] ) ; if ( ! stristr ( $ file , " <eac-cpf " ) ) { throw new \ snac \ exceptions \ SNACInputException ( " File does not have EAC-CPF tag specified " , 400 ) ; } \ libxml_use_internal_errors ( true ) ; $ testDoc = \ simplexml_load_string ( $ file ) ; $ testXml = explode ( " \n " , $ file ) ; if ( ! $ testDoc ) { $ errorText = " " ; $ errors = \ libxml_get_errors ( ) ; foreach ( $ errors as $ error ) { $ errorText .= \ display_xml_error ( $ error , $ xml ) ; } \ libxml_clear_errors ( ) ; throw new \ snac \ exceptions \ SNACInputException ( " File is not correctly-formatted XML: \n " . $ errorText , 400 ) ; } $ response = array ( ) ; $ localVocab = new \ snac \ util \ LocalVocabulary ( ) ; $ localVocab -> setConstellationStore ( $ this -> cStore ) ; $ parser = new \ snac \ util \ EACCPFParser ( ) ; $ parser -> setVocabulary ( $ localVocab ) ; $ constellation = $ parser -> parse ( $ file ) ; $ errors = $ parser -> getMissing ( ) ; $ response [ " constellation " ] = $ constellation -> toArray ( ) ; $ response [ " unparsed " ] = $ errors ; if ( empty ( $ errors ) ) $ response [ " result " ] = " success " ; else $ response [ " result " ] = " failure " ; return $ response ; }
Parse EAC and return result
 Parses and EAC-CPF file given on the input and returns the SNAC JSON object
 as well as any errors that occurred during the conversion process.
Parse EAC and return result Parses and EAC - CPF file given on the input and returns the SNAC JSON object as well as any errors that occurred during the conversion process .