Package org.olat.ims.cp.objects

Examples of org.olat.ims.cp.objects.CPResource


    if (pageFile == null) { return ""; }
    return pageFile.getName();
  }

  protected CPResource getResource() {
    CPResource resource = null;
    CPManager mgr = CPManager.getInstance();
    DefaultElement resElement = mgr.getElementByIdentifier(cp, idRef);
    if (resElement instanceof CPResource) {
      resource = (CPResource)resElement;
    }
View Full Code Here


    // else in the manifest
    CPManager cpMgm = CPManager.getInstance();
    DefaultElement ele = cpMgm.getElementByIdentifier(cp, currentPage.getIdRef());
    boolean single = false;
    if (ele instanceof CPResource) {
      CPResource res = (CPResource) ele;
      single = cpMgm.isSingleUsedResource(res, cp);
    }

    StringBuilder b = new StringBuilder();
    b.append("<br /><ul>");
View Full Code Here

            new Exception());
      }

    } else if (parentElement instanceof CPResource) {
      // parent is a <resource>
      CPResource resource = (CPResource) parentElement;
      if (newElement instanceof CPFile) {
        resource.addFile((CPFile) newElement);
      } else if (newElement instanceof CPDependency) {
        resource.addDependency((CPDependency) newElement);
      } else {
        throw new OLATRuntimeException(CPOrganizations.class, "you can only add <dependency> or <file> elements to a Resource",
            new Exception());
      }
      return true;
View Full Code Here

        if (resourceFlag) {
          // Delete children (depth first search)
          removeChildElements(item, resourceFlag);

          // remove referenced resource
          CPResource res = (CPResource) rootNode.getElementByIdentifier(item.getIdentifierRef());
          if (res != null && referencesCount(res) == 1) {
            res.removeFromManifest();
          }
        }
        // then remove item
        item.removeFromManifest();
View Full Code Here

   * @param item
   */
  private void cloneResourceOfItem(CPItem item) {
    DefaultElement ref = getElementByIdentifier(item.getIdentifierRef());
    if (ref != null && ref instanceof CPResource) {
      CPResource resource = (CPResource) ref;
      // Clone the resource if the linked file is editable (i.e. it is an html,
      // Word or Excel file)
      String href = resource.getFullHref();
      if (href != null) {
        String extension = href.substring(href.lastIndexOf(".") + 1);
        if ("htm".equals(extension) || "html".equals(extension) || "doc".equals(extension) || "xls".equals(extension)) {
          CPResource clonedResource = (CPResource) resource.clone();
          addElement(clonedResource);
          item.setIdentifierRef(clonedResource.getIdentifier());
        }
      }
    }
  }
View Full Code Here

      }
    }

    // search for <dependency identifierref="resourceIdentifier" >
    for (Iterator<CPResource> itRes = rootNode.getResources().getResourceIterator(); itRes.hasNext();) {
      CPResource res = itRes.next();
      for (Iterator<CPDependency> itDep = res.getDependencyIterator(); itDep.hasNext();) {
        CPDependency dep = itDep.next();
        if (dep.getIdentifierRef().equals(resourceIdentifier)) return dep;
      }
    }
View Full Code Here

    if (ele instanceof CPItem) {
      CPItem item = (CPItem) ele;
      if (item.getIdentifierRef() == null || item.getIdentifierRef().equals("")) { return null; }
      DefaultElement resElement = getElementByIdentifier(item.getIdentifierRef());
      if (resElement instanceof CPResource) {
        CPResource res = (CPResource) resElement;
        return res.getFullHref();
      } else {
        Logger log = Logger.getLogger(this.getClass().getName());
        log.info("method: getPageByItemID(" + id + ") :  invalid manifest.. identifierred of <item> must point to a <resource>-element");
        return null;
      }
View Full Code Here

      if (itemIdentifierRef == null || itemIdentifierRef.equals("")) {
        // This item has no linked resource yet. Add one if there is a page file
        // attached.
        VFSLeaf pageFile = page.getPageFile();
        if (pageFile != null) {
          CPResource res = new CPResource();
          CPFile file = new CPFile(pageFile);
          res.addFile(file);
          // TODO:GW Set type according to file
          res.setType("text/html");
          res.setHref(file.getHref());
          item.setIdentifierRef(res.getIdentifier());
          cpcore.getRootNode().getResources().addResource(res);
        }
      } else {// this item has already a linked resource
        // this is not supported, we don't change linked resources...
      }
View Full Code Here

TOP

Related Classes of org.olat.ims.cp.objects.CPResource

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.