SWORD will only accept deposits on the URL configured in dspace.cfg
-------------------------------------------------------------------

                 Key: DS-598
                 URL: http://jira.dspace.org/jira/browse/DS-598
             Project: DSpace 1.x
          Issue Type: Bug
          Components: DSpace API
            Reporter: Graham Triggs


SWORDURLManager.getDSpaceObject() calls getBaseDepositUrl() to get the base url 
to strip from the deposit location, in order to retrieve the handle.

If the deposit is attempted on any url that is not either exactly as 
configured, or exactly the same length as the url generated from the dspace.url 
configuration, then the SWORD service will throw an exception saying "The 
deposit URL does not resolve to a valid deposit target" (as the retrieved 
handle will not actually be a valid handle).

Alternate version of method:

        public DSpaceObject getDSpaceObject(Context context, String location)
                throws DSpaceSWORDException, SWORDErrorException
        {
                try
                {
                        URL baseUrl    = new URL(this.getBaseDepositUrl());
                        URL depositUrl = new URL(location);
                        
                        String basePath    = baseUrl.getPath();
                        String depositPath = depositUrl.getPath();
                        
                        if (basePath.length() == depositPath.length())
                        {
                                throw new 
SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is 
incomplete");
                        }
                        String handle = 
depositPath.substring(basePath.length());
                        if (handle.startsWith("/"))
                        {
                                handle = handle.substring(1);
                        }
                        if ("".equals(handle))
                        {
                                throw new 
SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is 
incomplete");
                        }

                        DSpaceObject dso = 
HandleManager.resolveToObject(context, handle);

                        if (!(dso instanceof Collection) && !(dso instanceof 
Item))
                        {
                                throw new 
SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL does not 
resolve to a valid deposit target");
                        }

                        return dso;
                }
                catch (SQLException e)
                {
                        // log.error("Caught exception:", e);
                        throw new DSpaceSWORDException("There was a problem 
resolving the collection", e);
                } catch (MalformedURLException e) {
                        throw new 
SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The deposit URL is 
incomplete");
                }
        }


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.dspace.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to