Tabnine Logo
SessionProvider.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
org.exoplatform.services.jcr.ext.common.SessionProvider

Best Java code snippets using org.exoplatform.services.jcr.ext.common.SessionProvider.close (Showing top 20 results out of 315)

origin: exoplatform/platform

  public long getBeforeLastLogin(String userId) throws Exception {
   SessionProvider sProvider = SessionProvider.createSystemProvider();
   try {
    Session session = this.getSession(sProvider);
    Node homeNode = session.getRootNode().getNode(HOME);
    return !homeNode.hasNode(userId) ? 0 : homeNode.getNode(userId).getProperty("exo:LoginHisSvc_beforeLastLogin").getLong();
   } catch (Exception e) {
    LOG.debug("Error while retrieving " + userId + "'s last login: " + e.getMessage(), e);
    throw e;
   } finally {
    sProvider.close();
   }
  }
}
origin: exoplatform/platform

private Node getSpaceHome() throws Exception {
  
 if(this._repoService != null){
   SessionProvider sProvider = null;
   Session session = null;
   
   try {
     sProvider = SessionProvider.createSystemProvider();
     session = this.getSession(sProvider);
     Node rootNode = session.getRootNode();
     if(rootNode.hasNode(SPACE_HOME))
     {
       return rootNode.getNode(SPACE_HOME);
     }
   }
   catch (Exception e) {
     LOG.error("Can not get get SpaceHome", e);
     sProvider.close();
   } finally {
     if (session != null) {
       session.logout();
     }
     if (sProvider != null) {
       sProvider.close();
     }
   }
 }
 return null;
}
origin: exoplatform/platform

/**
 * Get user's last login time
 */
public long getLastLogin(String userId) throws Exception {
  SessionProvider sProvider = SessionProvider.createSystemProvider();
  try {
    Session session = this.getSession(sProvider);
    Node homeNode = session.getRootNode().getNode(HOME);
    return !homeNode.hasNode(userId) ? 0 : homeNode.getNode(userId).getProperty("exo:LoginHisSvc_lastLogin").getLong();
  } catch (Exception e) {
    LOG.debug("Error while retrieving " + userId + "'s last login: " + e.getMessage(), e);
    throw e;
  } finally {
    sProvider.close();
  }
}
origin: exoplatform/platform

public String getHomePageLogoURI() {
  SessionProvider sProvider  =  SessionProvider.createSystemProvider();
  Node rootNode = null;
  Node publicApplicationNode = null;
  String pathImageNode = null;
  Node ImageNode = null;
  Session session = null;
  try {
    publicApplicationNode = nodeCreator.getPublicApplicationNode(sProvider);
    session = publicApplicationNode.getSession();
    rootNode = session.getRootNode();
    if (rootNode.hasNode(path)) {
     Node logosNode = rootNode.getNode(path);
     if (logosNode.hasNode(logo_name)) {
      ImageNode = logosNode.getNode(logo_name);
      pathImageNode = ImageNode.getPath()+"?"+System.currentTimeMillis();
     }
    }
  } catch (Exception e) {
    LOG.error("Can not get path of Logo : default LOGO will be used" + e.getMessage(), e);
    return null;
  }
  finally {
   if  (session != null)
     session.logout();
   if  (sProvider != null)
     sProvider.close ();
  }
  return pathImageNode;
}
origin: exoplatform/platform

private void createTermsAndConditions() {
  SessionProvider sessionProvider = SessionProvider.createSystemProvider();
  try {
    Node publicApplicationNode = nodeHierarchyCreator.getPublicApplicationNode(sessionProvider);
    if(! publicApplicationNode.hasNode(TC_NODE_NAME)) {
      publicApplicationNode = publicApplicationNode.addNode(TC_NODE_NAME, "nt:folder");
      publicApplicationNode.addMixin("mix:referenceable");
      publicApplicationNode.getSession().save();
    }
  } catch(Exception e) {
   LOG.error("Terms and conditions: cannot create node", e);
  } finally {
    if (sessionProvider != null) {
      sessionProvider.close();
    }
  }
}
origin: exoplatform/platform

@GET
@Path("setDelete")
@Produces(MediaType.APPLICATION_JSON)
public Response setDelete(@Context SecurityContext sc, @Context UriInfo uriInfo) throws Exception {
  SessionProvider sProvider = null;
  try {
    String userId = getUserId(sc, uriInfo);
    if (userId == null) {
      return Response.status(HTTPStatus.INTERNAL_ERROR).build();
    }
    NodeHierarchyCreator nodeCreator = (NodeHierarchyCreator) ExoContainerContext.getCurrentContainer()
        .getComponentInstanceOfType(NodeHierarchyCreator.class);
    sProvider = SessionProvider.createSystemProvider();
    Node userPrivateNode = nodeCreator.getUserNode(sProvider, userId).getNode("ApplicationData");
    if (userPrivateNode.hasNode("GsGadget")) {
      Node gettingStartedNode = userPrivateNode.getNode("GsGadget");
      if (gettingStartedNode.hasProperty("exo:gs_deleteGadget")) {
        gettingStartedNode.setProperty("exo:gs_deleteGadget", true);
        gettingStartedNode.save();
        return Response.ok("Property exo:gs_deleteGadget set to true").build();
      } else return Response.ok("no Property exo:gs_deleteGadget ").build();
    } else return Response.ok("no Node GsGadget ").build();
  } catch (Exception e) {
    return Response.status(HTTPStatus.INTERNAL_ERROR).build();
  } finally {
    if (sProvider != null) {
      sProvider.close();
    }
  }
}
origin: exoplatform/platform

@GET
@Path("IsDelete")
@Produces(MediaType.APPLICATION_JSON)
public Response IsDelete(@Context SecurityContext sc, @Context UriInfo uriInfo) throws Exception {
  SessionProvider sProvider = null;
  try {
    String userId = getUserId(sc, uriInfo);
    if (userId == null) {
      return Response.status(HTTPStatus.INTERNAL_ERROR).build();
    }
    NodeHierarchyCreator nodeCreator = (NodeHierarchyCreator) ExoContainerContext.getCurrentContainer()
        .getComponentInstanceOfType(NodeHierarchyCreator.class);
    sProvider = SessionProvider.createSystemProvider();
    Node userPrivateNode = nodeCreator.getUserNode(sProvider, userId).getNode("ApplicationData");
    if (userPrivateNode.hasNode("GsGadget")) {
      Node gettingStartedNode = userPrivateNode.getNode("GsGadget");
      if (gettingStartedNode.hasProperty("exo:gs_deleteGadget")) {
        Boolean del=gettingStartedNode.getProperty("exo:gs_deleteGadget").getBoolean();
        return Response.ok(del.toString()).build();
      } else return Response.ok("no Property exo:gs_deleteGadget ").build();
    } else return Response.ok("no Node GsGadget ").build();
  } catch (Exception e) {
    return Response.status(HTTPStatus.INTERNAL_ERROR).build();
  } finally {
    if (sProvider != null) {
      sProvider.close();
    }
  }
}
origin: exoplatform/platform

/**
 * Create software registration node
 */
private void createSoftwareRegistrationNode() {
 SessionProvider sessionProvider = SessionProvider.createSystemProvider();
 try {
  Node publicApplicationNode = nodeHierarchyCreator.getPublicApplicationNode(sessionProvider);
  if (!publicApplicationNode.hasNode(SW_NODE_NAME)) {
   publicApplicationNode = publicApplicationNode.addNode(SW_NODE_NAME, "nt:folder");
   publicApplicationNode.addMixin("mix:referenceable");
   publicApplicationNode.getSession().save();
  }
 } catch (Exception e) {
  LOG.error("Software Registration: cannot create node", e);
 } finally {
  if (sessionProvider != null) {
   sessionProvider.close();
  }
 }
}
origin: exoplatform/platform

public Map<String, Integer> getActiveUsers(long fromTime) {
 Map<String, Integer> users = new LinkedHashMap<String, Integer>();
 SessionProvider sProvider = SessionProvider.createSystemProvider();
 try {
  Session session = this.getSession(sProvider);
  QueryManager queryManager = session.getWorkspace().getQueryManager();
  StringBuilder sb = new StringBuilder();
  sb.append("SELECT * FROM exo:LoginHisSvc_userProfile WHERE")
   .append(" exo:LoginHisSvc_lastLogin >= " + Long.toString(fromTime))
   .append(" AND exo:LoginHisSvc_beforeLastLogin > 0")
   .append(" ORDER BY exo:LoginHisSvc_lastLogin DESC");
  QueryImpl query = (QueryImpl) queryManager.createQuery(sb.toString(), Query.SQL);
  QueryResult result = query.execute();
  NodeIterator nodeIterator = result.getNodes();
  while (nodeIterator.hasNext()) {
   Node node = nodeIterator.nextNode();
   String userId = node.getProperty("exo:LoginHisSvc_userId").getString();
   long numberOfLogin = node.getNode(LOGIN_HISTORY).getProperty("exo:LoginHisSvc_loginHistory_lastIndex").getLong();
   users.put(userId, (int) numberOfLogin);
  }
  return users;
 } catch (Exception e) {
  LOG.debug("Error while getting login history of users " + e.getMessage(), e);
 } finally {
  sProvider.close();
 }
 return null;
}

origin: exoplatform/platform

@Override
public void processUpgrade(String oldVersion, String newVersion) {
 SessionProvider sessionProvider = SessionProvider.createSystemProvider();
 try {
  Session session = sessionProvider.getSession("collaboration",
    repoService.getCurrentRepository());
  Node rootNode = session.getRootNode();
  if (rootNode.hasNode("Application Data")) {
   LOG.info("SecureJCRFolder - Proceed securing JCR folders for branding logo");
   Node applicationDataNode = rootNode.getNode("Application Data");
   Map<String, String[]> map = new HashMap<String, String[]>();
   map.put("*:/platform/administrators", PermissionType.ALL);
   ((ExtendedNode) applicationDataNode).setPermissions(map);
   if (applicationDataNode.hasNode("logos/logo.png")) {
    Node fileNode = applicationDataNode.getNode("logos/logo.png");
    if (fileNode.canAddMixin("exo:privilegeable")) {
     fileNode.addMixin("exo:privilegeable");
    }
    ((ExtendedNode) fileNode).setPermission(IdentityConstants.ANY, PermissionType.DEFAULT_AC);
   }
   session.save();
  }
 } catch (Exception e) {
  LOG.error("SecureJCRFolder - Error while migrating security for branding logo: ", e.getMessage());
 } finally {
  sessionProvider.close();
 }
}
origin: exoplatform/platform

/**
 * Get all Forums Weekly Statistic
 * 
 * @return all Forums Weekly Statistic
 */
public List<ForumsWeeklyStatistic> getAllForumsWeeklyStatistic() throws Exception {
 SessionProvider sProvider = SessionProvider.createSystemProvider();
 List<ForumsWeeklyStatistic> listForumsWeeklyStatistic = new ArrayList<ForumsWeeklyStatistic>();
 try {
  Node statisticHome = getStatisticWeekHomeNode(sProvider);
  QueryManager qm = statisticHome.getSession().getWorkspace().getQueryManager();
  String pathQuery = "/jcr:root" + statisticHome.getPath()
    + "/element(*,exo:periodicForumStats) order by @exo:startDate descending";
  Query query = qm.createQuery(pathQuery, Query.XPATH);
  QueryResult result = query.execute();
  NodeIterator iter = result.getNodes();
  while (iter.hasNext()) {
   listForumsWeeklyStatistic.add(getForumsWeeklyStatistic(iter.nextNode()));
  }
 } catch (Exception e) {
  LOG.error("can not get getAllForumsWeeklyStatistic", e);
 } finally {
  sProvider.close();
 }
 return listForumsWeeklyStatistic;
}
origin: exoplatform/platform

public Boolean hasDocuments(Node node, String userId) {
  SessionProvider sProvider = null;
  try {
   sProvider = SessionProvider.createSystemProvider();
   String pathCondition = node == null ? "" : 
               new StringBuilder(" AND jcr:path like ").append(node.getPath()).append("/%").toString();
   String fileQueryStatement = new StringBuilder("SELECT * FROM nt:file WHERE exo:owner='").
             append(userId).append("'").append(pathCondition).toString();
   String ws = CommonsUtils.getRepository().getConfiguration().getDefaultWorkspaceName();
   QueryImpl query = (QueryImpl)sProvider.getSession(ws, CommonsUtils.getRepository()).
        getWorkspace().getQueryManager().createQuery(fileQueryStatement, Query.SQL);
   query.setLimit(1);
   return (query.execute().getNodes().hasNext());
  } catch (RepositoryException e) {
    LOG.error("Getting started Service : cannot check uploaded documents " + e.getLocalizedMessage(), e);
    return false;
  } finally {
    if (sProvider !=null) {
      sProvider.close();
    }
  }
}
origin: exoplatform/platform

@Ajax
@Resource
public Response.Content delete() throws Exception {
  //set Delete
  String userId = null;
  SessionProvider sProvider = null;
  try {
    userId = RequestContext.getCurrentInstance().getRemoteUser();
    sProvider = SessionProvider.createSystemProvider();
    Node userPrivateNode = nodeHierarchyCreator_.getUserNode(sProvider, userId).getNode(GettingStartedUtils.JCR_APPLICATION_NODE);
    if (userPrivateNode.hasNode(GettingStartedUtils.JCR_GS_NODE)) {
      Node gettingStartedNode = userPrivateNode.getNode(GettingStartedUtils.JCR_GS_NODE);
      if (gettingStartedNode.hasProperty(GettingStartedUtils.JCR_DELETE_GADGET_PROPERTY_NAME)) {
        gettingStartedNode.setProperty(GettingStartedUtils.JCR_DELETE_GADGET_PROPERTY_NAME, true);
        gettingStartedNode.save();
      }
    }
  } catch (Exception E) {
    LOG.error("GettingStarted Portlet : Can not delete Portlet from ApplicationRegistry", E.getLocalizedMessage(), E);
  } finally {
    if (sProvider != null) {
      sProvider.close();
    }
  }
  return gettingStarted.ok();
}
origin: exoplatform/platform

 /**
  * Get total Post Count of Forums
  * 
  * @return total Post Count of Forums
  */
 public long getPostCountForumStatistic() throws Exception {
  SessionProvider sProvider = SessionProvider.createSystemProvider();
  try {
   Node statisticNode = sessionManager.getSession(sProvider)
                     .getRootNode()
                     .getNode(dataLocator.getForumStatisticsLocation());
   return new PropertyReader(statisticNode).l("exo:postCount", 0);
  } catch (Exception e) {
   LOG.error("getPostCountForumStatistic failure", e);
  } finally {
   sProvider.close();
  }
  return 0;
 }
}
origin: exoplatform/platform

sessionProvider.close();
origin: exoplatform/platform

@Override
public void processUpgrade(String oldVersion, String newVersion) {
 SessionProvider sessionProvider = SessionProvider.createSystemProvider();
 migrateCollaboration(sessionProvider);
 migrateGadgets(sessionProvider);
 migrateUsers(sessionProvider);
 migrateLoginHistory(sessionProvider);
 sessionProvider.close();
}
origin: exoplatform/platform

@Override
public void spaceCreated(SpaceLifeCycleEvent lifeCycleEvent) {
 SessionProvider sessionProvider = SessionProvider.createSystemProvider();
 try {
  Iterator<?> iterator = initParams.getObjectParamIterator();
  while (iterator.hasNext()) {
   ObjectParameter objectParameter = (ObjectParameter) iterator.next();
   DeploymentDescriptor deploymentDescriptor = (DeploymentDescriptor) objectParameter.getObject();
   spaceCustomizationService.deployContentToSpaceDrive(sessionProvider, lifeCycleEvent.getSpace().getGroupId(),
     deploymentDescriptor);
  }
 } catch (Exception e) {
  LOG.error("An unexpected problem occurs while deploying contents", e);
 } finally {
  sessionProvider.close();
 }
}
origin: exoplatform/platform

/**
 * Start the service and create a new node that contains all Forums Weekly Statistic if not found.
 * 
 * @see org.picocontainer.Startable#start()
 */
public void start() {
 SessionProvider sProvider = SessionProvider.createSystemProvider();
 try {
  Session session = sessionManager.getSession(sProvider);
  Node forumHome = session.getRootNode().getNode(dataLocator.getForumHomeLocation());
  if (!forumHome.hasNode(STATISTIC_WEEK_HOME)) {
   Node statisticWeekHome = forumHome.addNode(STATISTIC_WEEK_HOME, "nt:unstructured");
   session.save();
   // Initiate the first Forum Weekly Statistic
   ForumsWeeklyStatistic weeklyStatistic = new ForumsWeeklyStatistic();
   weeklyStatistic.setStartDate(new Date());
   weeklyStatistic.setLastStatEntry(new Date());
   weeklyStatistic.setPostsCountOfWeek(getPostCountForumStatistic());
   weeklyStatistic.setStartPostsCountOfWeek(getPostCountForumStatistic());
   saveForumsWeeklyStatistic(weeklyStatistic);
  }
 } catch (Exception e) {
  LOG.error("can not start ForumsWeeklyStatisticService", e);
 } finally {
  sProvider.close();
 }
}
origin: exoplatform/platform

/**
 * Get lastest Forums Weekly Statistic 
 * 
 * @return lastest Forums Weekly Statistic 
 */
public ForumsWeeklyStatistic getLastForumsWeeklyStatistic() throws Exception {
 SessionProvider sProvider = SessionProvider.createSystemProvider();
 try {
  Node statisticHome = getStatisticWeekHomeNode(sProvider);
  QueryManager qm = statisticHome.getSession().getWorkspace().getQueryManager();
  String pathQuery = "/jcr:root" + statisticHome.getPath()
    + "/element(*,exo:periodicForumStats) order by @exo:startDate descending";
  Query query = qm.createQuery(pathQuery, Query.XPATH);
  QueryResult result = query.execute();
  NodeIterator iter = result.getNodes();
  if (iter != null && iter.getSize() > 0)
   return getForumsWeeklyStatistic(iter.nextNode());
 } catch (Exception e) {
  LOG.error("can not get getLastForumsWeeklyStatistic", e);
 } finally {
  sProvider.close();
 }
 return null;
}
origin: exoplatform/platform

sProvider.close();
org.exoplatform.services.jcr.ext.commonSessionProviderclose

Popular methods of SessionProvider

  • createSystemProvider
  • getSession
  • <init>

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now