Code example for URI

Methods: getPathtoString

0
 
    private DigitalObjectRefBean findDOinDataRegistry( String id ) throws FileNotFoundException {
        // Attempt to look-up in the data registry. 
        URI domUri = null;
        try { 
            domUri = new URI( id );
        } catch (URISyntaxException e) {
            throw new FileNotFoundException("Could not find file " + id);
        } 
        // Got a URI, is it owned? 
        if( this.dataReg.hasDigitalObjectManager(domUri)) {
            try { 
            	//get the digital object with it's original content 
            	this.log.info("Retrieving Digital Object at " + domUri);
                DigitalObject digitalObject = this.dataReg.retrieve(domUri);
                // FIXME This is a duplicate of some PDURI logic, but there are two PDURI classes, oddly! 
                String leafname = domUri.getPath();
                // Strip any trailing slash: 
                if( leafname.endsWith("/") ) {
                    leafname = leafname.substring(0, leafname.length()-1);
                } 
                // Strip any upper path info: 
                if( leafname.contains("/") ) 
                { 
                    // Strip any directory path information. 
                    leafname = leafname.substring(leafname.lastIndexOf("/") + 1);
                } 
                return new DigitalObjectRefBean(leafname, domUri.toString(), domUri, digitalObject);
            } catch (DigitalObjectNotFoundException e) {
                throw new FileNotFoundException("Could not find file " + id);
            } 
        } 
		throw new FileNotFoundException("Could not find file " + id);