Permalink
Browse files

NXP-9169: Add api to get registration statut

  • Loading branch information...
1 parent 049edcd commit fdaf6eaee10dba38f5883c627fec5ec351004c20 @akervern akervern committed Apr 5, 2012
@@ -46,12 +46,14 @@
import org.nuxeo.ecm.core.api.ClientRuntimeException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
import org.nuxeo.ecm.core.api.DocumentRef;
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.NuxeoPrincipal;
import org.nuxeo.ecm.core.api.PathRef;
import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner;
import org.nuxeo.ecm.core.api.impl.DocumentModelImpl;
+import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl;
import org.nuxeo.ecm.core.api.model.PropertyException;
import org.nuxeo.ecm.core.api.repository.RepositoryManager;
import org.nuxeo.ecm.core.event.Event;
@@ -745,4 +747,18 @@ public void deleteRegistrationRequests(CoreSession session,
public Set<String> getConfigurationsName() {
return configurations.keySet();
}
+
+ @Override
+ public DocumentModelList getRegistrationsForUser(final String docId, final String username) throws ClientException {
+ final DocumentModelList registrationDocs = new DocumentModelListImpl();
+ new UnrestrictedSessionRunner(getTargetRepositoryName()) {
+ @Override
+ public void run() throws ClientException {
+ String query = "SELECT * FROM Document WHERE ecm:mixinType = 'UserRegistration' AND docinfo:documentId = '%s' AND userinfo:login = '%s' AND ecm:isCheckedInVersion = 0";
+ query = String.format(query, docId, username);
+ registrationDocs.addAll(session.query(query));
+ }
+ };
+ return registrationDocs;
+ }
}
@@ -24,6 +24,7 @@
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
import org.nuxeo.ecm.core.api.NuxeoPrincipal;
public interface UserRegistrationService {
@@ -123,6 +124,12 @@ void addRightsOnDoc(CoreSession session, DocumentModel registrationDoc)
UserRegistrationConfiguration getConfiguration();
/**
+ * Retrieve registrations for a document givent the username
+ * @since 5.6
+ */
+ DocumentModelList getRegistrationsForUser(String docId, String username) throws ClientException;
+
+ /**
* Return specific configuration for the specified name
*
* @param name configuration name

0 comments on commit fdaf6ea

Please sign in to comment.