public static SwordError throwSpecialSwordErrorWithoutStackTrace(String SwordUriRegistryError, String error) { if (SwordUriRegistryError == null) { SwordUriRegistryError = UriRegistry.ERROR_BAD_REQUEST; } if (error == null) { error = "UNKNOWN"; } SwordError swordError = new SwordError(SwordUriRegistryError, error); StackTraceElement[] emptyStackTrace = new StackTraceElement[0]; swordError.setStackTrace(emptyStackTrace); return swordError; }
public static DepositReceipt buildDepositReceipt(IRI iri) throws SwordError { DepositReceipt depositReceipt = new DepositReceipt(); depositReceipt.setEditIRI(iri); return depositReceipt; }
public static void checkIsObject(MCRBase retrievedMCRBase) throws SwordError { if (retrievedMCRBase instanceof MCRDerivate) { throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, HttpServletResponse.SC_BAD_REQUEST, "You cannot directly change Metadata of a Derivate!"); } }
public void authentication(AuthCredentials credentials) throws SwordAuthException { if (!exists(credentials.getUsername())) { throw new SwordAuthException("Wrong login data!"); } MCRUser mcrUser = login(credentials.getUsername(), credentials.getPassword()); if (mcrUser == null) { throw new SwordAuthException("Wrong login data!"); } } }
@Override public void init() throws ServletException { super.init(); this.api = new ServiceDocumentAPI(serviceDocumentManagerImpl, swordConfigurationImpl); }
@Override public void init() throws ServletException { super.init(); // load the api this.api = new MediaResourceAPI(mediaResourceManagerImpl, swordConfigurationImpl); }
@Override public void init() throws ServletException { super.init(); // load the container manager implementation this.cm = containerManagerImpl; // load the statement manager implementation this.sm = statementManagerImpl; // initialise the underlying servlet processor this.api = new ContainerAPI(this.cm, this.sm, this.config); }
@Override public void init() throws ServletException { super.init(); this.api = new CollectionAPI(collectionListManagerImpl, collectionDepositManagerImpl, this.config); }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { this.api.get(req, resp); }
@Override public void init() throws ServletException { super.init(); // load the container manager implementation this.sm = statementManagerImpl; // initialise the underlying servlet processor this.statementApi = new StatementAPI(this.sm, this.config); }
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { prepareRequest(req, resp); api.get(req, resp); afterRequest(req, resp); }
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { prepareRequest(req, resp); api.get(req, resp); afterRequest(req, resp); }
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { prepareRequest(req, resp); api.put(req, resp); afterRequest(req, resp); }
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { prepareRequest(req, resp); api.delete(req, resp); afterRequest(req, resp); } }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { this.statementApi.get(req, resp); }
public static SwordError throwRegularSwordErrorWithoutStackTrace(String error) { if (error == null) { error = "UNKNOWN"; } SwordError swordError = new SwordError(error); StackTraceElement[] emptyStackTrace = new StackTraceElement[0]; swordError.setStackTrace(emptyStackTrace); return swordError; }
public static void throwObjectDoesNotExist(String objectIdString) throws SwordError { throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, HttpServletResponse.SC_NOT_FOUND, "The object '" + objectIdString + "' does not exist!"); }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { prepareRequest(req, resp); api.get(req, resp); afterRequest(req, resp); } }
/** * @todo get rid of this method */ private SwordError returnEarly(String error) { SwordError swordError = new SwordError(error); StackTraceElement[] emptyStackTrace = new StackTraceElement[0]; swordError.setStackTrace(emptyStackTrace); return swordError; }
@Override public DepositReceipt replaceMediaResource(String uri, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException { /** * @todo: Perhaps create a new version of a dataset here? * * "The server MUST effectively replace all the existing content in the * item, although implementations may choose to provide versioning or * some other mechanism for retaining the overwritten content." -- * http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_editingcontent_binary * * Also, if you enable this method, think about the SwordError currently * being returned by replaceOrAddFiles with shouldReplace set to true * and an empty zip uploaded. If no files are unzipped the user will see * a error about this but the files will still be deleted! */ throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Replacing the files of a dataset is not supported. Please delete and add files separately instead."); }