<?php // Load the PHP library include_once '../../../../swordappclient.php'; include_once '../../utils.php'; // Store the values session_start(); // Try and deposit the multipart package $client = new SWORDAPPClient(); try { $response = $client->depositMultipart($_SESSION['durl'], $_SESSION['u'], $_SESSION['p'], $_SESSION['obo'], $_SESSION['filename'], 'http://purl.org/net/sword/package/SimpleZip', 'application/zip', $_SESSION['inprogress']); if ($response->sac_status != 201) { $error = 'Unable to deposit package. HTTP response code: ' . $response->sac_status . ' - ' . $response->sac_statusmessage; $_SESSION['error'] = $error; } else { $_SESSION['error'] = ''; } } catch (Exception $e) { $error = 'Unable to deposit package: ' . $e->getMessage(); $_SESSION['error'] = $error; header('Location: ../../get/sd/'); } // Show the response include '../../common/depositresponse.php';
} $testsdr = $testsac->servicedocument($testurl, $testuser, $testpw, $testobo); print "Received HTTP status code: " . $testsdr->sac_status . " (" . $testsdr->sac_statusmessage . ")\n"; if ($testsdr->sac_status == 200) { $testsdr->toString(); } print "\n\n"; } if (true) { print "About to deposit multipart file (" . $testmultipart . ") to " . $testdepositurl . "\n"; if (empty($testuser)) { print "As: anonymous\n"; } else { print "As: " . $testuser . "\n"; } $testdr = $testsac->depositMultipart($testdepositurl, $testuser, $testpw, $testobo, $testmultipart, $testpackaging, false); print "Received HTTP status code: " . $testdr->sac_status . " (" . $testdr->sac_statusmessage . ")\n"; if ($testdr->sac_status >= 200 || $testdr->sac_status < 300) { $testdr->toString(); } print "\n\n"; $edit_iri = $testdr->sac_edit_iri; $cont_iri = $testdr->sac_content_src; $edit_media = $testdr->sac_edit_media_iri; $statement_atom = $testdr->sac_state_iri_atom; $statement_ore = $testdr->sac_state_iri_ore; } if (false) { print "About to request Atom serialisation of the deposit statement from " . $statement_atom . "\n"; if (empty($testuser)) { print "As: anonymous\n";
private function _depositatommultipart() { $response = ''; try { $package = new PackagerAtomMultipart($this->config->item('easydeposit_uploadfiles_savedir'), $this->userid, $this->config->item('easydeposit_deposit_packages'), $this->userid . '.multipart'); foreach ($this->easydeposit_steps as $stepname) { if ($stepname == 'deposit') { break; } include_once APPPATH . 'controllers/' . $stepname . '.php'; $stepclass = ucfirst($stepname); call_user_func(array($stepclass, '_packagemultipart'), $package); } $package->create(); // Deposit the package $sac = new SWORDAPPClient(); $response = $sac->depositMultipart($_SESSION['depositurl'], $_SESSION['sword-username'], $_SESSION['sword-password'], $_SESSION['sword-obo'], $this->config->item('easydeposit_deposit_packages') . $this->userid . '.multipart', false); if ($response->sac_status >= 200 && $response->sac_status < 300) { $_SESSION['deposited-response'] = $response->sac_xml; $_SESSION['deposited-url'] = (string) $response->sac_id; } else { $error = 'Server returned status code: ' . $response->sac_status . "\n\n"; $error .= 'Server provided response: ' . $response->sac_xml; } } catch (Exception $e) { // Catch the exception for reporting $error = 'Error: ' . $e->getMessage() . "\n\n"; $error .= 'Deposit URL: ' . $_SESSION['depositurl'] . "\n"; $error .= 'Deposit username: '******'sword-username'] . "\n"; $error .= 'Package file: ' . $this->config->item('easydeposit_deposit_packages') . $this->userid . '.zip' . "\n"; if (!empty($response->sac_xml)) { $error .= "\n\nResponse:" . $response->sac_xml; } $_SESSION['deposited-response'] = $error; } // If there was an error, send it to the administrator if (!empty($error)) { $to = $this->config->item('easydeposit_supportemail'); $subject = 'Error with EasyDeposit system'; $headers = 'From: ' . $to . ' <' . $to . ">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; mail($to, $subject, $error, $headers); } }