Merged V3.0 to HEAD

11982: Fix for ETHREEOH-906 - Writing the TICKET value directly to the page during template processing is a potential XSS security hole.
   11983: Added back .html suffix to plain HTML form upload api call - added code comment to explain why it's there.
   11984: Added debug/info level logging to Invite process.
   11985: ETHREEOH-184: thumbnail assocs do not double up on check-in and thumbnail updates are done in one action
   11986: Fix for ETHREEOH-905 - missing url encoding step for user password during webscript based login process.
   11995: Unit test fixed up, fallout from runAs merge.
   11998: Part of a fix for ETHREEOH-546 - Cannot save document to the any space for Microsoft Office
   11999: Merged V2.2 to V3.0
      11996: Fix for open Lucene ResultSet memory leaks
   12000: ETHREEOH-692 - It is impossible to login to Alfresco from Microsoft Office add-in using NTLM authentication. ETHREEOH-546 - Cannot save document to the any space for Microsoft Office.
   12001: Paging enabled by default in all Document Libraries

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12494 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-12-18 15:08:14 +00:00
parent 26d7b9669f
commit 7bc8557a1e
11 changed files with 232 additions and 122 deletions

View File

@@ -1009,6 +1009,7 @@ public class AdminNodeBrowseBean implements Serializable
{ {
rows.setWrappedData(resultSet.getChildAssocRefs()); rows.setWrappedData(resultSet.getChildAssocRefs());
length = resultSet.length(); length = resultSet.length();
resultSet.close();
} }
} }

View File

@@ -220,11 +220,19 @@ public class AddUsersDialog extends BaseDialogBean
query.append("*\" @").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:userName:"); query.append("*\" @").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:userName:");
query.append(term); query.append(term);
query.append("*"); query.append("*");
List<NodeRef> nodes;
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query( ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(
Repository.getStoreRef(), Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, SearchService.LANGUAGE_LUCENE,
query.toString()); query.toString());
List<NodeRef> nodes = resultSet.getNodeRefs(); try
{
nodes = resultSet.getNodeRefs();
}
finally
{
resultSet.close();
}
ArrayList<SelectItem> itemList = new ArrayList<SelectItem>(nodes.size()); ArrayList<SelectItem> itemList = new ArrayList<SelectItem>(nodes.size());
for (NodeRef personRef : nodes) for (NodeRef personRef : nodes)

View File

@@ -37,6 +37,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthenticationService;
@@ -154,7 +155,16 @@ public class DeleteUserDialog extends BaseDialogBean
params.addStore(Repository.getStoreRef()); params.addStore(Repository.getStoreRef());
params.setQuery(query); params.setQuery(query);
List<NodeRef> people = this.getSearchService().query(params).getNodeRefs(); ResultSet results = this.getSearchService().query(params);
List<NodeRef> people;
try
{
people = results.getNodeRefs();
}
finally
{
results.close();
}
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Found " + people.size() + " users"); logger.debug("Found " + people.size() + " users");

View File

@@ -41,6 +41,7 @@ import org.alfresco.repo.search.impl.lucene.QueryParser;
import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
@@ -343,7 +344,16 @@ public class UsersDialog extends BaseDialogBean implements IContextListener, Cha
params.addStore(Repository.getStoreRef()); params.addStore(Repository.getStoreRef());
params.setQuery(query.toString()); params.setQuery(query.toString());
List<NodeRef> people = properties.getSearchService().query(params).getNodeRefs(); ResultSet results = properties.getSearchService().query(params);
List<NodeRef> people;
try
{
people = results.getNodeRefs();
}
finally
{
results.close();
}
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Found " + people.size() + " users"); logger.debug("Found " + people.size() + " users");

View File

@@ -272,13 +272,20 @@ public class EditFormWizard
for (WebProject wp: webProjects) for (WebProject wp: webProjects)
{ {
ResultSet results = searchRenderingEngineTemplateInWebProject(wp, retd.getName()); ResultSet results = searchRenderingEngineTemplateInWebProject(wp, retd.getName());
for (int i=0; i<results.length(); i++) try
{ {
NodeRef webformTemplateNodeRef = results.getNodeRef(i); for (int i=0; i<results.length(); i++)
NodeRef webformNodeRef = getNodeService().getPrimaryParent(webformTemplateNodeRef).getParentRef(); {
getNodeService().removeChild(webformNodeRef, webformTemplateNodeRef); NodeRef webformTemplateNodeRef = results.getNodeRef(i);
if (LOGGER.isDebugEnabled()) NodeRef webformNodeRef = getNodeService().getPrimaryParent(webformTemplateNodeRef).getParentRef();
LOGGER.debug(webformNodeRef); getNodeService().removeChild(webformNodeRef, webformTemplateNodeRef);
if (LOGGER.isDebugEnabled())
LOGGER.debug(webformNodeRef);
}
}
finally
{
results.close();
} }
} }
} }
@@ -324,26 +331,33 @@ public class EditFormWizard
ResultSet webforms = getSearchService().query(wp.getNodeRef().getStoreRef(), SearchService.LANGUAGE_LUCENE, query); ResultSet webforms = getSearchService().query(wp.getNodeRef().getStoreRef(), SearchService.LANGUAGE_LUCENE, query);
props.clear(); try
props.put(WCMAppModel.PROP_BASE_RENDERING_ENGINE_TEMPLATE_NAME,
retd.getName());
for (int i=0; i<webforms.length(); i++)
{ {
if (LOGGER.isDebugEnabled()) props.clear();
LOGGER.debug("WebForm NodeRef: " + webforms.getNodeRef(i)); props.put(WCMAppModel.PROP_BASE_RENDERING_ENGINE_TEMPLATE_NAME,
retd.getName());
for (int i=0; i<webforms.length(); i++)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("WebForm NodeRef: " + webforms.getNodeRef(i));
NodeRef templateRef = getNodeService().createNode(webforms.getNodeRef(i), NodeRef templateRef = getNodeService().createNode(webforms.getNodeRef(i),
WCMAppModel.ASSOC_WEBFORMTEMPLATE, WCMAppModel.ASSOC_WEBFORMTEMPLATE,
WCMAppModel.ASSOC_WEBFORMTEMPLATE, WCMAppModel.ASSOC_WEBFORMTEMPLATE,
WCMAppModel.TYPE_WEBFORMTEMPLATE, WCMAppModel.TYPE_WEBFORMTEMPLATE,
props).getChildRef(); props).getChildRef();
if (retd.getOutputPathPatternForRendition() != null) if (retd.getOutputPathPatternForRendition() != null)
{ {
props.clear(); props.clear();
props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN, retd.getOutputPathPatternForRendition()); props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN, retd.getOutputPathPatternForRendition());
getNodeService().addAspect(templateRef, WCMAppModel.ASPECT_OUTPUT_PATH_PATTERN, props); getNodeService().addAspect(templateRef, WCMAppModel.ASPECT_OUTPUT_PATH_PATTERN, props);
} }
}
}
finally
{
webforms.close();
} }
} }
} }
@@ -380,7 +394,7 @@ public class EditFormWizard
return result; return result;
} }
/** /**
* Action handler called when the Remove button is pressed to remove a * Action handler called when the Remove button is pressed to remove a
* rendering engine * rendering engine
*/ */

View File

@@ -492,14 +492,22 @@ public class RegenerateRenditionsWizard
LOGGER.debug("running query " + query); LOGGER.debug("running query " + query);
sp.setQuery(query.toString()); sp.setQuery(query.toString());
final ResultSet rs = getSearchService().query(sp); final ResultSet rs = getSearchService().query(sp);
final List<FormInstanceData> result = new ArrayList<FormInstanceData>(rs.length()); try
for (final ResultSetRow row : rs)
{ {
final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond(); final List<FormInstanceData> result = new ArrayList<FormInstanceData>(rs.length());
final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath); for (final ResultSetRow row : rs)
result.add(getFormsService().getFormInstanceData(-1, previewAvmPath)); {
final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond();
final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath);
result.add(getFormsService().getFormInstanceData(-1, previewAvmPath));
}
return result;
}
finally
{
rs.close();
} }
return result;
} }
private List<Rendition> getRelatedRenditions(final WebProject webProject, final RenderingEngineTemplate ret) private List<Rendition> getRelatedRenditions(final WebProject webProject, final RenderingEngineTemplate ret)
@@ -516,14 +524,21 @@ public class RegenerateRenditionsWizard
LOGGER.debug("running query " + query); LOGGER.debug("running query " + query);
sp.setQuery(query.toString()); sp.setQuery(query.toString());
final ResultSet rs = getSearchService().query(sp); final ResultSet rs = getSearchService().query(sp);
final List<Rendition> result = new ArrayList<Rendition>(rs.length()); try
for (final ResultSetRow row : rs)
{ {
final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond(); final List<Rendition> result = new ArrayList<Rendition>(rs.length());
final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath); for (final ResultSetRow row : rs)
result.add(getFormsService().getRendition(-1, previewAvmPath)); {
final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond();
final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath);
result.add(getFormsService().getRendition(-1, previewAvmPath));
}
return result;
}
finally
{
rs.close();
} }
return result;
} }
private List<Rendition> regenerateRenditions() private List<Rendition> regenerateRenditions()
@@ -596,65 +611,72 @@ public class RegenerateRenditionsWizard
LOGGER.debug("running query " + query); LOGGER.debug("running query " + query);
sp.setQuery(query.toString()); sp.setQuery(query.toString());
final ResultSet rs = getSearchService().query(sp); final ResultSet rs = getSearchService().query(sp);
if (LOGGER.isDebugEnabled()) try
LOGGER.debug("received " + rs.length() + " results");
final List<Rendition> result = new ArrayList<Rendition>(rs.length());
for (final ResultSetRow row : rs)
{ {
final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond(); if (LOGGER.isDebugEnabled())
final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath); LOGGER.debug("received " + rs.length() + " results");
if (this.regenerateScope.equals(REGENERATE_SCOPE_ALL) ||
this.regenerateScope.equals(REGENERATE_SCOPE_FORM)) final List<Rendition> result = new ArrayList<Rendition>(rs.length());
for (final ResultSetRow row : rs)
{ {
final FormInstanceData fid = getFormsService().getFormInstanceData(-1, previewAvmPath); final String avmPath = AVMNodeConverter.ToAVMVersionPath(row.getNodeRef()).getSecond();
try final String previewAvmPath = AVMUtil.getCorrespondingPathInPreviewStore(avmPath);
if (this.regenerateScope.equals(REGENERATE_SCOPE_ALL) ||
this.regenerateScope.equals(REGENERATE_SCOPE_FORM))
{ {
final List<FormInstanceData.RegenerateResult> regenResults = fid.regenerateRenditions(); final FormInstanceData fid = this.formsService.getFormInstanceData(-1, previewAvmPath);
for (final FormInstanceData.RegenerateResult rr : regenResults) try
{ {
if (rr.getException() != null) final List<FormInstanceData.RegenerateResult> regenResults = fid.regenerateRenditions();
for (final FormInstanceData.RegenerateResult rr : regenResults)
{ {
Utils.addErrorMessage("error regenerating rendition using " + if (rr.getException() != null)
rr.getRenderingEngineTemplate().getName() + {
": " + rr.getException().getMessage(), Utils.addErrorMessage("error regenerating rendition using " +
rr.getException()); rr.getRenderingEngineTemplate().getName() +
} ": " + rr.getException().getMessage(),
else rr.getException());
{ }
result.add(rr.getRendition()); else
} {
if (rr.getRendition() != null) result.add(rr.getRendition());
{ }
getAvmLockingService().removeLock(AVMUtil.getStoreId(rr.getRendition().getPath()), if (rr.getRendition() != null)
AVMUtil.getStoreRelativePath(rr.getRendition().getPath())); {
this.avmLockingService.removeLock(AVMUtil.getStoreId(rr.getRendition().getPath()),
AVMUtil.getStoreRelativePath(rr.getRendition().getPath()));
}
} }
} }
catch (FormNotFoundException fnfe)
{
Utils.addErrorMessage("error regenerating renditions of " + fid.getPath() +
": " + fnfe.getMessage(),
fnfe);
}
} }
catch (FormNotFoundException fnfe) else
{ {
Utils.addErrorMessage("error regenerating renditions of " + fid.getPath() + final Rendition r = this.formsService.getRendition(-1, previewAvmPath);
": " + fnfe.getMessage(), try
fnfe); {
} r.regenerate();
} result.add(r);
else }
{ catch (Exception e)
final Rendition r = getFormsService().getRendition(-1, previewAvmPath); {
try Utils.addErrorMessage("error regenerating rendition using " +
{ r.getRenderingEngineTemplate().getName() +
r.regenerate(); ": " + e.getMessage(),
result.add(r); e);
} }
catch (Exception e)
{
Utils.addErrorMessage("error regenerating rendition using " +
r.getRenderingEngineTemplate().getName() +
": " + e.getMessage(),
e);
} }
} }
return result;
}
finally
{
rs.close();
} }
return result;
} }
} }

View File

@@ -259,7 +259,15 @@ public class SetPermissionsDialog extends UpdatePermissionsDialog
query.append(term); query.append(term);
query.append("*"); query.append("*");
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(Repository.getStoreRef(), SearchService.LANGUAGE_LUCENE, query.toString()); ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(Repository.getStoreRef(), SearchService.LANGUAGE_LUCENE, query.toString());
List<NodeRef> nodes = resultSet.getNodeRefs(); List<NodeRef> nodes;
try
{
nodes = resultSet.getNodeRefs();
}
finally
{
resultSet.close();
}
for (int index = 0; index < nodes.size(); index++) for (int index = 0; index < nodes.size(); index++)
{ {

View File

@@ -392,7 +392,15 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
} }
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(searchParams); ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(searchParams);
List<NodeRef> nodes = resultSet.getNodeRefs(); List<NodeRef> nodes;
try
{
nodes = resultSet.getNodeRefs();
}
finally
{
resultSet.close();
}
// set the maximum users returned flag if appropriate // set the maximum users returned flag if appropriate
if (nodes.size() == maxResults) if (nodes.size() == maxResults)

View File

@@ -128,6 +128,7 @@ public abstract class BaseReassignDialog extends BaseDialogBean
SelectItem[] items; SelectItem[] items;
UserTransaction tx = null; UserTransaction tx = null;
ResultSet resultSet = null;
try try
{ {
tx = Repository.getUserTransaction(context, true); tx = Repository.getUserTransaction(context, true);
@@ -143,7 +144,7 @@ public abstract class BaseReassignDialog extends BaseDialogBean
query.append("*\" @").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:userName:"); query.append("*\" @").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:userName:");
query.append(term); query.append(term);
query.append("*"); query.append("*");
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query( resultSet = Repository.getServiceRegistry(context).getSearchService().query(
Repository.getStoreRef(), SearchService.LANGUAGE_LUCENE, query.toString()); Repository.getStoreRef(), SearchService.LANGUAGE_LUCENE, query.toString());
List<NodeRef> nodes = resultSet.getNodeRefs(); List<NodeRef> nodes = resultSet.getNodeRefs();
@@ -175,6 +176,13 @@ public abstract class BaseReassignDialog extends BaseDialogBean
items = new SelectItem[0]; items = new SelectItem[0];
} }
finally
{
if (resultSet != null)
{
resultSet.close();
}
}
return items; return items;
} }

View File

@@ -218,17 +218,24 @@ public final class FormsService
final ResultSet rs = this.searchService.query(Repository.getStoreRef(), final ResultSet rs = this.searchService.query(Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, SearchService.LANGUAGE_LUCENE,
query); query);
if (LOGGER.isDebugEnabled()) try
LOGGER.debug("found " + rs.length() + " form definitions");
final Collection<Form> result = new ArrayList<Form>(rs.length());
for (final ResultSetRow row : rs)
{ {
result.add(this.getForm(row.getNodeRef())); if (LOGGER.isDebugEnabled())
} LOGGER.debug("found " + rs.length() + " form definitions");
QuickSort sorter = new QuickSort((List)result, "name", true, IDataContainer.SORT_CASEINSENSITIVE); final Collection<Form> result = new ArrayList<Form>(rs.length());
sorter.sort(); for (final ResultSetRow row : rs)
{
result.add(this.getForm(row.getNodeRef()));
}
QuickSort sorter = new QuickSort((List)result, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return result; return result;
}
finally
{
rs.close();
}
} }
/** /**
@@ -400,15 +407,22 @@ public final class FormsService
final ResultSet rs = this.searchService.query(Repository.getStoreRef(), final ResultSet rs = this.searchService.query(Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, SearchService.LANGUAGE_LUCENE,
query); query);
if (LOGGER.isDebugEnabled()) try
{ {
LOGGER.debug("query " + query + " returned " + rs.length() + " results"); if (LOGGER.isDebugEnabled())
{
LOGGER.debug("query " + query + " returned " + rs.length() + " results");
}
final List<NodeRef> result = new ArrayList<NodeRef>(rs.length());
for (final ResultSetRow row : rs)
{
result.add(row.getNodeRef());
}
return result;
} }
final List<NodeRef> result = new ArrayList<NodeRef>(rs.length()); finally
for (final ResultSetRow row : rs)
{ {
result.add(row.getNodeRef()); rs.close();
} }
return result;
} }
} }

View File

@@ -145,18 +145,25 @@ public class Schema2XFormsProperties
searchService.query(Repository.getStoreRef(), searchService.query(Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, SearchService.LANGUAGE_LUCENE,
"PATH:\"" + name + "\""); "PATH:\"" + name + "\"");
LOGGER.debug("search returned " + results.length() + try
" results");
if (results.length() == 1)
{ {
final NodeRef nr = results.getNodeRef(0); LOGGER.debug("search returned " + results.length() +
final ContentReader reader = " results");
contentService.getReader(nr, ContentModel.PROP_CONTENT); if (results.length() == 1)
return reader.getContentInputStream(); {
final NodeRef nr = results.getNodeRef(0);
final ContentReader reader =
contentService.getReader(nr, ContentModel.PROP_CONTENT);
return reader.getContentInputStream();
}
else
{
return super.getResourceAsStream(name);
}
} }
else finally
{ {
return super.getResourceAsStream(name); results.close();
} }
} }
}; };