Package com.gentics.api.lib.datasource

Examples of com.gentics.api.lib.datasource.Datasource


      final HttpServletResponse response) throws ServletException,
      IOException {

    String allString = request.getParameter(ALL_PARAMETER);
    if (allString != null && Boolean.parseBoolean(allString)) {
      Datasource ds = conf.getDatasource();
      CRDatabaseFactory.clearCache(ds);
      LOGGER.debug("Cleared the cache of the configured datasource for "
          + this.getServletName());
    } else {
      String[] contentids = request.getParameterValues(ID_PARAMETER);
      Datasource ds = conf.getDatasource();
      if (contentids != null) {
        for (String id : contentids) {
          CRDatabaseFactory.clearCache(ds, id);
          LOGGER.debug("Cleared " + id + " from the cache for "
              + this.getServletName());
View Full Code Here


   */
  public final Collection<CRResolvableBean> getObjects(
      final CRRequest request,
      final boolean doNavigation)
      throws CRException {
    Datasource ds = null;
    DatasourceFilter dsFilter;
    Collection<CRResolvableBean> collection = null;
   
    if (request != null) {
      RequestWrapper rW = request.getRequestWrapper();
View Full Code Here

    if (langs != null) {
      for (String lang : langs) {
        langPrefills.add("contentid_" + lang);
      }
    }
    Datasource ds = null;
    DatasourceFilter dsFilter;
    Vector<CRResolvableBean> collection = new Vector<CRResolvableBean>();
 
    //GENERATE LANG REQUEST
    CRRequest myREQ = request.Clone();
    myREQ.setCountString("-1");
    myREQ.setStartString("0");

    // Parse the given expression and create a datasource filter
    try {
      ds = this.config.getDatasource();
      if (ds == null) {
        throw (new DatasourceException("No Datasource available."));
      }

      dsFilter = myREQ.getPreparedFilter(config, ds);

      // add base resolvables
      if (this.resolvables != null) {
        for (Iterator<String> it = this.resolvables.keySet().iterator(); it.hasNext();) {
          String name = it.next();
          dsFilter.addBaseResolvable(name, this.resolvables.get(name));
        }
      }

      Collection<Resolvable> fallbackedColl = new ArrayList<Resolvable>();
      // do the query
      Collection<Resolvable> col = this.toResolvableCollection(ds.getResult(
        dsFilter,
        langPrefills.toArray(new String[] {}),
        myREQ.getStart().intValue(),
        myREQ.getCount().intValue(),
        myREQ.getSorting()));

      //REMOVE ALL NONFITTING RESOS
      int count = request.getCount().intValue();
      int start = request.getStart().intValue();
      boolean all = count == -1;
      int objectsToProcess = start + count;
      for (Resolvable reso : col) {
        boolean found = false;
        if (langs != null) {

          for (String lang : langs) {
            Resolvable langVersion = (Resolvable) reso.get("contentid_" + lang);
            if (langVersion != null) {
              found = true;
              if (!fallbackedColl.contains(langVersion)) {
                fallbackedColl.add(langVersion);
              }
              break;
            }
          }

        }
        if (!found) {
          fallbackedColl.add(reso);
        }
        if (!all && (fallbackedColl.size() >= objectsToProcess)) {
          break;
        }
      }

      if (count != 0) {
        Collection<Resolvable> sizedColl = new ArrayList<Resolvable>();
        Iterator<Resolvable> it = fallbackedColl.iterator();
        int counter = 0;
        while (it.hasNext() && counter < objectsToProcess) {
          Resolvable r = it.next();
          if (counter >= start) {
            sizedColl.add(r);
          }
          counter++;
        }
        fallbackedColl = sizedColl;
      }

      //PREFILL THE COLLECTION
      String[] prefillAttributes = request.getAttributeArray();
      CRResolvableBean meta = new CRResolvableBean();
      meta.set("objects", fallbackedColl);
      myREQ.addObjectForFilterDeployment("meta", meta);
      myREQ.setRequestFilter(createPrefillFilter("contentid"));
      dsFilter = myREQ.getPreparedFilter(config, ds);
      col = this.toResolvableCollection(ds.getResult(
        dsFilter,
        prefillAttributes,
        myREQ.getStart().intValue(),
        myREQ.getCount().intValue(),
        myREQ.getSorting()));
View Full Code Here

    }
    if (!lazyload) {
      // Init datasources so that the connections can be initialized
      // The initialized handles will be cached and then returned when
      // the datasource is fetched again
      Datasource ds = getDatasource();
     
      if (ds != null) {
        CRDatabaseFactory.releaseDatasource(ds);
      }
    }
View Full Code Here

   * @throws CRException TODO javadoc
   */
  public final Collection<CRResolvableBean> getObjects(final CRRequest request, final boolean doNavigation)
      throws CRException {
    UseCase getObjectCase = MonitorFactory.startUseCase("CRRequestProcessor.getObjects(" + config.getName() + ")");
    Datasource ds = null;
    DatasourceFilter dsFilter;
    Vector<CRResolvableBean> collection = new Vector<CRResolvableBean>();
    if (request != null) {
      // Parse the given expression and create a datasource filter
      try {
View Full Code Here

   * requestProcessorConfig.
   * @param requestProcessorConfig containing the datasource config
   * @return Datasource if correctly configured, otherwise null
   */
  public static Datasource getDatasource(final CRConfigUtil requestProcessorConfig) {
    Datasource ds = null;
    Properties dsHandle = requestProcessorConfig.getDatasourceHandleProperties();
    Properties dsProps = requestProcessorConfig.getDatasourceProperties();
    if (dsHandle != null && dsHandle.size() != 0) {
      if (dsHandle.containsKey("portalnodedb")) {
        String key = (String) dsHandle.get("portalnodedb");
View Full Code Here

   * @return resulting objects
   * @throws CRException TODO javadocs
   */
  public Collection<CRResolvableBean> getObjects(final CRRequest request, final boolean doNavigation)
      throws CRException {
    Datasource ds = null;
    DatasourceFilter dsFilter;
    Vector<CRResolvableBean> collection = new Vector<CRResolvableBean>();
    if (request != null) {

      // Parse the given expression and create a datasource filter
      try {
        ds = this.config.getDatasource();
        if (ds == null) {
          throw (new DatasourceException("No Datasource available."));
        }

        dsFilter = request.getPreparedFilter(config, ds);

        // add base resolvables
        if (this.resolvables != null) {
          for (Iterator<String> it = this.resolvables.keySet().iterator(); it.hasNext();) {
            String name = it.next();
            dsFilter.addBaseResolvable(name, this.resolvables.get(name));
          }
        }

        String[] prefillAttributes = request.getAttributeArray();
        prefillAttributes = ArrayHelper.removeElements(prefillAttributes, "contentid", "updatetimestamp");
        // do the query
        Collection<Resolvable> col = this.toResolvableCollection(ds.getResult(
          dsFilter,
          prefillAttributes,
          request.getStart().intValue(),
          request.getCount().intValue(),
          request.getSorting()));
View Full Code Here

   * @param cacheWarmRule - Rule that is used to fetch the objects
   */
  @SuppressWarnings("unchecked")
  public void warmCache(final String cacheWarmRule) {

    Datasource ds = null;
    try {

      // prepare the filter
      ds = this.conf.getDatasource();
      DatasourceFilter filter = ds.createDatasourceFilter(ExpressionParser.getInstance().parse(cacheWarmRule));

      // use the filter to get matching objects
      String[] atts = null;
      if (fast) {
        atts = fastprefillAttributes;
      } else {
        atts = prefillAttributes;
      }
      Collection<Resolvable> coll = (Collection<Resolvable>) ds.getResult(filter, atts);
      for (Resolvable res : coll) {
        CRRequest req = new CRRequest();
        req.setUrl((String) res.get("pub_dir") + (String) res.get("filename"));
        this.getObject(req);
      }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public CRResolvableBean getObject(final CRRequest request) {
    Resolvable contentObject = null;
    String url = request.getUrl();
    Datasource ds = null;
    if (url != null) {
      try {

        // prepare the filter
        ds = this.conf.getDatasource();
        DatasourceFilter filter = ds.createDatasourceFilter(expression);

        //Deploy base objects
        Iterator<String> it = request.getObjectsToDeploy().keySet().iterator();
        while (it.hasNext()) {
          String key = it.next();
          filter.addBaseResolvable(key, request.getObjectsToDeploy().get(key));
        }

        // add the data to the filter
        filter.addBaseResolvable("data", new PathBean(url));

        // use the filter to get matching objects
        Collection<Resolvable> objects = ds.getResult(filter, request.getAttributeArray());

        Iterator<Resolvable> i = objects.iterator();
        if (i.hasNext()) {
          // we found at least one object, take the first one
          contentObject = i.next();
View Full Code Here

   * @param contentid
   */
  public String getPath(final String contentid) {

    Resolvable linkedObject = null;
    Datasource ds = null;
    try {
      ds = this.conf.getDatasource();
      // initialize linked Object
      linkedObject = PortalConnectorFactory.getContentObject(contentid, ds);
      return getPath(linkedObject);
View Full Code Here

TOP

Related Classes of com.gentics.api.lib.datasource.Datasource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.