001/* 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.fcrepo.migration; 017 018import java.io.InputStream; 019 020/** 021 * An interface representing all of the high-level fedora 4 operations 022 * needed by the migration utility. 023 * 024 * @author Mike Durbin 025 */ 026public interface Fedora4Client { 027 028 /** 029 * Determines if a resource exists. 030 * @param path the path to the resource 031 * @return true if it exists, false otherwise 032 */ 033 public boolean exists(String path); 034 035 /** 036 * Creates a new resource at the given path. 037 * @param path the path to the new resource 038 */ 039 public void createResource(String path); 040 041 /** 042 * Gets the repository URL (to which paths can be appended to reference resources). 043 * @return the repository URL 044 */ 045 public String getRepositoryUrl(); 046 047 /** 048 * Creates or updates a non-RDF resource that points to external content at the given URL. 049 * @param path the path of the resource to be created 050 * @param url the URL at which the external content is hosted 051 */ 052 public void createOrUpdateRedirectNonRDFResource(String path, String url); 053 054 /** 055 * Creates or updates a non-RDF resource. 056 * @param path the path of the resource to be modified/created 057 * @param content the non-RDF content 058 * @param contentType the mime type of the content 059 */ 060 public void createOrUpdateNonRDFResource(String path, InputStream content, String contentType); 061 062 /** 063 * Creates a version snapshot for the resource (or graph) at the given path. 064 * @param path the path of the resource to be versioned 065 * @param versionId a label for the version 066 */ 067 public void createVersionSnapshot(String path, String versionId); 068 069 /** 070 * Updates properties on a resource. 071 * @param path the resource whose properties are to be updated. 072 * @param sparqlUpdate the sparql update statements to be applied 073 */ 074 public void updateResourceProperties(String path, String sparqlUpdate); 075 076 /** 077 * Updates properties on a non-RDF resource. 078 * @param path the resource whose properties are to be updated. 079 * @param sparqlUpdate the sparql update statements to be applied 080 */ 081 public void updateNonRDFResourceProperties(String path, String sparqlUpdate); 082 083 /** 084 * Creates a placeholder resource at the given path (or at a server-assigned path, 085 * if no path is given) if no resource exists at that path. If a resource already 086 * exists, this method returns the path to that resource which may or may not be 087 * a placeholder. If none exists, this method creates a new resource that should 088 * should be distinguishable from resources that have already been migrated as well 089 * as resources created using another process. 090 * @param path a path at which to create a placeholder resource (or null to create 091 * a placeholder resource at a server-assigned path). 092 * @return the path of the placeholder resource that was created 093 */ 094 public String createPlaceholder(String path); 095 096 /** 097 * Creates a placeholder non-RDF resource at the given path (or at a server-assigned 098 * path, if no path is given) if no resource exists at that path. If a resource 099 * already exists, this method returns the path to that resource which may or may not 100 * be a placeholder. If none exists, this method creates a new resource that should 101 * should be distinguishable from resources that have already been migrated as well 102 * as resources created using another process. 103 * @param path a path at which to create a placeholder resource (or null to create 104 * a placeholder resource at a server-assigned path). 105 * @return the path of the placeholder resource that was created 106 */ 107 public String createNonRDFPlaceholder(String path); 108 109 /** 110 * Determines whether the resource at the given path is a placeholder or not. 111 * @param path a path of a resource (expected to exist) 112 * @return true if it's a placeholder, false otherwise 113 */ 114 public boolean isPlaceholder(String path); 115 116}