Class MyDataEnvironmentManager

java.lang.Object
de.fraunhofer.iese.mydata.MyDataEnvironmentManager

public final class MyDataEnvironmentManager extends Object
MyDataEnvironmentManager handles the IMyDataEnvironment, whether it is local or cloud.

Simple usage example (local-mode, manual init/config):

   
     MyDataEnvironmentManager.constructDefaultEnvironment().initializeLocal(new SolutionId("urn:solution:mysolution"), "Europe/Berlin", 4, true, null);
     IMyDataEnvironment myDataEnvironment = MyDataEnvironmentManager.getDefaultEnvironment();
     myDataEnvironment.registerLocalPxp("mailpxp", new MailPxp(...));
     PolicyId policyId = myDataEnvironment.getPmp().addPolicy(new Policy(...));
     myDataEnvironment.getPmp().deployPolicy(policyId);
     Event event = new EventBuilder("mysolution", "read").withParameter("text", "Hello World", String.class).getEvent();
     try{
       myDataEnvironment.getPep().enforce(event); // use of a provided default PEP
       System.out.println(event.getValueForName("text")); // access to the enforced event/data
     } catch (InhibitException e){ // handling of InhibitException
       System.out.println("Inhibited");
     } catch (EvaluationUndecidableException e) { // handling of EvaluationUndecidableException
       System.out.println("EvaluationUndecidable");
     } catch (IOException e){ // handling of IOException
       System.out.println("IOException");
     }
     
 
  • Field Details

  • Method Details

    • enableOverwritingOfExistingMyDataEnvironments

      public static void enableOverwritingOfExistingMyDataEnvironments()
      Enable overwriting of existing MyDataEnvironments for testing purpose
    • disableOverwritingOfExistingMyDataEnvironments

      public static void disableOverwritingOfExistingMyDataEnvironments()
      Disable overwriting of existing MyDataEnvironments for testing purpose
    • getDefaultEnvironment

      public static IMyDataEnvironment getDefaultEnvironment()
      Static access to the default IMyDataEnvironment
      Returns:
      the default IMyDataEnvironment
      Throws:
      IllegalStateException - when the default IMyDataEnvironment has not been initialized yet.
    • getEnvironment

      public static Optional<IMyDataEnvironment> getEnvironment(String environmentId)
      Access to a IMyDataEnvironment instance via environmentId
      Parameters:
      environmentId - the id of the IMyDataEnvironment instance to access
      Returns:
      an Optional that contains the IMyDataEnvironment if available
    • constructDefaultEnvironment

      public static IMyDataEnvironmentInitializer constructDefaultEnvironment()
      Method to create the default IMyDataEnvironment instance
         MyDataEnvironment myDataEnvironment = MyDataEnvironmentManager.constructDefaultEnvironment().initializeLocal(...);
       

      Multiple Environments are not supported at the moment, so there is only the "Default Environment"

      Returns:
      a IMyDataEnvironmentInitializer that can be initialized