mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Coding standards and consistency sweep across new services code in remote-api project.
Covers spacing, trailing {, @since tags, tabs and copyright headers. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30216 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -26,7 +26,6 @@ import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
|
||||
import org.alfresco.service.cmr.invitation.InvitationExceptionUserError;
|
||||
import org.alfresco.service.cmr.invitation.InvitationService;
|
||||
import org.alfresco.service.cmr.invitation.NominatedInvitation;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
@@ -209,34 +208,34 @@ public class Invite extends DeclarativeWebScript
|
||||
NominatedInvitation newInvite = null;
|
||||
try
|
||||
{
|
||||
if(inviteeUserName != null)
|
||||
{
|
||||
newInvite = invitationService.inviteNominated(inviteeUserName, Invitation.ResourceType.WEB_SITE, siteShortName, inviteeSiteRole, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
newInvite = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, Invitation.ResourceType.WEB_SITE, siteShortName, inviteeSiteRole, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
// add model properties for template to render
|
||||
model.put(MODEL_PROP_KEY_ACTION, ACTION_START);
|
||||
model.put(MODEL_PROP_KEY_INVITE_ID, newInvite.getInviteId());
|
||||
model.put(MODEL_PROP_KEY_INVITE_TICKET, newInvite.getTicket());
|
||||
model.put(MODEL_PROP_KEY_INVITEE_USER_NAME, newInvite.getInviteeUserName());
|
||||
model.put(MODEL_PROP_KEY_INVITEE_FIRSTNAME, inviteeFirstName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_LASTNAME, inviteeLastName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_EMAIL, inviteeEmail);
|
||||
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, siteShortName);
|
||||
if (inviteeUserName != null)
|
||||
{
|
||||
newInvite = invitationService.inviteNominated(inviteeUserName, Invitation.ResourceType.WEB_SITE, siteShortName, inviteeSiteRole, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
newInvite = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, Invitation.ResourceType.WEB_SITE, siteShortName, inviteeSiteRole, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
// add model properties for template to render
|
||||
model.put(MODEL_PROP_KEY_ACTION, ACTION_START);
|
||||
model.put(MODEL_PROP_KEY_INVITE_ID, newInvite.getInviteId());
|
||||
model.put(MODEL_PROP_KEY_INVITE_TICKET, newInvite.getTicket());
|
||||
model.put(MODEL_PROP_KEY_INVITEE_USER_NAME, newInvite.getInviteeUserName());
|
||||
model.put(MODEL_PROP_KEY_INVITEE_FIRSTNAME, inviteeFirstName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_LASTNAME, inviteeLastName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_EMAIL, inviteeEmail);
|
||||
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, siteShortName);
|
||||
}
|
||||
catch (InvitationExceptionUserError ie)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT,
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT,
|
||||
"Cannot proceed with invitation. A person with user name: '" + inviteeUserName
|
||||
+ "' and invitee email address: '"
|
||||
+ inviteeEmail + "' is already a member of the site: '" + siteShortName + "'.");
|
||||
}
|
||||
}
|
||||
catch (InvitationExceptionForbidden fe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
|
||||
}
|
||||
|
||||
// process action 'start' with provided parameters
|
||||
@@ -259,14 +258,14 @@ public class Invite extends DeclarativeWebScript
|
||||
// process action 'cancel' with provided parameters
|
||||
try
|
||||
{
|
||||
invitationService.cancel(inviteId);
|
||||
invitationService.cancel(inviteId);
|
||||
// add model properties for template to render
|
||||
model.put(MODEL_PROP_KEY_ACTION, ACTION_CANCEL);
|
||||
model.put(MODEL_PROP_KEY_INVITE_ID, inviteId);
|
||||
}
|
||||
catch(InvitationExceptionForbidden fe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow" , fe);
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow" , fe);
|
||||
}
|
||||
}
|
||||
// handle action not recognised
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -128,27 +128,25 @@ public class InviteByTicket extends DeclarativeWebScript
|
||||
|
||||
try
|
||||
{
|
||||
Invitation invitation = invitationService.getInvitation(inviteId);
|
||||
|
||||
if (invitation instanceof NominatedInvitation)
|
||||
{
|
||||
NominatedInvitation theInvitation = (NominatedInvitation)invitation;
|
||||
String ticket = theInvitation.getTicket();
|
||||
if (ticket == null || (! ticket.equals(inviteTicket)))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||
"Ticket mismatch");
|
||||
}
|
||||
Invitation invitation = invitationService.getInvitation(inviteId);
|
||||
|
||||
if (invitation instanceof NominatedInvitation)
|
||||
{
|
||||
NominatedInvitation theInvitation = (NominatedInvitation)invitation;
|
||||
String ticket = theInvitation.getTicket();
|
||||
if (ticket == null || (! ticket.equals(inviteTicket)))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Ticket mismatch");
|
||||
}
|
||||
// return the invite info
|
||||
model.put("invite", toInviteInfo(theInvitation));
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a nominated invitation
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN,
|
||||
"Not a nominated invitation");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a nominated invitation
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Not a nominated invitation");
|
||||
}
|
||||
}
|
||||
catch (InvitationExceptionNotFound nfe)
|
||||
{
|
||||
@@ -177,20 +175,19 @@ public class InviteByTicket extends DeclarativeWebScript
|
||||
TemplateNode inviteePerson = null;
|
||||
if (inviteeRef != null)
|
||||
{
|
||||
inviteePerson = new TemplateNode(inviteeRef, serviceRegistry, null);
|
||||
inviteePerson = new TemplateNode(inviteeRef, serviceRegistry, null);
|
||||
}
|
||||
|
||||
InviteInfo ret = new InviteInfo(invitationStatus,
|
||||
invitation.getInviterUserName(),
|
||||
inviterPerson,
|
||||
invitation.getInviteeUserName(),
|
||||
inviteePerson,
|
||||
invitation.getRoleName(),
|
||||
invitation.getResourceName(),
|
||||
siteInfo,
|
||||
invitation.getSentInviteDate(),
|
||||
invitation.getInviteId()
|
||||
);
|
||||
invitation.getInviterUserName(),
|
||||
inviterPerson,
|
||||
invitation.getInviteeUserName(),
|
||||
inviteePerson,
|
||||
invitation.getRoleName(),
|
||||
invitation.getResourceName(),
|
||||
siteInfo,
|
||||
invitation.getSentInviteDate(),
|
||||
invitation.getInviteId());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -112,38 +112,38 @@ public class InviteResponse extends DeclarativeWebScript
|
||||
String action = req.getServiceMatch().getTemplateVars().get("action");
|
||||
if (action.equals("accept"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Invitation invitation = invitationService.accept(inviteId, inviteTicket);
|
||||
try
|
||||
{
|
||||
Invitation invitation = invitationService.accept(inviteId, inviteTicket);
|
||||
// add model properties for template to render
|
||||
model.put(MODEL_PROP_KEY_RESPONSE, RESPONSE_ACCEPT);
|
||||
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, invitation.getResourceName());
|
||||
}
|
||||
}
|
||||
catch (InvitationExceptionForbidden fe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
|
||||
}
|
||||
catch (InvitationExceptionUserError fe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT, fe.toString());
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT, fe.toString());
|
||||
}
|
||||
}
|
||||
else if (action.equals("reject"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Invitation invitation = invitationService.reject(inviteId, "Rejected");
|
||||
try
|
||||
{
|
||||
Invitation invitation = invitationService.reject(inviteId, "Rejected");
|
||||
// add model properties for template to render
|
||||
model.put(MODEL_PROP_KEY_RESPONSE, RESPONSE_REJECT);
|
||||
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, invitation.getResourceName());
|
||||
}
|
||||
}
|
||||
catch (InvitationExceptionForbidden fe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
|
||||
}
|
||||
catch (InvitationExceptionUserError fe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT, fe.toString());
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT, fe.toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -242,37 +242,37 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
*/
|
||||
public static void configureMailExecutorForTestMode(TestWebScriptServer server)
|
||||
{
|
||||
// This test class depends on a MailActionExecuter bean which sends out emails
|
||||
// in a live system. We want to prevent these emails from being sent during
|
||||
// test execution.
|
||||
// To do that, we need to get at the outboundSMTP-context.xml and change its
|
||||
// "mail" MailActionExecuter bean to test mode. setTestMode(true) on that object
|
||||
// will turn off email sending.
|
||||
// But that bean is defined within a subsystem i.e. a child application context.
|
||||
|
||||
// There are a number of ways we could do this, none of them perfect.
|
||||
//
|
||||
// 1. Expose the setTestMode(boolean) method in the subsystem API.
|
||||
// We could have the "mail" bean implement a "TestModeable" interface and
|
||||
// expose that through the proxy.
|
||||
// But that would mean that the setTestMode method would be available in the
|
||||
// live system too, which is not ideal.
|
||||
// 2. Replace the "mail" bean in outboundSMTP-context.xml with an alternative in a
|
||||
// different subsystem context file as described in
|
||||
// http://wiki.alfresco.com/wiki/Alfresco_Subsystems#Debugging_Alfresco_Subsystems
|
||||
// But to do that, we'd have to reproduce all the spring config for that bean
|
||||
// and add a testMode property. Again not ideal.
|
||||
// 3. Hack into the "mail" bean by programmatically going through the known applicationContext
|
||||
// and bean structure. This is not ideal either, but it has no effect on product code
|
||||
// and isolates all the hacking into this test class.
|
||||
//
|
||||
// Therefore we've decided to do [3].
|
||||
|
||||
ChildApplicationContextFactory outboundSmptSubsystem
|
||||
// This test class depends on a MailActionExecuter bean which sends out emails
|
||||
// in a live system. We want to prevent these emails from being sent during
|
||||
// test execution.
|
||||
// To do that, we need to get at the outboundSMTP-context.xml and change its
|
||||
// "mail" MailActionExecuter bean to test mode. setTestMode(true) on that object
|
||||
// will turn off email sending.
|
||||
// But that bean is defined within a subsystem i.e. a child application context.
|
||||
|
||||
// There are a number of ways we could do this, none of them perfect.
|
||||
//
|
||||
// 1. Expose the setTestMode(boolean) method in the subsystem API.
|
||||
// We could have the "mail" bean implement a "TestModeable" interface and
|
||||
// expose that through the proxy.
|
||||
// But that would mean that the setTestMode method would be available in the
|
||||
// live system too, which is not ideal.
|
||||
// 2. Replace the "mail" bean in outboundSMTP-context.xml with an alternative in a
|
||||
// different subsystem context file as described in
|
||||
// http://wiki.alfresco.com/wiki/Alfresco_Subsystems#Debugging_Alfresco_Subsystems
|
||||
// But to do that, we'd have to reproduce all the spring config for that bean
|
||||
// and add a testMode property. Again not ideal.
|
||||
// 3. Hack into the "mail" bean by programmatically going through the known applicationContext
|
||||
// and bean structure. This is not ideal either, but it has no effect on product code
|
||||
// and isolates all the hacking into this test class.
|
||||
//
|
||||
// Therefore we've decided to do [3].
|
||||
|
||||
ChildApplicationContextFactory outboundSmptSubsystem
|
||||
= (ChildApplicationContextFactory)server.getApplicationContext().getBean("OutboundSMTP");
|
||||
ApplicationContext childAppCtxt = outboundSmptSubsystem.getApplicationContext();
|
||||
MailActionExecuter mailActionExecutor = (MailActionExecuter)childAppCtxt.getBean("mail");
|
||||
mailActionExecutor.setTestMode(true);
|
||||
ApplicationContext childAppCtxt = outboundSmptSubsystem.getApplicationContext();
|
||||
MailActionExecuter mailActionExecutor = (MailActionExecuter)childAppCtxt.getBean("mail");
|
||||
mailActionExecutor.setTestMode(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,19 +19,16 @@
|
||||
package org.alfresco.repo.web.scripts.invite;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.invitation.InvitationSearchCriteriaImpl;
|
||||
import org.alfresco.repo.invitation.InviteHelper;
|
||||
import org.alfresco.service.cmr.invitation.InvitationSearchCriteria;
|
||||
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
|
||||
import org.alfresco.repo.invitation.site.InviteInfo;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.invitation.Invitation;
|
||||
import org.alfresco.service.cmr.invitation.InvitationSearchCriteria;
|
||||
import org.alfresco.service.cmr.invitation.InvitationService;
|
||||
import org.alfresco.service.cmr.invitation.NominatedInvitation;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -39,10 +36,6 @@ import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
@@ -97,23 +90,27 @@ public class Invites extends DeclarativeWebScript
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry) {
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService) {
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setInvitationService(InvitationService invitationService) {
|
||||
this.invitationService = invitationService;
|
||||
}
|
||||
|
||||
public InvitationService getInvitationService() {
|
||||
return invitationService;
|
||||
}
|
||||
public void setInvitationService(InvitationService invitationService)
|
||||
{
|
||||
this.invitationService = invitationService;
|
||||
}
|
||||
|
||||
/*
|
||||
public InvitationService getInvitationService()
|
||||
{
|
||||
return invitationService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
@@ -181,8 +178,8 @@ public class Invites extends DeclarativeWebScript
|
||||
// query properties
|
||||
if (inviteIdProvided)
|
||||
{
|
||||
NominatedInvitation invitation = (NominatedInvitation)invitationService.getInvitation(inviteId);
|
||||
inviteInfoList.add(toInviteInfo(invitation));
|
||||
NominatedInvitation invitation = (NominatedInvitation)invitationService.getInvitation(inviteId);
|
||||
inviteInfoList.add(toInviteInfo(invitation));
|
||||
}
|
||||
else
|
||||
// 'inviteId' has not been provided, so create the query properties from
|
||||
@@ -194,37 +191,34 @@ public class Invites extends DeclarativeWebScript
|
||||
// properties will be set
|
||||
// at this point
|
||||
{
|
||||
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
|
||||
criteria.setInvitationType(InvitationSearchCriteria.InvitationType.NOMINATED);
|
||||
criteria.setResourceType(Invitation.ResourceType.WEB_SITE);
|
||||
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
|
||||
criteria.setInvitationType(InvitationSearchCriteria.InvitationType.NOMINATED);
|
||||
criteria.setResourceType(Invitation.ResourceType.WEB_SITE);
|
||||
|
||||
|
||||
if (inviterUserNameProvided)
|
||||
{
|
||||
criteria.setInviter(inviterUserName);
|
||||
|
||||
criteria.setInviter(inviterUserName);
|
||||
}
|
||||
if (inviteeUserNameProvided)
|
||||
{
|
||||
criteria.setInvitee(inviteeUserName);
|
||||
|
||||
criteria.setInvitee(inviteeUserName);
|
||||
}
|
||||
if (siteShortNameProvided)
|
||||
{
|
||||
criteria.setResourceName(siteShortName);
|
||||
|
||||
criteria.setResourceName(siteShortName);
|
||||
}
|
||||
|
||||
List<Invitation> invitations = invitationService.searchInvitation(criteria);
|
||||
List<Invitation> invitations = invitationService.searchInvitation(criteria);
|
||||
|
||||
// Put InviteInfo objects (containing workflow path properties
|
||||
// wf:inviterUserName, wf:inviteeUserName, wf:siteShortName,
|
||||
// and invite id property (from workflow instance id))
|
||||
// onto model for each invite workflow task returned by the query
|
||||
for (Invitation invitation : invitations)
|
||||
{
|
||||
inviteInfoList.add(toInviteInfo((NominatedInvitation)invitation));
|
||||
}
|
||||
// Put InviteInfo objects (containing workflow path properties
|
||||
// wf:inviterUserName, wf:inviteeUserName, wf:siteShortName,
|
||||
// and invite id property (from workflow instance id))
|
||||
// onto model for each invite workflow task returned by the query
|
||||
for (Invitation invitation : invitations)
|
||||
{
|
||||
inviteInfoList.add(toInviteInfo((NominatedInvitation)invitation));
|
||||
}
|
||||
}
|
||||
|
||||
// put the list of invite infos onto model to be passed onto template
|
||||
@@ -256,20 +250,19 @@ public class Invites extends DeclarativeWebScript
|
||||
TemplateNode inviteePerson = null;
|
||||
if (inviteeRef != null)
|
||||
{
|
||||
inviteePerson = new TemplateNode(inviteeRef, serviceRegistry, null);
|
||||
inviteePerson = new TemplateNode(inviteeRef, serviceRegistry, null);
|
||||
}
|
||||
|
||||
InviteInfo ret = new InviteInfo(invitationStatus,
|
||||
invitation.getInviterUserName(),
|
||||
inviterPerson,
|
||||
invitation.getInviteeUserName(),
|
||||
inviteePerson,
|
||||
invitation.getRoleName(),
|
||||
invitation.getResourceName(),
|
||||
siteInfo,
|
||||
invitation.getSentInviteDate(),
|
||||
invitation.getInviteId()
|
||||
);
|
||||
invitation.getInviterUserName(),
|
||||
inviterPerson,
|
||||
invitation.getInviteeUserName(),
|
||||
inviteePerson,
|
||||
invitation.getRoleName(),
|
||||
invitation.getResourceName(),
|
||||
siteInfo,
|
||||
invitation.getSentInviteDate(),
|
||||
invitation.getInviteId());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user