Created
May 14, 2013 22:27
-
-
Save migue/5580178 to your computer and use it in GitHub Desktop.
Basic OSGi Gogo shell consuming a Liferay service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import com.liferay.gogo.commands.user.internal.AbstractUserManagementCommand; | |
import com.liferay.portal.kernel.exception.SystemException; | |
import com.liferay.portal.model.User; | |
import com.liferay.portal.service.UserLocalService; | |
import aQute.bnd.annotation.component.Component; | |
import aQute.bnd.annotation.component.Reference; | |
@Component(properties = { | |
"osgi.command.function=listByCompany", | |
"osgi.command.scope=usermanagement" | |
}, provide=Object.class) | |
public class ListUsersCommand extends AbstractUserManagementCommand { | |
public void listByCompany(long companyId) throws SystemException { | |
List<User> users = _userLocalService.getCompanyUsers( | |
companyId, -1, -1); | |
System.out.println("Users of the company " + companyId); | |
for (User user : users) { | |
System.out.println( | |
"\tUser " + user.getEmailAddress() + "with id " + | |
user.getUserId()); | |
} | |
} | |
@Reference | |
public void setUserLocalService(UserLocalService userLocaService) { | |
_userLocalService = userLocaService; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment