Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.Metadata


            report.incrementNullRecords();
            return null;
        }
       
        int iId = Integer.valueOf(id);
        Metadata info = metadataRepository.findOne(id);
       
       
        if (info == null) {
            report.addNotFoundMetadataId(iId);
        } else if (!accessMan.canEdit(context, id)) {
            report.addNotEditableMetadataId(iId);
        } else {

            // -----------------------------------------------------------------------
            // --- check processing exist for current schema
            String schema = info.getDataInfo().getSchemaId();

            String filePath = schemaMan.getSchemaDir(schema) + "/process/" + process + ".xsl";
            File xslProcessing = new File(filePath);
            if (!xslProcessing.exists()) {
                Log.info("org.fao.geonet.services.metadata","  Processing instruction not found for " + schema + " schema. Looking for "+filePath);
View Full Code Here


      //--- Metadata may have been deleted since selection
      if (id != null) {
        //-----------------------------------------------------------------------
        //--- check access
 
        Metadata info = context.getBean(MetadataRepository.class).findOne(id);
 
        if (info == null) {
          notFound.add(Integer.valueOf(id));
        } else if (!accessMan.isOwner(context, id)) {
          notOwner.add(Integer.valueOf(id));
        } else {
 
          //--- backup metadata in 'removed' folder
          if (backupFile && info.getDataInfo().getType() != MetadataType.SUB_TEMPLATE) {
            backupFile(context, id, info.getUuid(), MEFLib.doExport(context, info.getUuid(), "full", false, true, false));
          }
     
          //--- remove the metadata directory
          File pb = new File(Lib.resource.getMetadataDir(context, id));
          FileCopyMgr.removeDirectoryOrFile(pb);
View Full Code Here

    if (!category.equals("_none_") || !category.equals("")) {
      Element categs = new Element("categories");
      categs.addContent((new Element("category")).setAttribute(
          "name", category));

            final Metadata metadata = context.getBean(MetadataRepository.class).findOne(id.get(0));
            Importer.addCategoriesToMetadata(metadata , categs, context);
    }

    // Index
        dm.indexMetadata(id.get(0), true);
View Full Code Here

        String access = Util.getParam(params, Params.ACCESS);

        Lib.resource.checkPrivilege(context, id, ReservedOperation.download);

        //--- get metadata info
        Metadata info = context.getBean(MetadataRepository.class).findOne(id);

        if (info == null)
            throw new IllegalArgumentException("Metadata not found --> " + id);

        //--- start building response
        Element response = new Element("response");
        addElement(response, Params.ID, id);
        addElement(response, Params.UUID, info.getUuid());

        //--- now add the files chosen from the interface and record in 'downloaded'
        Element downloaded = new Element("downloaded");
        File dir = new File(Lib.resource.getDir(context, access, id));

        @SuppressWarnings("unchecked")
        List<Element> files = params.getChildren(Params.FNAME);
        for (Element elem : files) {
            response.addContent((Element) elem.clone());

            String fname = elem.getText();

            if (fname.contains("..")) {
                continue;    // Avoid unsecured file name
            }

            File file = new File(dir, fname);

            Element fileInfo = new Element("file");

            Element details = BinaryFile.encode(200, file.getAbsolutePath(), false);
            String remoteURL = details.getAttributeValue("remotepath");
            if (remoteURL != null) {
                fileInfo.setAttribute("size", "unknown");
                fileInfo.setAttribute("datemodified", "unknown");
                fileInfo.setAttribute("name", remoteURL);
            } else {
                fileInfo.setAttribute("size", file.length() + "");
                fileInfo.setAttribute("name", fname);
                Date date = new Date(file.lastModified());
                fileInfo.setAttribute("datemodified", _dateFormat.format(date));
            }
            downloaded.addContent(fileInfo);
        }
        addElement(response, Params.ACCESS, access);

        //--- get metadata
        boolean forEditing = false, withValidationErrors = false, keepXlinkAttributes = false;
        final DataManager dataManager = context.getBean(DataManager.class);
        Element elMd = dataManager.getMetadata(context, id, forEditing, withValidationErrors, keepXlinkAttributes);

        if (elMd == null)
            throw new IllegalArgumentException("Metadata not found --> " + id);

        //--- place xml in metadata element
        Element md = new Element(Geonet.Elem.METADATA);
        md.addContent((Element) elMd.clone());
        response.addContent(md);

        //--- transform record into brief version
        String briefXslt = stylePath + Geonet.File.METADATA_BRIEF;
        Element elBrief = Xml.transform(elMd, briefXslt);

        //--- create root element for passing all the info we've gathered
        //--- to license annex xslt generator
        Element root = new Element("root");
        elBrief.setAttribute("changedate", info.getDataInfo().getChangeDate().getDateAndTime());
        elBrief.setAttribute("currdate", now());
        root.addContent(elBrief);
        root.addContent(downloaded);
        if (context.isDebugEnabled())
            context.debug("Passed to metadata-license-annex.xsl:\n " + Xml.getString(root));
View Full Code Here

    String metadataId = Utils.getIdentifierFromParameters(params, context);

    //-----------------------------------------------------------------------
    //--- check access

    Metadata info = context.getBean(MetadataRepository.class).findOne(metadataId);

    if (info == null)
      throw new MetadataNotFoundEx(metadataId);

        Element ownerId = new Element("ownerid").setText(info.getSourceInfo().getOwner() + "");
        Element groupOwner = new Element("groupOwner").setText(info.getSourceInfo().getGroupOwner() + "");
        Element hasOwner = new Element("owner");
        if (am.isOwner(context, metadataId))
            hasOwner.setText("true");
        else
      hasOwner.setText("false");
View Full Code Here

        //
    // update element and return status
        //

        Metadata result = null;
        // whether to request automatic changes (update-fixed-info)
        boolean ufo = true;
        // whether to index on update
        boolean index = true;
       
View Full Code Here

            return null;
        }

        int iId = Integer.valueOf(id);

        Metadata metadataEntity =  context.getBean(MetadataRepository.class).findOne(iId);
        MetadataDataInfo info = metadataEntity.getDataInfo();

        // Get metadata title from the index
        String metadataTitle = LuceneSearcher.getMetadataFromIndexById(context.getLanguage(), id, "title");
        if (StringUtils.isEmpty(metadataTitle)) metadataTitle = metadataEntity.getUuid();

        if (info == null) {
            MassiveReplaceReportEntry notFoundEntry =
                    new MassiveReplaceReportEntry(id, "", null);
            report.addNotFound(notFoundEntry);

        } else if (!accessMan.isOwner(context, id)) {
            MassiveReplaceReportEntry notOwnerEntry =
                    new MassiveReplaceReportEntry(metadataEntity.getUuid(), metadataTitle, null);
            report.addNotEditable(notOwnerEntry);
        } else {

            // -----------------------------------------------------------------------
            // --- check processing exist for current schema
            String schema = info.getSchemaId();
            String filePath = schemaMan.getSchemaDir(schema) + "/process/" + process + ".xsl";
            File xslProcessing = new File(filePath);
            if (!xslProcessing.exists()) {
                context.info("  Processing instruction not found for " + schema
                        + " schema.");

                MassiveReplaceReportEntry notOwnerEntry =
                        new MassiveReplaceReportEntry(metadataEntity.getUuid(), metadataTitle, null);
                report.addNoProcessFound(notOwnerEntry);

                return null;
            }
            // --- Process metadata
            Element processedMetadata = null;

            try {
                Element md = dataMan.getMetadataNoInfo(context, id);

                // -- here we send parameters set by user from
                // URL if needed.
                List<Element> children = params.getChildren();
                Map<String, Object> xslParameter = new HashMap<String, Object>();
                for (Element param : children) {
                    if (param.getChildren().size() > 0) {
                        xslParameter.put(param.getName(), param);
                    } else {
                        xslParameter.put(param.getName(), param.getTextTrim());

                    }
                }

                processedMetadata = Xml.transformWithXmlParam(md, filePath, paramNameXml, paramXml);

                // Get changes
                String filePath2 = schemaMan.getSchemaDir(schema) + "/process/massive-content-update-extract-changes.xsl";
                List<Element> changesEl = Xml.transform(processedMetadata, filePath2).getChildren("change");

                boolean hasChanges = (changesEl.size() > 0);


                MassiveReplaceReportEntry mdEntry = new MassiveReplaceReportEntry(metadataEntity.getUuid(),
                        metadataTitle,
                        changesEl);

                if (hasChanges) {
                    report.addChanged(mdEntry);
View Full Code Here

                }
            } else {
                moreFields.add(SearchManager.makeField("_hasxlinks", "0", true, true));
            }

            final Metadata fullMd = _metadataRepository.findOne(id$);

            final String  schema     = fullMd.getDataInfo().getSchemaId();
            final String  createDate = fullMd.getDataInfo().getCreateDate().getDateAndTime();
            final String  changeDate = fullMd.getDataInfo().getChangeDate().getDateAndTime();
            final String  source     = fullMd.getSourceInfo().getSourceId();
            final MetadataType metadataType = fullMd.getDataInfo().getType();
            final String  root       = fullMd.getDataInfo().getRoot();
            final String  uuid       = fullMd.getUuid();
            final String  extra       = fullMd.getDataInfo().getExtra();
            final String  isHarvested = String.valueOf(Constants.toYN_EnabledChar(fullMd.getHarvestInfo().isHarvested()));
            final String  owner      = String.valueOf(fullMd.getSourceInfo().getOwner());
            final String  groupOwner = String.valueOf(fullMd.getSourceInfo().getGroupOwner());
            final String  popularity = String.valueOf(fullMd.getDataInfo().getPopularity());
            final String  rating     = String.valueOf(fullMd.getDataInfo().getRating());
            final String  displayOrder = fullMd.getDataInfo().getDisplayOrder() == null ? null : String.valueOf(fullMd.getDataInfo().getDisplayOrder());

            if(Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
                Log.debug(Geonet.DATA_MANAGER, "record schema (" + schema + ")"); //DEBUG
                Log.debug(Geonet.DATA_MANAGER, "record createDate (" + createDate + ")"); //DEBUG
            }

            moreFields.add(SearchManager.makeField("_root",        root,        true, true));
            moreFields.add(SearchManager.makeField("_schema",      schema,      true, true));
            moreFields.add(SearchManager.makeField("_createDate",  createDate,  true, true));
            moreFields.add(SearchManager.makeField("_changeDate",  changeDate,  true, true));
            moreFields.add(SearchManager.makeField("_source",      source,      true, true));
            moreFields.add(SearchManager.makeField("_isTemplate",  metadataType.codeString,  true, true));
            moreFields.add(SearchManager.makeField("_uuid",        uuid,        true, true));
            moreFields.add(SearchManager.makeField("_isHarvested", isHarvested, true, true));
            moreFields.add(SearchManager.makeField("_owner",       owner,       true, true));
            moreFields.add(SearchManager.makeField("_dummy",       "0",        false, true));
            moreFields.add(SearchManager.makeField("_popularity",  popularity,  true, true));
            moreFields.add(SearchManager.makeField("_rating",      rating,      true, true));
            moreFields.add(SearchManager.makeField("_displayOrder",displayOrder, true, false));
            moreFields.add(SearchManager.makeField("_extra",       extra,       true, false));

            if (owner != null) {
                User user = _applicationContext.getBean(UserRepository.class).findOne(fullMd.getSourceInfo().getOwner());
                if (user != null) {
                    moreFields.add(SearchManager.makeField("_userinfo", user.getUsername() + "|" + user.getSurname() + "|" + user
                            .getName() + "|" + user.getProfile(), true, false));
                }
            }
            if (groupOwner != null) {
                moreFields.add(SearchManager.makeField("_groupOwner", groupOwner, true, true));
            }

            // get privileges
            OperationAllowedRepository operationAllowedRepository = _applicationContext.getBean(OperationAllowedRepository.class);
            GroupRepository groupRepository = _applicationContext.getBean(GroupRepository.class);
            List<OperationAllowed> operationsAllowed = operationAllowedRepository.findAllById_MetadataId(id$);

            for (OperationAllowed operationAllowed : operationsAllowed) {
                OperationAllowedId operationAllowedId = operationAllowed.getId();
                int groupId = operationAllowedId.getGroupId();
                int operationId = operationAllowedId.getOperationId();

                moreFields.add(SearchManager.makeField("_op" + operationId, String.valueOf(groupId), true, true));
                if(operationId == ReservedOperation.view.getId()) {
                    Group g = groupRepository.findOne(groupId);
                    if (g != null) {
                        moreFields.add(SearchManager.makeField("_groupPublished", g.getName(), true, true));
                    }
                }
            }

            for (MetadataCategory category : fullMd.getCategories()) {
                moreFields.add(SearchManager.makeField("_cat", category.getName(), true, true));
            }

            final MetadataStatusRepository statusRepository = _applicationContext.getBean(MetadataStatusRepository.class);
View Full Code Here

     * @param id
     * @return
     * @throws Exception
     */
    public String getMetadataSchema(String id) throws Exception {
        Metadata md = _metadataRepository.findOne(id);

        if (md == null) {
            throw new IllegalArgumentException("Metadata not found for id : " +id);
        } else {
            // get metadata
            return md.getDataInfo().getSchemaId();
        }
    }
View Full Code Here

     * @param id
     * @return
     * @throws Exception
     */
    public @Nullable String getMetadataUuid(@Nonnull String id) throws Exception {
        Metadata metadata = _metadataRepository.findOne(id);

        if (metadata == null)
            return null;

        return metadata.getUuid();
    }
View Full Code Here

TOP

Related Classes of org.fao.geonet.domain.Metadata

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.