Changeset 25542


Ignore:
Timestamp:
2012-05-08T15:04:31+12:00 (12 years ago)
Author:
sjm84
Message:

Adding a dc.Title of "UNTITLED DOCUMENT" to new documents

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSDocumentModel.java

    r25074 r25542  
    130130            return;
    131131        }
    132 
    133         //If the document does not have an OID specified then generate one
     132       
     133        //If the collection is not specified then we cannot continue
    134134        if (oid == null || oid.equals(""))
    135135        {
    136             oid = generateOID();
    137         }
    138         else if (archiveCheckDocumentOrSectionExists(oid, collection, userContext))
     136            _errorStatus = ERROR_OID_NOT_SPECIFIED;
     137            return;
     138        }
     139
     140        if (archiveCheckDocumentOrSectionExists(oid, collection, userContext))
    139141        {
    140142            _errorStatus = ERROR_DESTINATION_DOCUMENT_OR_SECTION_ALREADY_EXISTS;
     
    673675        try
    674676        {
    675             Document docXML = null;
    676 
    677             String filePath = archiveGetDocumentFilePath(oid, collection, userContext);
    678             File docFile = new File(filePath);
    679             if (!docFile.exists() && !docFile.createNewFile())
     677            String s = File.separator;
     678           
     679            String docFolderPath = _siteHome + s + "collect" + s + collection + s + "import" + s + oid;
     680            File docFolder = new File(docFolderPath);
     681           
     682            if (!docFolder.exists())
     683            {
     684                if(!docFolder.mkdirs())
     685                {
     686                    _errorStatus = ERROR_DOC_XML_COULD_NOT_BE_CREATED;
     687                    return;
     688                }
     689            }
     690           
     691            File docFile = new File(docFolderPath + s + "doc.xml");
     692            if(!docFile.exists() && !docFile.createNewFile())
    680693            {
    681694                _errorStatus = ERROR_DOC_XML_COULD_NOT_BE_CREATED;
     
    687700            bw.write("<!DOCTYPE Archive SYSTEM \"http://greenstone.org/dtd/Archive/1.0/Archive.dtd\">\n");
    688701            bw.write("<Archive>\n");
     702            bw.write("  <Section>\n");
     703            bw.write("    <Description>\n");
     704            bw.write("      <Metadata name=\"Identifier\">" + oid + "</Metadata>\n");
     705            bw.write("      <Metadata name=\"dc.Title\">UNTITLED DOCUMENT</Metadata>\n");
     706            bw.write("    </Description>\n");
     707            bw.write("    <Content>\n");
     708            bw.write("    </Content>\n");
     709            bw.write("  </Section>\n");
    689710            bw.write("</Archive>\n");
    690711            bw.close();
    691712
     713            Document docXML = null;
    692714            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    693715            DocumentBuilder db = dbf.newDocumentBuilder();
     
    18311853    }
    18321854
    1833     protected static String generateOID()
    1834     {
    1835         return "temp";
    1836     }
    1837 
    18381855    public boolean copyDirectory(File src, File dest)
    18391856    {
Note: See TracChangeset for help on using the changeset viewer.