src/de/uka/ipd/idaho/goldenGateServer/imi/GoldenGateIMI.java
/**
	 * Schedule a document import from a URL.
	 * @param mimeType the MIME type of the document
	 * @param url the URL to import from
	 * @param attributes additional document attributes
	 * @param owner the owner of the import
	 */
Schedule a document import from a URL.
@param mimeType the MIME type of the document
@param url the URL to import from
@param attributes additional document attributes
@param owner the owner of the import
Schedule a document import from a URL . @param mimeType the MIME type of the document @param url the URL to import from @param attributes additional document attributes @param owner the owner of the import
public void scheduleImport(String mimeType, URL url, Attributed attributes, ImiDocumentImportOwner owner) {
		ImiDocumentImport idi = new ImiDocumentImport(mimeType, url, owner);
		if (owner != null) 
			this.registerImportOwner(owner);
		String urlString = url.toString();
		idi.setAttribute(ImDocument.DOCUMENT_SOURCE_LINK_ATTRIBUTE, urlString);
		urlString = urlString.substring(urlString.lastIndexOf('/') + "/".length());
		if (urlString.indexOf('.') == -1) {}
		else if (urlString.toLowerCase().endsWith(".html")) {}
		else if (urlString.toLowerCase().endsWith(".htm")) {}
		else if (urlString.toLowerCase().endsWith(".shtml")) {}
		else if (urlString.toLowerCase().endsWith(".shtm")) {}
		else if (urlString.toLowerCase().endsWith(".xhtml")) {}
		else if (urlString.toLowerCase().endsWith(".xhtm")) {}
		else if (urlString.toLowerCase().endsWith(".xml")) {}
		else idi.setAttribute(DOCUMENT_NAME_ATTRIBUTE, urlString);
		if (attributes != null)
			AttributeUtils.copyAttributes(attributes, idi);
		String docId;
		try {
			InputStream docUrlIn = new BufferedInputStream(new ByteArrayInputStream(url.toString().getBytes()));
			DataHashOutputStream docHashOut = new DataHashOutputStream(new OutputStream() {
				public void write(int b) throws IOException {}
			});
			byte[] buffer = new byte[1024];
			for (int r; (r = docUrlIn.read(buffer, 0, buffer.length)) != -1;)
				docHashOut.write(buffer, 0, r);
			docHashOut.flush();
			docHashOut.close();
			docUrlIn.close();
			docId = docHashOut.getDataHash();
		}
		catch (IOException ioe) {
			docId = Gamta.getAnnotationID();
		}
		idi.setDataId(docId);
		this.importHandler.enqueueDataAction(docId, idi.getArguments());
	}
public void scheduleImport ( String mimeType , URL url , Attributed attributes , ImiDocumentImportOwner owner ) { ImiDocumentImport idi = new ImiDocumentImport ( mimeType , url , owner ) ; if ( owner != null ) this . registerImportOwner ( owner ) ; String urlString = url . toString ( ) ; idi . setAttribute ( ImDocument . DOCUMENT_SOURCE_LINK_ATTRIBUTE , urlString ) ; urlString = urlString . substring ( urlString . lastIndexOf ( '/' ) + "/" . length ( ) ) ; if ( urlString . indexOf ( '.' ) == - 1 ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".html" ) ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".htm" ) ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".shtml" ) ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".shtm" ) ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".xhtml" ) ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".xhtm" ) ) { } else if ( urlString . toLowerCase ( ) . endsWith ( ".xml" ) ) { } else idi . setAttribute ( DOCUMENT_NAME_ATTRIBUTE , urlString ) ; if ( attributes != null ) AttributeUtils . copyAttributes ( attributes , idi ) ; String docId ; try { InputStream docUrlIn = new BufferedInputStream ( new ByteArrayInputStream ( url . toString ( ) . getBytes ( ) ) ) ; DataHashOutputStream docHashOut = new DataHashOutputStream ( new OutputStream ( ) { public void write ( int b ) throws IOException { } } ) ; byte [ ] buffer = new byte [ 1024 ] ; for ( int r ; ( r = docUrlIn . read ( buffer , 0 , buffer . length ) ) != - 1 ; ) docHashOut . write ( buffer , 0 , r ) ; docHashOut . flush ( ) ; docHashOut . close ( ) ; docUrlIn . close ( ) ; docId = docHashOut . getDataHash ( ) ; } catch ( IOException ioe ) { docId = Gamta . getAnnotationID ( ) ; } idi . setDataId ( docId ) ; this . importHandler . enqueueDataAction ( docId , idi . getArguments ( ) ) ; }
Schedule a document import from a URL.
Schedule a document import from a URL .
// for good measures ... might have been reloaded dynamically or something