src/snac/server/ServerExecutor.php
/**
     * Read Constellation
     *
     * Looks for a constellationid, arkid, or testid in the input, and then reads the constellation data and
     * creates a Constellation object.  The object is converted to an array and put in the response to send to the
     * user.
     *
     * If given a constellationid, it reads the constellation from the database.  If trying to read a constellation
     * without a published version, an exception is thrown.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACInputException
     * @return string[] The response to send to the client
     */
Read Constellation
Looks for a constellationid, arkid, or testid in the input, and then reads the constellation data and
creates a Constellation object.  The object is converted to an array and put in the response to send to the
user.

If given a constellationid, it reads the constellation from the database.  If trying to read a constellation
without a published version, an exception is thrown.

@param string[] $input Input array from the Server object
@throws \snac\exceptions\SNACInputException
@return string[] The response to send to the client
Read Constellation Looks for a constellationid arkid or testid in the input and then reads the constellation data and creates a Constellation object . The object is converted to an array and put in the response to send to the user . If given a constellationid it reads the constellation from the database . If trying to read a constellation without a published version an exception is thrown . @param string [] $input Input array from the Server object @throws \ snac \ exceptions \ SNACInputException @return string [] The response to send to the client
public function readConstellation(&$input) {
        $this->logger->addDebug("Reading constellation");
        $reponse = array();
        $constellation = null;
        try {
            $flags = 0;
            if (isset($input["type"]) && $input["type"] == "summary")
                $flags = \snac\server\database\DBUtil::$READ_ALL_BUT_RELATIONS_AND_META;
            else if (isset($input["type"]) && $input["type"] == "summary_meta")
                $flags = \snac\server\database\DBUtil::$READ_ALL_BUT_RELATIONS;
            $constellations = $this->readConstellationFromDatabase($input, false, $flags);
            if ($constellations === null) {
                throw new \snac\exceptions\SNACInputException("Constellation does not exist", 404);
            } else if (count($constellations) > 1) {
                $response["constellation"] = array();
                foreach ($constellations as $constellation) {
                    array_push($response["constellation"], $constellation->toArray());
                }
                $response["result"] = "success-notice";
                $response["message"] = [
                    "text" => "Please update your cache, the Constellation you requested has been split.",
                    "info" => [
                        "type" => "split"
                    ]
                ];
            } else {
                $constellation = $constellations[0];
                if (\snac\Config::$USE_NEO4J) {
                    $this->neo4J->checkHoldingInstitutionStatus($constellation);
                }
                $editable = false;
                $userStatus = $this->cStore->readConstellationUserStatus($constellation->getID());
                if ($this->user != null) {
                    if ($userStatus['userid'] == $this->user->getUserID() && $userStatus["status"] == 'locked editing') {
                        $editable = true;
                    }
                }
                if ($userStatus["status"] == "published" || $editable) {
                    $constellation->setStatus("editable");
                } else if ($this->hasPermission("Change Locks")) {
                    if ($userStatus["status"] == 'needs review') {
                        $constellation->setStatus("reviewable");
                    }
                    $editingUser = new \snac\data\User();
                    $editingUser->setUserID($userStatus["userid"]);
                    $editingUser = $this->uStore->readUser($editingUser);
                    if ($editingUser)
                        $response["editing_user"] = $editingUser->toArray();
                }
                $response["result"] = "success";
                if ((isset($input["arkid"]) && $input["arkid"] != $constellation->getArk()) ||
                    (isset($input["constellationid"]) && $input["constellationid"] != $constellation->getID())) {
                    $response["result"] = "success-notice";
                    $response["message"] = [
                        "text" => "Please update your cache, the Constellation you requested has been merged into "
                        . $constellation->getArk() . ".",
                        "info" => [
                            "type" => "merged",
                            "redirect" => $constellation->getArk()
                        ]
                    ];
                }
                $response["maybesame_count"] = $this->cStore->countMaybeSameConstellations($constellation->getID());
                $this->logger->addDebug("Finished checking constellation status against the user");
                $response["constellation"] = $constellation->toArray();
            }
            $this->logger->addDebug("Serialized constellation for output to client");
        } catch (Exception $e) {
            $response["error"] = $e;
            $response["result"] = "failure";
        }
        return $response;
    }
public function readConstellation ( & $ input ) { $ this -> logger -> addDebug ( " Reading constellation " ) ; $ reponse = array ( ) ; $ constellation = null ; try { $ flags = 0 ; if ( isset ( $ input [ " type " ] ) && $ input [ " type " ] == " summary " ) $ flags = \ snac \ server \ database \ DBUtil :: $ READ_ALL_BUT_RELATIONS_AND_META ; else if ( isset ( $ input [ " type " ] ) && $ input [ " type " ] == " summary_meta " ) $ flags = \ snac \ server \ database \ DBUtil :: $ READ_ALL_BUT_RELATIONS ; $ constellations = $ this -> readConstellationFromDatabase ( $ input , false , $ flags ) ; if ( $ constellations === null ) { throw new \ snac \ exceptions \ SNACInputException ( " Constellation does not exist " , 404 ) ; } else if ( count ( $ constellations ) > 1 ) { $ response [ " constellation " ] = array ( ) ; foreach ( $ constellations as $ constellation ) { array_push ( $ response [ " constellation " ] , $ constellation -> toArray ( ) ) ; } $ response [ " result " ] = " success-notice " ; $ response [ " message " ] = [ " text " => " Please update your cache, the Constellation you requested has been split. " , " info " => [ " type " => " split " ] ] ; } else { $ constellation = $ constellations [ 0 ] ; if ( \ snac \ Config :: $ USE_NEO4J ) { $ this -> neo4J -> checkHoldingInstitutionStatus ( $ constellation ) ; } $ editable = false ; $ userStatus = $ this -> cStore -> readConstellationUserStatus ( $ constellation -> getID ( ) ) ; if ( $ this -> user != null ) { if ( $ userStatus [ 'userid' ] == $ this -> user -> getUserID ( ) && $ userStatus [ " status " ] == 'locked editing' ) { $ editable = true ; } } if ( $ userStatus [ " status " ] == " published " || $ editable ) { $ constellation -> setStatus ( " editable " ) ; } else if ( $ this -> hasPermission ( " Change Locks " ) ) { if ( $ userStatus [ " status " ] == 'needs review' ) { $ constellation -> setStatus ( " reviewable " ) ; } $ editingUser = new \ snac \ data \ User ( ) ; $ editingUser -> setUserID ( $ userStatus [ " userid " ] ) ; $ editingUser = $ this -> uStore -> readUser ( $ editingUser ) ; if ( $ editingUser ) $ response [ " editing_user " ] = $ editingUser -> toArray ( ) ; } $ response [ " result " ] = " success " ; if ( ( isset ( $ input [ " arkid " ] ) && $ input [ " arkid " ] != $ constellation -> getArk ( ) ) || ( isset ( $ input [ " constellationid " ] ) && $ input [ " constellationid " ] != $ constellation -> getID ( ) ) ) { $ response [ " result " ] = " success-notice " ; $ response [ " message " ] = [ " text " => " Please update your cache, the Constellation you requested has been merged into  " . $ constellation -> getArk ( ) . " . " , " info " => [ " type " => " merged " , " redirect " => $ constellation -> getArk ( ) ] ] ; } $ response [ " maybesame_count " ] = $ this -> cStore -> countMaybeSameConstellations ( $ constellation -> getID ( ) ) ; $ this -> logger -> addDebug ( " Finished checking constellation status against the user " ) ; $ response [ " constellation " ] = $ constellation -> toArray ( ) ; } $ this -> logger -> addDebug ( " Serialized constellation for output to client " ) ; } catch ( Exception $ e ) { $ response [ " error " ] = $ e ; $ response [ " result " ] = " failure " ; } return $ response ; }
Read Constellation
 Looks for a constellationid, arkid, or testid in the input, and then reads the constellation data and
 creates a Constellation object.
Read Constellation Looks for a constellationid arkid or testid in the input and then reads the constellation data and creates a Constellation object .
// Send back multiple constellations // Normal condition (one constellation)