001package org.kuali.ole.repository;
002
003import org.apache.commons.io.FileUtils;
004import org.junit.Ignore;
005import org.junit.Test;
006import org.kuali.ole.BaseTestCase;
007import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
008import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
009import org.kuali.ole.docstore.model.xmlpojo.ingest.Response;
010import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler;
011import org.kuali.ole.docstore.service.BeanLocator;
012import org.kuali.ole.docstore.service.DocumentIndexer;
013import org.kuali.ole.docstore.service.DocumentIngester;
014import org.kuali.ole.docstore.service.IngestNIndexHandlerService;
015import org.kuali.ole.logger.DocStoreLogger;
016
017import java.io.File;
018
019/**
020 * Created with IntelliJ IDEA.
021 * User: ?
022 * Date: 1/15/13
023 * Time: 11:35 AM
024 * To change this template use File | Settings | File Templates.
025 */
026@Ignore
027@Deprecated
028public class DocumentStoreManager_UT extends BaseTestCase {
029
030    DocStoreLogger docStoreLogger = new DocStoreLogger(this.getClass().getName());
031
032    @Test
033    public void testDocumentStoreManager() throws Exception {
034        DocumentStoreManager documentStoreManager = BeanLocator.getDocumentStoreManager();
035        File inputDir = new File(this.getClass().getResource("/org/kuali/ole/repository/request.xml").toURI());
036        String input = FileUtils.readFileToString(inputDir);
037        RequestHandler requestHandler = new RequestHandler();
038        Request request = requestHandler.toObject(input);
039        IngestNIndexHandlerService ingestNIndexHandlerService = new IngestNIndexHandlerService();
040        ingestNIndexHandlerService.setRequestHandler(requestHandler);
041        ingestNIndexHandlerService.setDocumentIndexer(new DocumentIndexer());
042        ingestNIndexHandlerService.setDocumentIngester(new DocumentIngester());
043        RequestDocument requestDocument = request.getRequestDocuments().get(0);
044        Response xmlResponse = ingestNIndexHandlerService.ingestNIndexRequestDocuments(request);
045        docStoreLogger.log("Response :" + xmlResponse);
046        DeleteManager deleteManager = (DeleteManager) BeanLocator.getBean("deleteManagerService");
047        CheckoutManager checkoutManager = (CheckoutManager) BeanLocator.getBean("checkoutManagerService");
048        CheckinManager checkinManager = (CheckinManager) BeanLocator.getBean("checkinManagerService");
049        documentStoreManager.setCheckinManager(checkinManager);
050        documentStoreManager.setDeleteManager(deleteManager);
051        documentStoreManager.setRequestHandler(requestHandler);
052        documentStoreManager.setCheckoutManager(checkoutManager);
053        documentStoreManager.updateRecord(requestDocument);
054        documentStoreManager.processDeleteRequest(input);
055        documentStoreManager.checkOutMultiPart(request);
056        documentStoreManager.addReference("1", "2", "ole-khuntly", "checkIn");
057        documentStoreManager.checkOut(requestDocument.getUuid(), requestDocument.getUser(), requestDocument.getOperation());
058        documentStoreManager.checkOutBinary(requestDocument.getUuid(), requestDocument.getUser(), requestDocument.getOperation(), requestDocument.getFormat());
059    }
060}