public RemoteObjectSource(ServiceInfo serviceInfo) throws ServiceException, IOException { FedoraClient fc = new FedoraClient(serviceInfo.getBaseUrlString(), serviceInfo.getUsername(), serviceInfo.getPassword()); apia = fc.getAPIAMTOM(); apim = fc.getAPIMMTOM(); fc.shutdown(); }
@Override public String construct() { try { return fc.uploadFile(file); } catch (IOException e) { thrownException = e; return ""; } } };
/** * Get an HTTP resource with the response as an InputStream, given a URL. * This method will follow redirects if FOLLOW_REDIRECTS is true. Note that * if the HTTP response has no body, the InputStream will be empty. The * success of a request can be checked with getResponseCode(). Usually * you'll want to see a 200. See * http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for other codes. * * @param url * A URL that we want to do an HTTP GET upon * @param failIfNotOK * boolean value indicating if an exception should be thrown if we do * NOT receive an HTTP 200 response (OK) * @return HttpInputStream the HTTP response * @throws IOException */ public HttpInputStream get(URL url, boolean failIfNotOK) throws IOException { return get(url, failIfNotOK, FOLLOW_REDIRECTS); }
@Before public void setUp() throws Exception { apia = s_client.getAPIAMTOM(); apim = s_client.getAPIMMTOM(); }
@Before public void setUp() throws Exception { FedoraClient client = getFedoraClient(); apia = client.getAPIAMTOM(); apim = client.getAPIMMTOM(); client.shutdown(); }
FedoraClient fc = new FedoraClient(baseURL, user, pass); String serverVersion = fc.getServerVersion(); FedoraClient.getCompatibleServerVersions(); if (!compatibleVersions.contains(serverVersion)) { StringBuffer endText = new StringBuffer(); Administrator.APIA = fc.getAPIAMTOM(); Administrator.APIM = fc.getAPIMMTOM();
public void init(String host, String port, String username, String password, String batch, String batches, String threads, String outputFileLocation, String context) throws Exception { FedoraClient fedoraClient = new FedoraClient(baseURL, username, password); apim = fedoraClient.getAPIMMTOM(); fedoraClient.shutdown();
/** * Construct an uploader to a certain repository as a certain user. */ public Uploader(String protocol, String host, int port, String context, String user, String pass) throws IOException { String baseURL = protocol + "://" + host + ":" + port + "/" + context; fc = new FedoraClient(baseURL, user, pass); }
try { fedora = new FedoraClient( fedoraUrl, fedoraUsername, fedoraPassword); fedora.SOCKET_TIMEOUT_SECONDS = fedoraTimeout; String version = fedora.getServerVersion(); FedoraAPIM apim = fedora.getAPIM(); if (firstConnection) { log.info("API-M access testing... {} second timeout",
FedoraClient fc = new FedoraClient(baseURL, user, pass); AutoFinder finder = new AutoFinder(fc.getAPIAMTOM()); fc.shutdown();
private void removeObjectSpecificPolicies() { try { admin.getAPIMMTOM().purgeObject("demo:ObjSpecificTest", "", false); } catch (Exception e) { throw new RuntimeException("Failure removing object-specific " + "policies", e); } }
@Before public void setUp() throws Exception { apia = s_client.getAPIAMTOM(); }
try { post = new HttpPost(getUploadURL()); post.getParams().setParameter("Connection", "Keep-Alive"); HttpResponse response = getHttpClient().execute(post); int responseCode = response.getStatusLine().getStatusCode(); String body = null; throw new IOException("Upload failed: " + response.getStatusLine().getReasonPhrase() + ": " + replaceNewlines(body, " ")); } else { return replaceNewlines(body, "");
return fc.uploadFile(file); } else { + fc.getUploadURL(); Dimension d = Administrator.PROGRESS.getSize(); Administrator.PROGRESS.setString(msg);
fedora.getAPIM().modifyDatastreamByValue( tempURI = fedora.uploadFile(tempFile); fedora.getAPIM().modifyDatastreamByReference( tempURI = fedora.uploadFile(tempFile); fedora.getAPIM().addDatastream(
@After public void tearDown() throws Exception { m_client.getAPIMMTOM().purgeObject(PID, "Cleanup", false); m_client.shutdown(); }
private void reloadPolicies() { System.out.println("Reloading Policies..."); try { FedoraClient client = new FedoraClient(ServerUtility.getBaseURL(getProtocol()), getUsername(), getPassword()); client.reloadPolicies(); System.out.println(" Done Reloading Policies"); } catch (Exception e) { throw new RuntimeException(e); } }
private String upload() throws Exception { String url = fedoraClient.getUploadURL(); HttpPost post = new HttpPost(url); post.setHeader(HttpHeaders.CONNECTION, "Keep-Alive"); post.setHeader(HttpHeaders.TRANSFER_ENCODING, "chunked"); MultipartEntity entity = new MultipartEntity(); entity.addPart("file", new InputStreamBody(new SizedInputStream(), "file")); post.setEntity(entity); HttpClient client = fedoraClient.getHttpClient(); HttpResponse response = null; try { response = client.execute(post); int status = response.getStatusLine().getStatusCode(); String body = EntityUtils.toString(response.getEntity()); if (status != HttpStatus.SC_CREATED) { throw new IOException("Upload failed: " + response.getStatusLine().getReasonPhrase() + ": " + replaceNewlines(body, " ")); } else { body = body.replaceAll("\r", "").replaceAll("\n", ""); return body; } } finally { if (response != null && response.getEntity() != null) { response.getEntity().getContent().close(); } } }
HttpClient client = getHttpClient(followRedirects, followRedirects); HttpGet getMethod = new HttpGet(urlString); HttpInputStream in = new HttpInputStream(client, getMethod); return get(location, true, false); } else { try {