Package de.fraunhofer.iese.mydata
Class MyDataEnvironmentManager
- java.lang.Object
-
- de.fraunhofer.iese.mydata.MyDataEnvironmentManager
-
public final class MyDataEnvironmentManager extends Object
MyDataEnvironmentManager
handles theIMyDataEnvironment
, 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 Summary
Fields Modifier and Type Field Description static String
DEFAULT_ENVIRONMENT_ID
The id of the defaultIMyDataEnvironment
instance to which a reference is kept by the static context ofMyDataEnvironmentManager
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IMyDataEnvironmentInitializer
constructDefaultEnvironment()
Method to create the defaultIMyDataEnvironment
instancestatic void
disableOverwritingOfExistingMyDataEnvironments()
Disable overwriting of existing MyDataEnvironments for testing purposestatic void
enableOverwritingOfExistingMyDataEnvironments()
Enable overwriting of existing MyDataEnvironments for testing purposestatic IMyDataEnvironment
getDefaultEnvironment()
Static access to the defaultIMyDataEnvironment
static Optional<IMyDataEnvironment>
getEnvironment(String environmentId)
Access to aIMyDataEnvironment
instance via environmentId
-
-
-
Field Detail
-
DEFAULT_ENVIRONMENT_ID
public static final String DEFAULT_ENVIRONMENT_ID
The id of the defaultIMyDataEnvironment
instance to which a reference is kept by the static context ofMyDataEnvironmentManager
.- See Also:
- Constant Field Values
-
-
Method Detail
-
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 defaultIMyDataEnvironment
- Returns:
- the default
IMyDataEnvironment
- Throws:
IllegalStateException
- when the defaultIMyDataEnvironment
has not been initialized yet.
-
getEnvironment
public static Optional<IMyDataEnvironment> getEnvironment(String environmentId)
Access to aIMyDataEnvironment
instance via environmentId- Parameters:
environmentId
- the id of theIMyDataEnvironment
instance to access- Returns:
- an Optional that contains the
IMyDataEnvironment
if available
-
constructDefaultEnvironment
public static IMyDataEnvironmentInitializer constructDefaultEnvironment()
Method to create the defaultIMyDataEnvironment
instanceMyDataEnvironment 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
-
-