示例#1
0
function checkwriteable($pdphandler, $user, $item)
{
    $subject = new Subject(Subject::SUBJECT_CATEGORY_DEFAULT);
    $subject->getAttributes()->add(new Attribute(new Uri(SubjectIdentifier::SUBJECT_ID), new Uri(DataTypes::STRING), StringAttribute::getInstance($user)));
    $resource = new Resource();
    $resource->getAttributes()->add(new Attribute(new Uri(ResourceIdentifier::RESOURCE_ID), new Uri(DataTypes::STRING), StringAttribute::getInstance($item)));
    $writeaction = new Action();
    $writeaction->getAttributes()->add(new Attribute(new Uri(ActionIdentifier::ACTION_ID), new Uri(DataTypes::STRING), StringAttribute::getInstance('info:escidoc/names:aa:1.0:action:update-item')));
    $writerequest = new Request($resource, $writeaction);
    $writerequest->add($subject);
    $requestarray = array($writerequest);
    $requests = new Requests();
    $requests->addAll($requestarray);
    $pdpresults = $pdphandler->evaluate($requests);
    if (!$pdpresults->get(0)->getDecision() === Decision::PERMIT) {
        throw new Exception("You are not allowed to update the dataset");
    }
}
示例#2
0
文件: doi.php 项目: ulbricht/pmdmeta
session_start();
try {
    if (!isset($_SESSION["eSciDocUserHandle"])) {
        throw new Exception("You must be logged in!");
    }
    $_SESSION["itemhandler"] = new ItemHandler(new Net_URL($escidoccoreservice));
    $_SESSION["itemhandler"]->setHandle($_SESSION["eSciDocUserHandle"]);
    $_SESSION["userhandler"] = new UserHandler(new Net_URL($escidoccoreservice));
    $_SESSION["userhandler"]->setHandle($_SESSION["eSciDocUserHandle"]);
    $_SESSION["pdphandler"] = new PDPHandler(new Net_URL($escidoccoreservice));
    $_SESSION["pdphandler"]->setHandle($_SESSION["eSciDocUserHandle"]);
    $user = $_SESSION["userhandler"]->retrieveCurrentUser();
    $escidocitemid = $_REQUEST["item"];
    $targeturl = $_REQUEST["dataciteurl"];
    $registermode = $_REQUEST["dataciteregistry"];
    $subject = new Subject(Subject::SUBJECT_CATEGORY_DEFAULT);
    $subject->getAttributes()->add(new Attribute(new Uri(SubjectIdentifier::SUBJECT_ID), new Uri(DataTypes::STRING), StringAttribute::getInstance($user->getObjid())));
    $resource = new Resource();
    $resource->getAttributes()->add(new Attribute(new Uri(ResourceIdentifier::RESOURCE_ID), new Uri(DataTypes::STRING), StringAttribute::getInstance($escidocitemid)));
    $writeaction = new Action();
    $writeaction->getAttributes()->add(new Attribute(new Uri(ActionIdentifier::ACTION_ID), new Uri(DataTypes::STRING), StringAttribute::getInstance('info:escidoc/names:aa:1.0:action:update-item')));
    $writerequest = new Request($resource, $writeaction);
    $writerequest->add($subject);
    $requestarray[0] = $writerequest;
    $requests = new Requests();
    $requests->addAll($requestarray);
    //    echo DOMMapper::marshal($requests);
    $pdpresults = $_SESSION["pdphandler"]->evaluate($requests);
    if ($pdpresults->get(0)->getDecision() !== Decision::PERMIT) {
        throw new Exception("To register a DOI you need write access to the dataset.");
    }