Guest and LDAP progress

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2127 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2006-01-17 14:17:39 +00:00
parent db5e800018
commit 4408850b7a
25 changed files with 535 additions and 15 deletions

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.importer;
import org.dom4j.io.XMLWriter;
public interface ExportSource
{
/**
* Generate XML suitable for use with the importer.
*
* @param writer
*/
public void generateExport(XMLWriter writer);
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.importer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.view.ImporterBinding;
import org.alfresco.service.cmr.view.ImporterService;
import org.alfresco.service.cmr.view.Location;
import org.alfresco.util.TempFileProvider;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
public class ExportSourceImporter implements ImporterJobSPI
{
private ImporterService importerService;
private ExportSource exportSource;
private StoreRef storeRef;
private String path;
public ExportSourceImporter()
{
super();
}
public void setImporterService(ImporterService importerService)
{
this.importerService = importerService;
}
public void setExportSource(ExportSource exportSource)
{
this.exportSource = exportSource;
}
public void doImport()
{
try
{
File tempFile = TempFileProvider.createTempFile("ExportSourceImporter-", ".xml");
Writer writer = new BufferedWriter(new FileWriter(tempFile));
XMLWriter xmlWriter = createXMLExporter(writer);
exportSource.generateExport(xmlWriter);
xmlWriter.close();
Reader reader = new BufferedReader(new FileReader(tempFile));
Location location = new Location(storeRef);
location.setPath(path);
importerService.importView(reader, location, REPLACE_BINDING, null);
reader.close();
}
catch (IOException io)
{
throw new ExportSourceImporterException("Failed to import", io);
}
}
private XMLWriter createXMLExporter(Writer writer)
{
// Define output format
OutputFormat format = OutputFormat.createPrettyPrint();
format.setNewLineAfterDeclaration(false);
format.setIndentSize(3);
format.setEncoding("UTF-8");
// Construct an XML Exporter
XMLWriter xmlWriter = new XMLWriter(writer, format);
return xmlWriter;
}
private static ImporterBinding REPLACE_BINDING = new ImporterBinding()
{
public UUID_BINDING getUUIDBinding()
{
return UUID_BINDING.REPLACE_EXISTING;
}
public String getValue(String key)
{
return null;
}
};
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.importer;
import org.alfresco.error.AlfrescoRuntimeException;
public class ExportSourceImporterException extends AlfrescoRuntimeException
{
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -2366069362776024153L;
public ExportSourceImporterException(String msgId)
{
super(msgId);
}
public ExportSourceImporterException(String msgId, Object[] msgParams)
{
super(msgId, msgParams);
}
public ExportSourceImporterException(String msgId, Throwable cause)
{
super(msgId, cause);
}
public ExportSourceImporterException(String msgId, Object[] msgParams, Throwable cause)
{
super(msgId, msgParams, cause);
}
}

View File

@@ -569,7 +569,7 @@ public class ImporterComponent
searchParameters.addStore(importedRef.context.getNodeRef().getStoreRef());
searchParameters.setLanguage(SearchService.LANGUAGE_LUCENE);
searchParameters.setQuery("PATH:\"" + importedRef.value + "\"");
searchParameters.excludeDataInTheCurrentTransaction(true);
searchParameters.excludeDataInTheCurrentTransaction(false);
ResultSet resultSet = searchService.query(searchParameters);
try
{

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.importer;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class ImporterJob implements Job
{
public ImporterJob()
{
super();
}
public void execute(JobExecutionContext executionContext) throws JobExecutionException
{
ImporterJobSPI importerJob = (ImporterJobSPI) executionContext.getJobDetail().getJobDataMap()
.get("bean");
if (importerJob != null)
{
importerJob.doImport();
}
}
}

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.importer;
public interface ImporterJobSPI
{
public void doImport();
}