public EntryPointInstance createEntryPointInstance(EntryPointDefinition entryPointDefinition, final String path)
throws JahiaException {
if (entryPointDefinition == null) {
return null;
}
final ApplicationBean appBean = getApplication(entryPointDefinition.getApplicationID());
ApplicationsManagerProvider appProvider = getProvider(appBean);
EntryPointInstance epInstance = null;
try {
epInstance = appProvider.createEntryPointInstance(entryPointDefinition);
// Create the new entry point instance with its acl id binded to the one of its application parent
} catch (JahiaException je) {
logger.error("Error while trying to retrieve entry point definitions for application " + appBean.getID(),
je);
}
if (epInstance != null) {
try {
final EntryPointInstance epInstance1 = epInstance;
JCRSessionWrapper session = jcrTemplate.getSessionFactory().getCurrentUserSession();
final JCRNodeWrapper parentNode = session.getNode(path);
session.checkout(parentNode);
final String name = epInstance1.getResKeyName() != null ? epInstance1.getResKeyName() : appBean.getName().replaceAll(
"/", "___") + Math.round(Math.random() * 1000000l);
final JCRPortletNode wrapper = (JCRPortletNode) parentNode.addNode(name, "jnt:portlet");
final String scope = epInstance1.getCacheScope();
if (scope != null) {
wrapper.setProperty("j:cacheScope", scope);
}
wrapper.setApplication(appBean.getID(), epInstance1.getDefName());
wrapper.setProperty("j:expirationTime", epInstance1.getExpirationTime());
session.save();
epInstance1.setID(wrapper.getUUID());
return epInstance1;
} catch (RepositoryException e) {