
If the default photo service does not suit your organization's requirements, you can develop and register a custom photo service.
The service should extend the AbstractPhoto interface, located in the com.sap.workspaces.workspace package.
import com.sap.security.api.IUser;
import com.sap.security.api.UMFactory;
import com.sap.workspaces.workspace.AbstractPhoto;
import com.sapportals.portal.prt.service.IService;
import com.sapportals.portal.prt.service.IServiceContext;
/**
* A sample service that returns the URL of the specified user's photo
*
*/
public class CustomPhoto extends AbstractPhoto implements IService {
public String getURL(IUser user) {
IUser loggedInUser = UMFactory.getAuthenticator().getLoggedInUser();
// Custom logic for retrieving photos
if (isAuthorised(loggedInUser, user)) {
if (user.isMemberOfGroup("group_x", true)) {
// Photos of the group_x members are in the "johnsmith.jpg" format
return "http://someserver/photo/"+user.getFirstName()+user.getLastName()+".jpg";
} else {
// Photos of all other users are in the "john.smith.png" format
String email = user.getEmail();
if (email != null) {
return "http://someserver/photo/"+email.substring(0, email.indexOf("@"))+".png";
}
}
}
// Null is a valid return value
return null;
}
// If your organisation has a privacy policy regarding visibility of photos
private boolean isAuthorised(IUser loggedInUser, IUser user) {
// Implement the privacy policy ...
return true;
}
}To register your photo service:
Finalize and deploy the service to the portal.
Log on to the portal in the Workspaces System Administration role.
Navigate to .
In the User Photo Implementation field, enter prt_service:<your service key>. Ignore the URL Pattern field.
After you have registered a custom photo service, it will replace the default one, and thus impact all user interfaces of enterprise workspaces that display user photos.