Merged V2.1 to HEAD

6455: OpenOffice transformer and extractor register regardless of the initial connection state.
   6456: Fix for WCM-636 (Clicking OK twice while deleting web project results in exception)
   6457: Updated installers and associated config
   6458: AR-1669 Add getQnamePath to Javascript
   6459: Fix for AWC-1456 - Word and Excel documents were being stored as octet streams rather than their correct mimetype
   6460: Reverse order of reject & approve transitions, so that approve appears first in list of ui actions.
   6461: Removed Process.exe (often detected as a virus) and updated config wizard.
   6462: Switch to synchronous indexing for AVM by default
   6463: Better support to query the state of AVM indexes
   6464: Added Office 2007 document mimetypes and icons
   6465: Added Office 2007 icons without the typo this time


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6736 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-10 22:41:44 +00:00
parent 28d4278290
commit 1f3aabc6a0
17 changed files with 265 additions and 158 deletions

View File

@@ -80,25 +80,6 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
this.connection = connection;
}
private synchronized void connect()
{
if (isConnected())
{
// just leave it
}
else
{
try
{
connection.connect();
}
catch (ConnectException e)
{
logger.warn(e.getMessage());
}
}
}
/**
* Initialises the bean by establishing an UNO connection
*/
@@ -109,15 +90,6 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
// Base initialization
super.init();
// attempt a connection
connect();
// Only allow registration if the connection is good
if (!isConnected())
{
// Reconnections are only supported if the server is able to connection initially.
super.setRegistry(null);
}
}
/**
@@ -129,6 +101,19 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
return connection.isConnected();
}
/**
* Perform the default check, but also check if the OpenOffice connection is good.
*/
@Override
public boolean isSupported(String sourceMimetype)
{
if (!isConnected())
{
return false;
}
return super.isSupported(sourceMimetype);
}
@Override
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
{
@@ -146,35 +131,32 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
String sourceUrl = toUrl(tempFromFile, connection);
// UNO Interprocess Bridge *should* be thread-safe, but...
synchronized (connection)
XComponentLoader desktop = connection.getDesktop();
XComponent document = desktop.loadComponentFromURL(
sourceUrl,
"_blank",
0,
new PropertyValue[] { property("Hidden", Boolean.TRUE) });
if (document == null)
{
XComponentLoader desktop = connection.getDesktop();
XComponent document = desktop.loadComponentFromURL(
sourceUrl,
"_blank",
0,
new PropertyValue[] { property("Hidden", Boolean.TRUE) });
if (document == null)
{
throw new FileNotFoundException("could not open source document: " + sourceUrl);
}
try
{
XDocumentInfoSupplier infoSupplier = (XDocumentInfoSupplier) UnoRuntime.queryInterface(
XDocumentInfoSupplier.class, document);
XPropertySet propSet = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class,
infoSupplier
.getDocumentInfo());
throw new FileNotFoundException("could not open source document: " + sourceUrl);
}
try
{
XDocumentInfoSupplier infoSupplier = (XDocumentInfoSupplier) UnoRuntime.queryInterface(
XDocumentInfoSupplier.class, document);
XPropertySet propSet = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class,
infoSupplier
.getDocumentInfo());
putRawValue(KEY_TITLE, propSet.getPropertyValue("Title").toString(), rawProperties);
putRawValue(KEY_DESCRIPTION, propSet.getPropertyValue("Subject").toString(), rawProperties);
putRawValue(KEY_AUTHOR, propSet.getPropertyValue("Author").toString(), rawProperties);
}
finally
{
document.dispose();
}
putRawValue(KEY_TITLE, propSet.getPropertyValue("Title").toString(), rawProperties);
putRawValue(KEY_DESCRIPTION, propSet.getPropertyValue("Subject").toString(), rawProperties);
putRawValue(KEY_AUTHOR, propSet.getPropertyValue("Author").toString(), rawProperties);
}
finally
{
document.dispose();
}
// Done
return rawProperties;
@@ -188,14 +170,6 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
return fic.getFileURLFromSystemPath("", file.getAbsolutePath());
}
public double getReliability(String sourceMimetype)
{
if (isConnected())
return super.getReliability(sourceMimetype);
else
return 0.0;
}
private static PropertyValue property(String name, Object value)
{
PropertyValue property = new PropertyValue();