mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
12994: Merged V3.0 to V3.1 12931: Merged V2.2 to V3.0 12635: Fix for ETWOTWO-995: Diff performance degrades on large data sets 12742: Fix for ETWOTWO-981: WCM - regression - revert fails (eg. for content publisher) 12743: AVM - add missing tests to test suite & fix existing tests (including base setup) 12759: AVM - build/test fix - follow-on to r12742 12781: Fix PersonDAO - fixes AuthorityServiceTest which failed after adding AVMServicePermissionsTest 12932: Merged V2.2 to V3.0 12763: Support for ETWOTWO-975: AVMDifference now implements Comparable<AVMDifference> 12782: Fix for ETWOTWO-939: Content Contributor cannot edit their own items 12809: Test fixes after r 12782 12818: ETWOTWO-977 (Orphan Reaper) - removal of comment questioning cache interaction. 12933: Merged V2.2 to V3.0 12306: (record-only) Final set of XSS and HTML encoding fixes for ETWOONE-90 - already merged (see r12310) 12934: Merged V2.2 to V3.0 12311: (record-only) Fix for ETWOONE-389 - Current page number not always visible on the browse screen - already merged (see r12312) 12935: Merged V2.2 to V3.0 12320: (record-only) Fix for ETWOONE-87: Behavior of delete cascade - already merged (see r12324) 12322: (record-only) Fix merge issue (marked as Do Not Merge - see CHK-5607) 12936: Merged V2.2 to V3.0 12775: (record-only) ETHREEOH-872: Editing Email-notify-rules fails w/ ClassCastException (back-port of r11966) 12937: Merged V2.2 to V3.0 12780: Fixed ETWOTWO-1003: DuplicateChildNameException not generated correctly (on Oracle) 12820: Update to ETWOTWO-926 (WCM Form Inline callouts to Web Scripts) 12825: Further ETWOTWO-926 update: provide compatibility with old token scheme as the original patch has already made its way into 3.0.1 12850: ETWOTWO-975 - Show Conflicts in Modified Items List 12938: Fix merge typo (follow on from r12931) 12941: Fix merge typo (follow on from r12931) 12998: Cleaned up svn:mergeinfo entries ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/V3.0:r12931-12938,12941 Merged /alfresco/BRANCHES/V2.2:r12306,12311,12320,12322,12635,12742-12743,12759,12763,12775,12780-12782,12809,12818,12820,12825,12850 Merged /alfresco/BRANCHES/V3.1:r12994,12998 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13549 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
178 lines
6.5 KiB
Java
178 lines
6.5 KiB
Java
/*
|
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* As a special exception to the terms and conditions of version 2.0 of
|
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
* FLOSS exception. You should have recieved a copy of the text describing
|
|
* the FLOSS exception, and it is also available here:
|
|
* http://www.alfresco.com/legal/licensing"
|
|
*/
|
|
package org.alfresco.repo.security.person;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.domain.LocaleDAO;
|
|
import org.alfresco.repo.domain.Node;
|
|
import org.alfresco.repo.domain.NodePropertyValue;
|
|
import org.alfresco.repo.domain.PropertyMapKey;
|
|
import org.alfresco.repo.domain.QNameDAO;
|
|
import org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl;
|
|
import org.alfresco.repo.tenant.TenantService;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.StoreRef;
|
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.hibernate.SQLQuery;
|
|
import org.hibernate.Session;
|
|
import org.springframework.orm.hibernate3.HibernateCallback;
|
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|
|
|
public class PersonDaoImpl extends HibernateDaoSupport implements PersonDao
|
|
{
|
|
private static final String QUERY_PERSON_GET_PERSON = "person.getPerson";
|
|
|
|
private static final String QUERY_PERSON_GET_ALL_PEOPLE = "person.getAllPeople";
|
|
|
|
private QNameDAO qnameDAO;
|
|
private Long qNamePropId;
|
|
private Long qNameTypeId;
|
|
private LocaleDAO localeDAO;
|
|
private DictionaryService dictionaryService;
|
|
|
|
private StoreRef storeRef;
|
|
|
|
private TenantService tenantService;
|
|
|
|
public void setStoreUrl(String storeUrl)
|
|
{
|
|
this.storeRef = new StoreRef(storeUrl);
|
|
}
|
|
|
|
public void setTenantService(TenantService tenantService)
|
|
{
|
|
this.tenantService = tenantService;
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public List<NodeRef> getPersonOrNull(final String searchUserName, UserNameMatcher matcher)
|
|
{
|
|
final StoreRef personStoreRef = tenantService.getName(storeRef);
|
|
|
|
List<NodeRef> answer = new ArrayList<NodeRef>();
|
|
|
|
HibernateCallback callback = new HibernateCallback()
|
|
{
|
|
public Object doInHibernate(Session session)
|
|
{
|
|
SQLQuery query = (SQLQuery) session.getNamedQuery(QUERY_PERSON_GET_PERSON);
|
|
query.setParameter("qnamePropId", qNamePropId);
|
|
query.setParameter("qnameTypeId", qNameTypeId);
|
|
query.setParameter("userName1", searchUserName);
|
|
query.setParameter("userName2", searchUserName);
|
|
query.setParameter("False", Boolean.FALSE);
|
|
query.setParameter("storeProtocol", personStoreRef.getProtocol());
|
|
query.setParameter("storeIdentifier", personStoreRef.getIdentifier());
|
|
return query.list();
|
|
}
|
|
};
|
|
|
|
List<Node> results = (List<Node>) getHibernateTemplate().execute(callback);
|
|
|
|
for (Node node : results)
|
|
{
|
|
NodeRef nodeRef = node.getNodeRef();
|
|
Map<PropertyMapKey, NodePropertyValue> nodeProperties = node.getProperties();
|
|
|
|
// Convert the QName IDs
|
|
Map<QName, Serializable> converted = HibernateNodeDaoServiceImpl.convertToPublicProperties(nodeProperties, qnameDAO, localeDAO, dictionaryService);
|
|
|
|
Serializable value = converted.get(ContentModel.PROP_USERNAME);
|
|
String realUserName = DefaultTypeConverter.INSTANCE.convert(String.class, value);
|
|
|
|
if (matcher.matches(searchUserName, realUserName))
|
|
{
|
|
answer.add(nodeRef);
|
|
}
|
|
|
|
}
|
|
return answer;
|
|
|
|
}
|
|
|
|
public void init()
|
|
{
|
|
qNamePropId = qnameDAO.getOrCreateQName(ContentModel.PROP_USERNAME).getFirst();
|
|
qNameTypeId = qnameDAO.getOrCreateQName(ContentModel.TYPE_PERSON).getFirst();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public Set<NodeRef> getAllPeople()
|
|
{
|
|
final StoreRef personStoreRef = tenantService.getName(storeRef);
|
|
|
|
Set<NodeRef> answer = new HashSet<NodeRef>();
|
|
|
|
HibernateCallback callback = new HibernateCallback()
|
|
{
|
|
public Object doInHibernate(Session session)
|
|
{
|
|
SQLQuery query = (SQLQuery) session.getNamedQuery(QUERY_PERSON_GET_ALL_PEOPLE);
|
|
query.setParameter("qnamePropId", qNamePropId);
|
|
query.setParameter("qnameTypeId", qNameTypeId);
|
|
query.setParameter("False", Boolean.FALSE);
|
|
query.setParameter("storeProtocol", personStoreRef.getProtocol());
|
|
query.setParameter("storeIdentifier", personStoreRef.getIdentifier());
|
|
return query.list();
|
|
}
|
|
};
|
|
|
|
List<Node> results = (List<Node>) getHibernateTemplate().execute(callback);
|
|
|
|
for (Node node : results)
|
|
{
|
|
NodeRef nodeRef = node.getNodeRef();
|
|
answer.add(nodeRef);
|
|
}
|
|
return answer;
|
|
|
|
}
|
|
|
|
public void setQnameDAO(QNameDAO qnameDAO)
|
|
{
|
|
this.qnameDAO = qnameDAO;
|
|
}
|
|
|
|
public void setLocaleDAO(LocaleDAO localeDAO)
|
|
{
|
|
this.localeDAO = localeDAO;
|
|
}
|
|
|
|
public void setDictionaryService(DictionaryService dictionaryService)
|
|
{
|
|
this.dictionaryService = dictionaryService;
|
|
}
|
|
|
|
}
|