Package org.olat.core.commons.modules.bc.meta

Examples of org.olat.core.commons.modules.bc.meta.MetaInfo


       
        boolean targetIsRelPath = (target instanceof OlatRelPathImpl);
        for (VFSItem vfsSource:sources) {
          if (targetIsRelPath && (vfsSource instanceof OlatRelPathImpl)) {
            // copy the metainfo first
            MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)vfsSource);
            meta.moveCopyToDir((OlatRelPathImpl)target, move);
          }
         
          VFSItem targetFile = target.resolve(vfsSource.getName());
          if(vfsSource instanceof VFSLeaf && targetFile != null && targetFile instanceof Versionable
              && ((Versionable)targetFile).getVersions().isVersioned()) {
View Full Code Here


        this.fireEvent(ureq, Event.FAILED_EVENT);
        return;
      }
      if (item instanceof OlatRelPathImpl) {
        // update meta data
        MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)item);
        meta.setAuthor(ureq.getIdentity().getName());
        meta.write();
     
      fileName = getItemName();     
      fireEvent(ureq, Event.DONE_EVENT)
    }
View Full Code Here

      this.versionFile = versionFile;
    }

    public String getAuthor() {
      if(versionFile instanceof MetaTagged) {
        MetaInfo info = ((MetaTagged)versionFile).getMetaInfo();
        return info.getAuthor();
      }
      return "-";
    }
View Full Code Here

   *      org.olat.core.gui.control.Event)
   */
  public void event(UserRequest ureq, Controller source, Event event) {
    if (source == metaInfoCtr) {
      if (event == Event.DONE_EVENT) {
        MetaInfo meta = metaInfoCtr.getMetaInfo();
        meta.write();
        String fileName = metaInfoCtr.getFilename();
       
        if (metaInfoCtr.isFileRenamed()) {
          // IMPORTANT: First rename the meta data because underlying file
          // has to exist in order to work properly on it's meta data.
          VFSContainer container = currentItem.getParentContainer();
          if(container.resolve(fileName) != null) {
            getWindowControl().setError(translator.translate("TargetNameAlreadyUsed"));
            status = FolderCommandStatus.STATUS_FAILED;
          } else {
            if (meta != null) {
              meta.rename(fileName);
            }
            if(VFSConstants.NO.equals(currentItem.rename(fileName))) {
              getWindowControl().setError(translator.translate("FileRenameFailed", new String[]{fileName}));
              status = FolderCommandStatus.STATUS_FAILED;
            }
View Full Code Here

        for (String file : files) {
          VFSItem item = currentContainer.resolve(file);
          if (item != null && (item.canDelete() == VFSConstants.YES)) {
            if (item instanceof OlatRelPathImpl) {
              // delete all meta info
              MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)item);
              if (meta != null) meta.deleteAll();
            }
            // delete the item itself
            item.delete();
          } else {
            getWindowControl().setWarning(translator.translate("del.partial"));
View Full Code Here

    }
  }
 
  private boolean askForLock(VFSItem item, UserRequest ureq) {
    if(item instanceof MetaTagged) {
      MetaInfo info = ((MetaTagged)item).getMetaInfo();
      if(info.isLocked() && !MetaInfoHelper.isLocked(item, ureq)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

        }
      }
    } else if (source == commentVersionCtr) {
      String comment = commentVersionCtr.getComment();
      if(existingVFSItem instanceof MetaTagged) {
        MetaInfo info = ((MetaTagged)existingVFSItem).getMetaInfo();
        if(info.isLocked() && !commentVersionCtr.keepLocked()) {
          info.setLocked(false);
          info.write();
        }
      }
     
      cleanUpCommentDialog();
      cleanUpRevisionDialog();

      //ok, new version of the file
      Versionable existingVersionableItem = (Versionable)existingVFSItem;
      boolean ok = existingVersionableItem.getVersions().addVersion(ureq.getIdentity(), comment, newFile.getInputStream());
      if(ok) {
        newFile.delete();
        VersionsManager.getInstance().delete(newFile, true);
        //what can i do if existingVFSItem is a container
        if(existingVFSItem instanceof VFSLeaf) {
          newFile = (VFSLeaf)existingVFSItem;
        }
      }
      finishUpload(ureq);
    } else if (source == unlockCtr) {
      // Overwrite...
      String fileName = existingVFSItem.getName();
      if(!unlockCtr.keepLocked()) {
        MetaInfo info = ((MetaTagged)existingVFSItem).getMetaInfo();
        info.setLocked(false);
        info.setLockedBy(null);
        info.write();
      }
     
      cleanUpUnlockDialog();
     
      existingVFSItem.delete();
View Full Code Here

  private void finishSuccessfullUpload(String fileName, UserRequest ureq) {
    VFSItem item = currentContainer.resolve(fileName);
    if (item instanceof OlatRootFileImpl) {
      OlatRootFileImpl relPathItem = (OlatRootFileImpl) item;
      // create meta data
      MetaInfo meta = MetaInfoFactory.createMetaInfoFor(relPathItem);
      if (metaDataCtr != null) {
        meta = metaDataCtr.getMetaInfo(meta);
      }
      meta.setAuthor(ureq.getIdentity().getName());
      meta.write();
    }
    ThreadLocalUserActivityLogger.log(FolderLoggingAction.FILE_UPLOADED, getClass(), CoreLoggingResourceable.wrapUploadFile(fileName));

    // Notify listeners about upload
    fireEvent(ureq, new FolderEvent(FolderEvent.UPLOAD_EVENT, fileName));
View Full Code Here

    super();
  }
 
  protected void init(SearchResourceContext leafResourceContext, VFSLeaf leaf) throws IOException,DocumentException,DocumentAccessException {
    // Load metadata for this file
    MetaInfo meta = null;
    if (leaf instanceof OlatRelPathImpl) {
      meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)leaf);
    }
   
    // Set all know attributes
    this.setResourceUrl(leafResourceContext.getResourceUrl());
    this.setLastChange(new Date(leaf.getLastModified()));
    // Check if there are documents attributes set in resource context
    if (leafResourceContext.getDocumentType() != null && !leafResourceContext.getDocumentType().equals("")) {
      // document-type in context is set => get from there
      this.setDocumentType(leafResourceContext.getDocumentType());
    } else {
      this.setDocumentType(TYPE);
    }
    String metaTitle = (meta == null ? null : meta.getTitle());
    if(!StringHelper.containsNonWhitespace(metaTitle)) {
      metaTitle = null;
    }
    if (leafResourceContext.getTitle() != null && !leafResourceContext.getTitle().equals("")) {
      // Title in context is set => get from there and add filename
      this.setTitle(leafResourceContext.getTitle() + " , " + (metaTitle == null ? "" : (metaTitle + " ( ")) + leaf.getName() + (metaTitle == null ? "" : " )"));
    } else {
      this.setTitle((metaTitle == null ? "" : (metaTitle + " ( ")) + leaf.getName() + (metaTitle == null ? "" : " )"));
    }
    String metaDesc = (meta == null ? null : meta.getComment());
    if (leafResourceContext.getDescription() != null && !leafResourceContext.getDescription().equals("")) {
      // Title in context is set => get from there
      this.setDescription(leafResourceContext.getDescription() + (metaDesc == null ? "" : " " + metaDesc));
    } else {
      //     no description this.setDescription();
      if (metaDesc != null) this.setDescription(metaDesc);
    }
    this.setParentContextType(leafResourceContext.getParentContextType());
    this.setParentContextName(leafResourceContext.getParentContextName());
    // Add the content itself
    this.setContent(readContent(leaf));
   
    // Add other metadata from meta info
    if (meta != null) {
      addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_DESCRIPTION, meta.getComment());     
      addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_LANGUAGE, meta.getLanguage());
      // Date is 2009 200902 or 20090228
      String[] pubDateArray = meta.getPublicationDate();
      if (pubDateArray != null) {
        String pubDate = null;
        if (pubDateArray.length == 1) pubDate = meta.getPublicationDate()[0];
        if (pubDateArray.length == 2) pubDate = meta.getPublicationDate()[0]+meta.getPublicationDate()[1];
        if (pubDateArray.length == 3) pubDate = meta.getPublicationDate()[0]+meta.getPublicationDate()[1]+meta.getPublicationDate()[2];
        addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_DATE, pubDate);             
      }
      addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_PUBLISHER, meta.getPublisher())
      addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_SOURCE, meta.getSource())
      addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_SOURCE, meta.getUrl())
      // use creator and author as olat author
      setAuthor((meta.getCreator() == null ? meta.getAuthor() : meta.getAuthor() + " " + meta.getCreator()));
      addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_CREATOR, meta.getCreator());       
    }
    // Add file type
    String mimeType = WebappHelper.getMimeType(leaf.getName());
    addMetadata(SimpleDublinCoreMetadataFieldsProvider.DC_FORMAT, mimeType);   
   
View Full Code Here

          // delete file
          VFSItem item = rootContainer.resolve(cmdUpload.getFileName());
            if (item != null && (item.canDelete() == VFSConstants.YES)) {
              if (item instanceof OlatRelPathImpl) {
                // delete all meta info
                MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)item);
                if (meta != null) meta.deleteAll();
              }
              // delete the item itself
              item.delete();
            }
          return;
View Full Code Here

TOP

Related Classes of org.olat.core.commons.modules.bc.meta.MetaInfo

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.