Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to create a new RegisteredService implementation #6

Merged
merged 3 commits into from
Mar 7, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ public int getEvaluationOrder() {
}

public Object clone() throws CloneNotSupportedException {
final RegisteredServiceImpl registeredServiceImpl = new RegisteredServiceImpl();
final RegisteredServiceImpl registeredServiceImpl;
try {
registeredServiceImpl = this.getClass().newInstance();
} catch (final Exception e) {
throw new CloneNotSupportedException("error creating new object");
}

registeredServiceImpl.setAllowedAttributes(this.allowedAttributes);
registeredServiceImpl.setAllowedToProxy(this.allowedToProxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public RegisteredServiceSimpleFormController(
final IPersonAttributeDao attributeRepository) {
this.servicesManager = servicesManager;
this.personAttributeDao = attributeRepository;
this.setCommandClass(RegisteredServiceImpl.class);
}

/**
Expand Down Expand Up @@ -93,7 +94,7 @@ protected Object formBackingObject(final HttpServletRequest request)

if (!StringUtils.hasText(id)) {
logger.debug("Created new service.");
return new RegisteredServiceImpl();
return this.createCommand();
}

final RegisteredService service = this.servicesManager.findServiceBy(Long.parseLong(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.jasig.cas.services.web.support;

import org.jasig.cas.services.RegisteredService;
import org.jasig.cas.services.RegisteredServiceImpl;
import org.jasig.cas.services.ServicesManager;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
Expand Down Expand Up @@ -36,12 +35,12 @@ public final class RegisteredServiceValidator implements Validator {
private int maxDescriptionLength = DEFAULT_MAX_DESCRIPTION_LENGTH;

/**
* Supports the RegisteredServiceImpl.
* Supports RegisteredService objects.
*
* @see org.springframework.validation.Validator#supports(java.lang.Class)
*/
public boolean supports(final Class clazz) {
return RegisteredServiceImpl.class.equals(clazz);
return RegisteredService.class.isAssignableFrom(clazz);
}

public void validate(final Object o, final Errors errors) {
Expand Down