Developer Information

  Java Documentation (Version 3.0.4)
  Source Code  
Examples for API functionality

e!DAL need a configuration and authenticated subject as basis for the mounting the actual back-end implementation.

EdalConfiguration configuration = new EdalConfiguration("", "", "10.5072",
		new InternetAddress("scientific_reviewer@mail.com"),
		new InternetAddress("substitute_reviewer@mail.com"),
		new InternetAddress("managing_reviewer@mail.com"),
		new InternetAddress("root@mail.com"));

PrimaryDataDirectory rootDirectory = DataManager.getRootDirectory(
		EdalHelpers.getFileSystemImplementationProvider(false, configuration), EdalHelpers.authenticateWinOrUnixOrMacUser());

e!DAL need a Subject to authenticate a user. The EdalHelpers class provide some convenient methods for several login modules.

/* use Windows or Unix or MAC login module */
	Subject osSubject = EdalHelpers.authenticateWinOrUnixOrMacUser();

/* use Kerberos login module with IPK realm and kdc */
	Subject ipkSubject = EdalHelpers.authenticateIPKKerberosUser("username");

/* use Google+ login module */
	Subject googleSubject = EdalHelpers.authenticateNewGoogleUser("httpProxyHost", httpProxyPort);

/* use ORCID login module */
	Subject orcidSubject = EdalHelpers.authenticateORCIDUser("httpProxyHost", httpProxyPort);

This example show how to create a new PrimaryDataDirectory or PrimaryDataFile.

PrimaryDataDirectory rootDirectory = DataManager.getRootDirectory(mountPoint, mySubject);

/* create new sub directory */
	PrimaryDataDirectory myDirectory = rootDirectory.createPrimaryDataDirectory("directory");

/* create new file in sub directory */
	PrimaryDataFile myFile = myDirectory.createPrimaryDataFile("file");

This example show how to get the MetaData Object from a PrimaryDataDirectory or PrimaryDataFile.

/* output of a PrimaryDataDirectory */
	MetaData directoryMetaData = myDirectory.getMetaData();
	System.out.println(directoryMetaData);

/* output of a PrimaryDataFile */
	MetaData fileMetaData = myFile.getMetaData();
	System.out.println(fileMetaData);

This example show how to create a new PrimaryDataEntityVersion for a PrimaryDataEntity by creating a new MetaData set.

/* create new MetaData object from ImplementationProvider or get Metadata from exiting entity */
  MetaData metadata = myImplementationProvider.createMetaDataInstance();
  MetaData metadata = myEntity.getMetaData();

/* set new metadata values */
  metadata.setElementValue(EnumDublinCoreElements.TITLE, new UntypedData("The e!DAL API"));
  metadata.setElementValue(EnumDublinCoreElements.DESCRIPTION, new UntypedData("e!DAL Poster"));

/* set metadata generate automatically a new version for this object */
  myEntity.setMetaData(metadata);

This example show how to store a data stream to a PrimaryDataFile.

/* create new PrimaryDataFile */

	PrimaryDataFile file = rootDirectory.createPrimaryDataFile("file");
	File inputFile = new File("text_file.txt");
	FileInputStream in = new FileInputStream(inputFile);

/* store data stream of "text_file.txt" create automatically, a new version of the PrimaryDataFile 'file' */

	file.store(in);

This example show how to read the data stream of a PrimaryDataFile.

/* get PrimaryDataFile */

	PrimaryDataFile file = (PrimaryDataFile) rootDirectory.getPrimaryDataEntity("file");
	File outputFile = new File("output_file.txt");
	FileOutputStream out = new FileOutputStream(outputFile);

/* read data stream of the latest version of PrimaryDataFile 'file' save data to "output_file.txt" */

	file.read(out);

This example show how to store a data stream to a PrimaryDataFile.

/* search for a specified object name */
	List<PrimaryDataEntity> results = directory.searchByDublinCoreElement(EnumDublinCoreElements.TITLE, new UntypedData("*my_title*"), true, true);

/* search over a complete MetaData set */
	List<PrimaryDataEntity> results = directory.searchByMetaData(myMetaData, true, true);

/* search for a specified publication status */
	List<PrimaryDataEntity> results = directory.searchByPublicationStatus(PublicationStatus.ACCEPTED);

/* search for a specified keyword */
	List<PrimaryDataEntity> results = directory.searchByKeyword("my_keyword", true, true);
Examples for Publication Workflow

Set the needed metadata attributes for the data entities you want ot publish.

MetaData metadata = directory.getMetaData();

// creator
	metadata.setElementValue(EnumDublinCoreElements.CREATOR,
			new NaturalPerson("Daniel", "Arend", "Gatersleben", "06566", "Germany"));

// publisher
	metadata.setElementValue(EnumDublinCoreElements.PUBLISHER,
			new LegalPerson("IPK Gatersleben", "Gatersleben", "06466", "Germany"));
	metadata.setElementValue(EnumDublinCoreElements.SUBJECT,
			new UntypedData("roots, hordeum vulgare, protein analysis, salinity stress"));

// set the new (changed) metadata
	directory.setMetaData(metadata);

This example show how to request the publication of a data entity (file/directory)

// add a DOI reference; note: an entity may have several different public resolvable references
directory.addPublicReference(PersistentIdentifier.DOI);

// apply to publish all references
directory.getCurrentVersion().setAllReferencesPublic(new InternetAddress("applicant@mail.de"));

This example show how to get the MetaData Object from a PrimaryDataDirectory or PrimaryDataFile.

// wait for application result
JOptionPane.showMessageDialog(null, "Continue");
// or basicly continue with your code, because the applicant will get informed by email

// print the DOI and the URL
System.out.println(directory.getCurrentVersion().getPublicReference(PersistentIdentifier.DOI));
Examples for Server-Client functionality

The initiation of an e!DAL server instance is very similar to run a local e!DAL instance. You additional add some RMI related parameter.

/* construct a default EdalConfiguration*/
EdalConfiguration configuration = new EdalConfiguration("dataCiteUserName", "dataCitePassword", "dataCitePrefix",
		new InternetAddress("scientificReviever@mail.de"),
		new InternetAddress("substituteReviever@mail.de"),
		new InternetAddress("managingReviever@mail.de"),
		new InternetAddress("root@mail.de"));

/* startup server using parameter from EdalConfiguration and data/registry TCP port, flag to clean existing mount point or re-mount, and flag to activate/deactivate RMI logger */

EdalServer.startServer(configuration, EdalServer.REGISTRY_PORT, EdalServer.DATA_PORT, false, true);

After starting the e!DAL server a client can establish a connect to the server using the DataManagerClient as proxy. As parameter, an Authentication object must be provided, which hold all necessary authentication token. Over RMI you can use the same functions than provided in the stand-alone version.

/* construct an Authentication object, which holds all required authentication information*/
Authentication auth = new Authentication(EdalHelpers.authenticateWinOrUnixUser());

/* connect client with e!DAL server specify server port, server name and the authentication object */
DataManagerClient client = new DataManagerClient(1099, "remotehost", auth );

/* get root directory */
ClientPrimaryDataDirectory rootDirectory = myClient.getRootDirectory();