Exemple #1
0
        private bool UpdateMetadata(ObjDigital obj, string[] logMessage, out string newTimestamp)
        {
            DublinCoreExporter dcExporter;
            MetsExporter       metsExporter;

            newTimestamp = null;

            try
            {
                // Create new versions of XML for METS and DC
                if (obj.GetType() == typeof(ObjDigComposto))
                {
                    var objComposto = obj as ObjDigComposto;
                    dcExporter   = new DublinCoreExporter(objComposto);
                    metsExporter = new MetsExporter(objComposto, gisaOperator, logMessage);
                }
                else
                {
                    var objSimples = obj as ObjDigSimples;
                    dcExporter   = new DublinCoreExporter(objSimples);
                    metsExporter = new MetsExporter(objSimples, gisaOperator, logMessage);
                }
            }
            catch (Exception ex)
            {
                Trace.Write("Erro ao recriar DC/METS do " + obj.pid + ": ");
                Trace.WriteLine(ex.ToString());
                return(false);
            }

            // Reingerir o DC e o METS
            try {
                manager.modifyDatastreamByValue(obj.pid, "DC", null, null, "text/xml", null, ConvertToBytes(dcExporter.DublinCore), "MD5", null, "Atualização de metadados", false);
                newTimestamp = manager.modifyDatastreamByValue(obj.pid, "METS", null, null, "text/xml", null, ConvertToBytes(metsExporter.METS), "MD5", null, "Atualização de metadados", false);
                return(true);
            } catch (Exception ex) {
                Trace.Write("Erro ao reingerir DC/METS do " + obj.pid + ": ");
                Trace.WriteLine(ex.ToString());
                return(false);
            }
        }
Exemple #2
0
        private void DoTheFOXML(ObjDigital obj)
        {
            var title = obj.titulo;

            // Construir os headers
            foxml            = new FoxmlDigitalObject("1.1", this.pid);
            foxml.properties = new FoxmlObjectProperties();
            foxml.properties.AddProperty(new FoxmlProperty("info:fedora/fedora-system:def/model#state", "A"));
            foxml.properties.AddProperty(new FoxmlProperty("info:fedora/fedora-system:def/model#label", title));

            // Add the DC datastream
            DublinCoreExporter dcXml;
            MetsExporter       metsXml;

            if (obj.GetType() == typeof(ObjDigSimples))
            {
                ObjDigSimples objSimples = obj as ObjDigSimples;
                metsXml = new MetsExporter(objSimples, userName, new string[] { "Ingestão do documento " + this.pid });
                dcXml   = new DublinCoreExporter(obj as ObjDigSimples);
            }
            else
            {
                ObjDigComposto objComposto = obj as ObjDigComposto;
                metsXml = new MetsExporter(objComposto, userName, new string[] { "Ingestão do documento " + this.pid });
                dcXml   = new DublinCoreExporter(obj as ObjDigComposto);
            }

            FoxmlDatastream        dcStream  = new FoxmlDatastream("DC", FoxmlDatastreamState.Active, FoxmlControlGroup.InlineXML, true);
            FoxmlDatastreamVersion dcStream1 = new FoxmlDatastreamVersion("DC.0", "http://www.openarchives.org/OAI/2.0/oai_dc/", "text/xml", "Metadados em Dublin Core", null, null);

            dcStream1.inlineXML     = dcXml.DublinCore;
            dcStream1.contentDigest = new FoxmlContentDigest(FoxmlChecksumTypes.DEFAULT, null);
            dcStream.AddVersion(dcStream1);
            foxml.AddDatastream(dcStream);

            // Add the RELS-EXT datastream
            FoxmlDatastream        relsStream  = new FoxmlDatastream("RELS-EXT", FoxmlDatastreamState.Active, FoxmlControlGroup.InlineXML, true);
            FoxmlDatastreamVersion relsStream1 = new FoxmlDatastreamVersion("RELS-EXT.0", "info:fedora/fedora-system:FedoraRELSExt-1.0", "application/rdf+xml", "RDF Statements about this object", null, null);

            relsStream1.inlineXML = GetRdf(this.pid, this.nmspace);
            relsStream.AddVersion(relsStream1);
            foxml.AddDatastream(relsStream);

            // Add the METS datastream for this document
            FoxmlDatastream        metsStream  = new FoxmlDatastream("METS", FoxmlDatastreamState.Active, FoxmlControlGroup.InlineXML, true);
            FoxmlDatastreamVersion metsStream1 = new FoxmlDatastreamVersion("METS.0", "http://www.loc.gov/METS/", "text/xml", "Metadados adicionais em METS", null, null);

            metsStream1.inlineXML     = metsXml.METS;
            metsStream1.contentDigest = new FoxmlContentDigest(FoxmlChecksumTypes.DEFAULT, null);
            metsStream.AddVersion(metsStream1);
            foxml.AddDatastream(metsStream);

            // Add the content datastreams
            FoxmlDatastream        datastream;
            FoxmlDatastreamVersion dsversion;

            if (obj.GetType() == typeof(ObjDigSimples))
            {
                int           cnt        = 1;
                ObjDigSimples objSimples = obj as ObjDigSimples;

                foreach (Anexo s in objSimples.fich_associados)
                {
                    string uName = s.dataStreamID;
                    datastream = new FoxmlDatastream(uName, FoxmlDatastreamState.Active, FoxmlControlGroup.ExternallyReferenceContent, true);
                    dsversion  = new FoxmlDatastreamVersion(uName + ".0", null, s.mimeType, null, null, null);
                    dsversion.contentLocation = new FoxmlContentLocation(s.url, "URL");
                    dsversion.contentDigest   = new FoxmlContentDigest(FoxmlChecksumTypes.DEFAULT, null);
                    datastream.AddVersion(dsversion);
                    foxml.AddDatastream(datastream);
                    cnt++;
                }
            }
        }