Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.Metadata


        }

        // Set owner for all records to be modified.
        for (Integer i : metadata) {
            final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
            final Metadata metadata1 = metadataRepository.findOne(i);
            metadata1.getSourceInfo().setGroupOwner(targetGrp).setOwner(targetUsr);
            metadataRepository.save(metadata1);
        }

        dm.flush();
View Full Code Here


            throws Exception {
        String uuid = Util.getParam(params, Params.UUID);
       
        // Retrieve template
        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        final Metadata metadata = metadataRepository.findOneByUuid(uuid);

        if (metadata.getDataInfo().getType() != MetadataType.SUB_TEMPLATE) {
            throw new IllegalArgumentException("Metadata uuid="+uuid+" is not a subtemplate");
        }

        Element tpl = metadata.getXmlData(false);
       
       
        // Processing parameters process=xpath~value.
        // xpath must point to an Element or an Attribute.
        List<?> replaceList = params.getChildren(Params.PROCESS);
View Full Code Here

    if (context.isDebugEnabled())
      context.debug("Extracting subtemplates from metadata with uuid:"+ uuid);

        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Metadata metadataEntity = metadataRepository.findOneByUuid(uuid);

    // Metadata may have been deleted since selection
    if (metadataEntity != null) {
            String id   = "" + metadataEntity.getId();

      if (!accessMan.isOwner(context, id)) {
        notOwner.add(metadataEntity.getId());
      } else {
        extractSubtemplates(context, dataMan, metadataEntity, category, xpath, getTit, xpathTit, doChanges, metadata, subtemplates, response);
      }
    } else {
      if(context.isDebugEnabled())
View Full Code Here

         dataMan.updateMetadata(context, id, template, validate, ufo, index, language, df.format(date), false);

         int iId = Integer.parseInt(id);

         final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
         Metadata metadata = metadataRepository.findOne(iId);
         OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
         repository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, iId);
         addPrivileges(id, params.privileges, localGroups, dataMan, context, log);

         metadata.getCategories().clear();
         addCategories(metadata, params.categories, localCateg, context, log, null);

         if(doExt) {
             dataMan.setTemplateExt(iId, MetadataType.SUB_TEMPLATE);
             dataMan.setHarvestedExt(iId, params.uuid, Optional.of(harvestUri));
View Full Code Here

                String id = dm.getMetadataId(uuid);

                context.info("Attempting to set metadata owner on: " + id);

                //--- check existence and 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 {

                    //-- Get existing owner and privileges for that owner - note that
                    //-- owners don't actually have explicit permissions - only their
                    //-- group does which is why we have an ownerGroup (parameter groupid)
                    Integer sourceUsr = info.getSourceInfo().getOwner();
                    Integer sourceGrp = info.getSourceInfo().getGroupOwner();
                    Vector<OperationAllowedId> sourcePriv =
                            retrievePrivileges(context, id, "" + sourceUsr, "" + sourceGrp);

                    // -- Set new privileges for new owner from privileges of the old
                    // -- owner, if none then set defaults
View Full Code Here

    public static Record buildRecordStat(ServiceContext context, Specification<Metadata> spec/*String select, Object selectVal*/,
                                         String prefix) throws Exception {
        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        SchemaManager sm = gc.getBean(SchemaManager.class);

        Metadata metadata = context.getBean(MetadataRepository.class).findOne(spec);
        if (metadata == null)
            throw new IdDoesNotExistException(spec.toString());

        String uuid = metadata.getUuid();
        final MetadataDataInfo dataInfo = metadata.getDataInfo();
        String schema = dataInfo.getSchemaId();
        String changeDate = dataInfo.getChangeDate().getDateAndTime();
        String data = metadata.getData();

        Element md = Xml.loadString(data, false);

        //--- try to disseminate format

        if (prefix.equals(schema)) {
            Attribute schemaLocAtt = sm.getSchemaLocation(schema, context);
            if (schemaLocAtt != null) {
                if (md.getAttribute(schemaLocAtt.getName(), schemaLocAtt.getNamespace()) == null) {
                    md.setAttribute(schemaLocAtt);
                    // make sure namespace declaration for schemalocation is present -
                    // remove it first (does nothing if not there) then add it
                    md.removeNamespaceDeclaration(schemaLocAtt.getNamespace());
                    md.addNamespaceDeclaration(schemaLocAtt.getNamespace());
                }
            }
        } else {
            String schemaDir = sm.getSchemaDir(schema);
            if (Lib.existsConverter(schemaDir, prefix)) {
                final String siteURL = context.getBean(SettingManager.class).getSiteURL(context);
                Element env = Lib.prepareTransformEnv(uuid, changeDate, context.getBaseUrl(), siteURL, gc.getBean(SettingManager.class)
                        .getSiteName());
                md = Lib.transform(schemaDir, env, md, prefix + ".xsl");
            } else {
                throw new CannotDisseminateFormatException("Unknown prefix : " + prefix);
            }
        }

        //--- build header and set some infos

        Header h = new Header();

        h.setIdentifier(uuid);
        h.setDateStamp(new ISODate(changeDate));

        for (MetadataCategory metadataCategory : metadata.getCategories()) {
            h.addSet(metadataCategory.getName());
        }

        //--- build and return record

View Full Code Here

            throw new IllegalArgumentException("Group with identifier '" + groupOwner + "' not found.");
        }

        //--- Update groupOwner
        MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Metadata metadata = metadataRepository.findOne(iLocalId);
        metadata.getSourceInfo().setGroupOwner(iGroupOwner);
        metadataRepository.save(metadata);

        //--- index metadata
        dataMan.indexMetadata(id, true);
View Full Code Here

  private Header buildHeader(ServiceContext context, int id, String prefix) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SchemaManager   sm = gc.getBean(SchemaManager.class);

        final Metadata metadata = gc.getBean(MetadataRepository.class).findOne(id);

    //--- maybe the metadata has been removed

    if (metadata == null) {
      return null;
        }

    String uuid       = metadata.getUuid();
    String schema     = metadata.getDataInfo().getSchemaId();
    ISODate changeDate = metadata.getDataInfo().getChangeDate();

    //--- try to disseminate format if not by schema then by conversion

    if (!prefix.equals(schema)) {
      if (!Lib.existsConverter(sm.getSchemaDir(schema), prefix)) {
        return null;
      }
    }

    //--- build header and set some infos

    Header h = new Header();

    h.setIdentifier(uuid);
    h.setDateStamp(changeDate);

    //--- find and add categories (here called sets)

    for (MetadataCategory category : metadata.getCategories())
    {
      h.addSet(category.getName());
    }

    return h;
View Full Code Here

  //---------------------------------------------------------------------------

  private ISODate getEarliestDS(ServiceContext context) throws Exception
  {
        final Metadata oldestByChangeDate = context.getBean(MetadataRepository.class).findOneOldestByChangeDate();

    //--- if we don't have metadata, just return 'now'
    if (oldestByChangeDate == null)
      return new ISODate();

    return oldestByChangeDate.getDataInfo().getChangeDate();
  }
View Full Code Here

    boolean update = Util.getParam(params, Params.UPDATEONLY, "false").equals("true");

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

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

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

    //-----------------------------------------------------------------------
    //--- remove old operations

    boolean skip = false;

    //--- in case of owner, privileges for groups 0,1 and GUEST are disabled
    //--- and are not sent to the server. So we cannot remove them

    boolean isAdmin   = Profile.Administrator == us.getProfile();
    boolean isReviewer= Profile.Reviewer == us.getProfile();


    if (us.getUserIdAsInt() == info.getSourceInfo().getOwner() && !isAdmin && !isReviewer) {
      skip = true;
        }

    if (!update) {
      dm.deleteMetadataOper(context, id, skip);
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.