code
stringlengths
73
34.1k
label
stringclasses
1 value
public List<LocaleBean> getLocales(Locale currentLocale) { List<LocaleBean> locales = new ArrayList<>(); // get the array of locales available from the portal List<Locale> portalLocales = localeManagerFactory.getPortalLocales(); for (Locale locale : portalLocales) { if (curr...
java
public Locale getCurrentUserLocale(PortletRequest request) { final HttpServletRequest originalPortalRequest = this.portalRequestUtils.getPortletHttpRequest(request); IUserInstance ui = userInstanceManager.getUserInstance(originalPortalRequest); IUserPreferencesManager upm = ui.ge...
java
public void updateUserLocale(HttpServletRequest request, String localeString) { IUserInstance ui = userInstanceManager.getUserInstance(request); IUserPreferencesManager upm = ui.getPreferencesManager(); final IUserProfile userProfile = upm.getUserProfile(); LocaleManager localeManager =...
java
public TenantOperationResponse importWithResources( final ITenant tenant, final Set<Resource> resources) { /* * First load dom4j Documents and sort the entity files into the proper order */ final Map<PortalDataKey, Set<BucketTuple>> importQueue; try { im...
java
private Map<PortalDataKey, Set<BucketTuple>> prepareImportQueue( final ITenant tenant, final Set<Resource> templates) throws Exception { final Map<PortalDataKey, Set<BucketTuple>> rslt = new HashMap<>(); Resource rsc = null; try { for (Resource r : templates) { ...
java
private void importQueue( final ITenant tenant, final Map<PortalDataKey, Set<BucketTuple>> queue, final StringBuilder importReport) throws Exception { final StandardEvaluationContext ctx = new StandardEvaluationContext(); ctx.setRootObject(new RootObjectI...
java
public void updateCurrentUsername(String newUsername) { final String originalThreadName = originalThreadNameLocal.get(); if (originalThreadName != null && newUsername != null) { final Thread currentThread = Thread.currentThread(); final String threadName = getThreadName(originalT...
java
public Set<Entity> search(String entityType, String searchTerm) { if (StringUtils.isBlank(entityType) && StringUtils.isBlank(searchTerm)) { return null; } Set<Entity> results = new HashSet<Entity>(); EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType); Entity...
java
private IAuthorizationPrincipal getAuthorizationPrincipal(Authentication authentication) { final Object authPrincipal = authentication.getPrincipal(); logger.trace("getAuthorizationPrincipal -- authPrincipal=[{}]", authPrincipal); String username; if (authPrincipal instanceof UserDetai...
java
public final void setDuration(int duration) { if (isComplete()) { this.getLogger() .warn( "{} is already closed, the new duration of {} will be ignored on: {}", this.getClass().getSimpleName(), du...
java
protected IEntityGroup createUportalGroupFromGrouperGroup(WsGroup wsGroup) { IEntityGroup iEntityGroup = new EntityGroupImpl(wsGroup.getName(), IPerson.class); // need to set the group name and description to the actual // display name and description iEntityGroup.setName(wsGroup.getDis...
java
protected WsGroup findGroupFromKey(String key) { WsGroup wsGroup = null; if (key != null) { GcFindGroups gcFindGroups = new GcFindGroups(); gcFindGroups.addGroupName(key); WsFindGroupsResults results = gcFindGroups.execute(); // if no results were retur...
java
protected static String getStemPrefix() { String uportalStem = GrouperClientUtils.propertiesValue(STEM_PREFIX, false); // make sure it ends in colon if (!StringUtils.isBlank(uportalStem)) { if (uportalStem.endsWith(":")) { uportalStem = uportalStem.substring(0, upor...
java
@Override public void perform() throws PortalException { // push the change into the PLF if (nodeId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) { // we are dealing with an incorporated node ParameterEditManager.removeParmEditDirective(nodeId, name, person); } else ...
java
public static PortletCategoryBean create( String id, String name, String description, Set<PortletCategoryBean> subcategories, Set<PortletDefinitionBean> portlets) { return new PortletCategoryBean(id, name, description, subcategories, portlets); }
java
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/owners.json", method = RequestMethod.GET) public ModelAndView getOwners() { // get a l...
java
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/owners/{owner}.json", method = RequestMethod.GET) public ModelAndView getOwners( @P...
java
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/activities.json", method = RequestMethod.GET) public ModelAndView getActivities(@RequestParam(v...
java
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/{activity}/targets.json", method = RequestMethod.GET) public ModelAndView getTargets( ...
java
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping("/v5-5/permissions/assignments/users/{username}") public ModelAndView getAssignmentsForUser( @PathVariabl...
java
private void setReportFormTabs(final TabRenderReportForm report) { if (!report.getTabs().isEmpty()) { // Tabs are already set, do nothing return; } final Set<AggregatedTabMapping> tabs = this.getTabs(); if (!tabs.isEmpty()) { report.getTabs().add(tabs...
java
@javax.annotation.Resource(name = "dataFileIncludes") public void setDataFileIncludes(Set<String> dataFileIncludes) { this.dataFileIncludes = dataFileIncludes; }
java
private void importDataArchive( final Resource resource, final ArchiveInputStream resourceStream, BatchImportOptions options) { final File tempDir = Files.createTempDir(); try { ArchiveEntry archiveEntry; while ((archiveEntry = resourceStream....
java
private List<FutureHolder<?>> waitForFutures( final Queue<? extends FutureHolder<?>> futures, final PrintWriter reportWriter, final File reportDirectory, final boolean wait) throws InterruptedException { final List<FutureHolder<?>> failedFutures = new...
java
@Override public String setParameterValue(String parameterName, String parameterValue) { // don't try to store a null value if (parameterValue == null) return null; return (String) parameters.put(parameterName, parameterValue); }
java
static void applyAndUpdateParmEditSet(Document plf, Document ilf, IntegrationResult result) { Element pSet = null; try { pSet = getParmEditSet(plf, null, false); } catch (Exception e) { LOG.error("Exception occurred while getting user's DLM " + "paramter-edit-set.", e); ...
java
private static boolean applyEdit(Element edit, Document ilf) { String nodeID = edit.getAttribute(Constants.ATT_TARGET); Element channel = ilf.getElementById(nodeID); if (channel == null) return false; // now get the name of the parameter to be edited and find that element Stri...
java
private static Element getParmEditSet(Document plf, IPerson person, boolean create) throws PortalException { Node root = plf.getDocumentElement(); Node child = root.getFirstChild(); while (child != null) { if (child.getNodeName().equals(Constants.ELM_PARM_SET)) return (E...
java
public static synchronized void addParmEditDirective( String targetId, String name, String value, IPerson person) throws PortalException { Document plf = (Document) person.getAttribute(Constants.PLF); Element parmSet = getParmEditSet(plf, person, true); NodeList edits = parmSet.getCh...
java
private static void addParmEditDirective( String targetID, String name, String value, IPerson person, Document plf, Element parmSet) throws PortalException { String ID = null; try { ID = getDLS().getNextStr...
java
public static void removeParmEditDirective(String targetId, String name, IPerson person) throws PortalException { Document plf = (Document) person.getAttribute(Constants.PLF); Element parmSet = getParmEditSet(plf, person, false); if (parmSet == null) return; // no set so no edit to ...
java
public static final <T> T dropTableIfExists( JdbcOperations jdbcOperations, final String table, final Function<JdbcOperations, T> preDropCallback) { LOGGER.info("Dropping table: " + table); final boolean tableExists = doesTableExist(jdbcOperations, table); i...
java
public static boolean doesTableExist(JdbcOperations jdbcOperations, final String table) { final boolean tableExists = jdbcOperations.execute( new ConnectionCallback<Boolean>() { @Override public Boolean doInConnecti...
java
@Override public int getPortalUID(IPerson person, boolean createPortalData) throws AuthorizationException { int uid; String username = (String) person.getAttribute(IPerson.USERNAME); // only synchronize a non-guest request. if (PersonFactory.getGuestUsernames().contains(...
java
private PortalUser getPortalUser(final String userName) { return jdbcOperations.execute( (ConnectionCallback<PortalUser>) con -> { PortalUser portalUser = null; PreparedStatement pstmt = null; ...
java
@RequestMapping(params = "action=export") public ModelAndView getExportView(PortletRequest request) { Map<String, Object> model = new HashMap<String, Object>(); // add a list of all permitted export types final Iterable<IPortalDataType> exportPortalDataTypes = this.portalDat...
java
@RequestMapping(params = "action=delete") public ModelAndView getDeleteView(PortletRequest request) { Map<String, Object> model = new HashMap<String, Object>(); // add a list of all permitted deletion types final Iterable<IPortalDataType> deletePortalDataTypes = this.portalD...
java
public void validateEditDetails(GroupForm group, MessageContext context) { // ensure the group name is set if (StringUtils.isBlank(group.getName())) { context.addMessage( new MessageBuilder().error().source("name").code("please.enter.name").build()); } }
java
public String getTypeAndIdHash() { assert (entityType != null); assert (id != null); String idStr = id.replaceAll("\\W", "__"); return entityType.toString().toLowerCase() + "_" + idStr; }
java
private void filterAnalyticsGroups( IGroupMember groupMember, JsonNode config, Map<String, Boolean> isMemberCache) { if (config == null) { return; } final JsonNode dimensionGroups = config.get("dimensionGroups"); if (dimensionGroups == null) { return;...
java
private boolean isMember(IGroupMember groupMember, String groupName) { try { IEntityGroup group = GroupService.findGroup(groupName); if (group != null) { return groupMember.isDeepMemberOf(group); } final EntityIdentifier[] results = ...
java
@PostConstruct public void warnOnApathyKeyInMappings() { if (null != profileKeyForNoSelection && immutableMappings.containsKey(profileKeyForNoSelection)) { logger.warn( "Configured to treat profile key {} as apathy, " + "yet also co...
java
protected void chunkString( final List<CharacterEvent> characterEvents, final CharSequence buffer, int patternIndex) { // Iterate over the chunking patterns for (; patternIndex < this.chunkingPatterns.length; patternIndex++) { final Pattern pattern = this....
java
@Override public IPerson getPerson(HttpServletRequest request) throws PortalSecurityException { /* * This method overrides the implementation of getPerson() in BasePersonManager, but we only * want the RemoteUser behavior here if we're using RemoteUser AuthN. */ if (!remo...
java
public static String makeSafeFilename(String filename) { // Replace invalid characters for (final Map.Entry<Pattern, String> pair : REPLACEMENT_PAIRS.entrySet()) { final Pattern pattern = pair.getKey(); final Matcher matcher = pattern.matcher(filename); filename = mat...
java
@SuppressWarnings("unchecked") protected <D extends CachedPortletResultHolder<T>, T extends Serializable> CacheState<D, T> getPortletCacheState( HttpServletRequest request, IPortletWindow portletWindow, PublicPortletCacheKey publicCacheKey, ...
java
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) public ModelAndView getPrincipals( @R...
java
static Element appendChild(Element plfChild, Element parent, boolean copyChildren) { Document document = parent.getOwnerDocument(); Element copy = (Element) document.importNode(plfChild, false); parent.appendChild(copy); // set the identifier for the doc if warrented String id =...
java
private boolean isLocked(Class entityType, String entityKey) throws LockingException { return isLocked(entityType, entityKey, null); }
java
@Override public void renew(IEntityLock lock, int duration) throws LockingException { if (isValid(lock)) { Date newExpiration = getNewExpiration(duration); getLockStore().update(lock, newExpiration); ((EntityLockImpl) lock).setExpirationTime(newExpiration); } else...
java
public PortletDefinitionForm createPortletDefinitionForm(IPerson person, String portletId) { IPortletDefinition def = portletDefinitionRegistry.getPortletDefinition(portletId); // create the new form final PortletDefinitionForm form; if (def != null) { // if this is a pre-e...
java
public void removePortletRegistration(IPerson person, PortletDefinitionForm form) { /* TODO: Service-Layer Security Reboot (great need of refactoring with a community-approved plan in place) */ // Arguably a check here is redundant since -- in the current // portlet-manager webflow -- you can'...
java
public boolean shouldDisplayLayoutLink( IPerson person, PortletDefinitionForm form, String portletId) { if (!form.isNew()) { return false; } // only include the "do layout" link for published portlets. if (form.getLifecycleState() != PortletLifecycleState.PUBLISH...
java
public String getFragmentAdminURL(HttpServletRequest request) { IPortalUrlBuilder builder = urlProvider.getPortalUrlBuilderByPortletFName( request, PORTLET_FNAME_FRAGMENT_ADMIN_PORTLET, UrlType.RENDER); IPortletUrlBuilder portletUrlBuilder = builder.getTargetedPor...
java
public Set<String> getArbitraryPortletPreferenceNames(PortletDefinitionForm form) { // set default values for all portlet parameters PortletPublishingDefinition cpd = this.portletPublishingDefinitionDao.getChannelPublishingDefinition( form.getTypeId()); Se...
java
public List<PortletApplicationDefinition> getPortletApplications() { final PortletRegistryService portletRegistryService = portalDriverContainerServices.getPortletRegistryService(); final List<PortletApplicationDefinition> contexts = new ArrayList<>(); for (final Iterator<String...
java
private void copyAssertionAttributesToUserAttributes(Assertion assertion) { if (!copyAssertionAttributesToUserAttributes) { return; } // skip this if there are no attributes or if the attribute set is empty. if (assertion.getPrincipal().getAttributes() == null ...
java
@Override public IBasicEntity get(Class<? extends IBasicEntity> type, String key) throws CachingException { return EntityCachingServiceLocator.getEntityCachingService().get(type, key); }
java
public IBasicEntity get(EntityIdentifier entityID) throws CachingException { return EntityCachingServiceLocator.getEntityCachingService() .get(entityID.getType(), entityID.getKey()); }
java
@Override public void remove(Class<? extends IBasicEntity> type, String key) throws CachingException { EntityCachingServiceLocator.getEntityCachingService().remove(type, key); }
java
@RequestMapping("VIEW") public String renderError(RenderRequest request, RenderResponse response, ModelMap model) throws Exception { HttpServletRequest httpRequest = this.portalRequestUtils.getPortletHttpRequest(request); IPortletWindowId currentFailedPortletWindowId = (...
java
private String getAttributeValue(Attributes attrs, int attribute) throws NamingException { NamingEnumeration values = null; String aValue = ""; if (!isAttribute(attribute)) return aValue; Attribute attrib = attrs.get(attributes[attribute]); if (attrib != null) { for (...
java
@Override public UserProfile addUserProfile(final IPerson person, final IUserProfile profile) { final int userId = person.getID(); final int layoutId = getLayoutId(person, profile); // generate an id for this profile return jdbcOperations.execute( (ConnectionCallback...
java
private void createLayout(HashMap layoutStructure, Document doc, Element root, int structId) { while (structId != 0) { LayoutStructure ls = (LayoutStructure) layoutStructure.get(structId); // replaced with call to method in containing class to allow overriding // by subclasse...
java
protected String getNextStructId(final IPerson person, final String prefix) { final int userId = person.getID(); return nextStructTransactionOperations.execute( status -> jdbcOperations.execute( new ConnectionCallback<String>() { ...
java
private int getLayoutID(final int userId, final int profileId) { return jdbcOperations.execute( (ConnectionCallback<Integer>) con -> { String query = "SELECT LAYOUT_ID " ...
java
public static String getResourceAsURLString(Class<?> requestingClass, String resource) throws ResourceMissingException { return getResourceAsURL(requestingClass, resource).toString(); }
java
public static InputStream getResourceAsStream(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { return getResourceAsURL(requestingClass, resource).openStream(); }
java
public static InputSource getResourceAsSAXInputSource(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { URL url = getResourceAsURL(requestingClass, resource); InputSource source = new InputSource(url.openStream()); source.setPublicId(url.toExte...
java
public static Document getResourceAsDocument( Class<?> requestingClass, String resource, boolean validate) throws ResourceMissingException, IOException, ParserConfigurationException, SAXException { Document document = null; InputStream inputStream = null; ...
java
public static Document getResourceAsDocument(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException, ParserConfigurationException, SAXException { // Default is non-validating... return getResourceAsDocument(requestingClass, resource, fals...
java
public static Properties getResourceAsProperties(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { InputStream inputStream = null; Properties props = null; try { inputStream = getResourceAsStream(requestingClass, resource); ...
java
public static String getResourceAsString(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { String line = null; BufferedReader in = null; StringBuffer sbText = null; try { in = new BufferedReader( ...
java
public void setContextParameters( Map<String, String> principals, Map<String, String> credentials, String ctxName, ISecurityContext securityContext) { if (log.isDebugEnabled()) { final StringBuilder msg = new StringBuilder(); msg.append("P...
java
protected void publishRenderEvent( IPortletWindow portletWindow, HttpServletRequest httpServletRequest, RenderPart renderPart, long executionTime, boolean cached) { final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId(); ...
java
protected void publishResourceEvent( IPortletWindow portletWindow, HttpServletRequest httpServletRequest, long executionTime, boolean usedBrowserCache, boolean usedPortalCache) { final IPortletWindowId portletWindowId = portletWindow.getPortletWindowI...
java
protected void enforceConfigPermission( final HttpServletRequest httpServletRequest, final IPortletWindow portletWindow) { Validate.notNull( httpServletRequest, "Servlet request must not be null to determine remote user."); Validate.notNull(portletWindow, "Portlet window mus...
java
@Override public Object[] getAttributeValues(String key) { if (userAttributes == null) { return null; } final List<Object> values = userAttributes.get(key); if (values != null) { return values.toArray(); } return null; }
java
@Override public void setAttribute(String key, Object value) { if (value == null) { setAttribute(key, null); } else { setAttribute(key, Collections.singletonList(value)); } }
java
@Override public boolean isGuest() { String userName = (String) getAttribute(IPerson.USERNAME); boolean isGuestUsername = PersonFactory.getGuestUsernames().contains(userName); boolean isAuthenticated = m_securityContext != null && m_securityContext.isAuthenticated(); return isGuestUs...
java
public IEntityStore newInstance() throws GroupsException { try { return new RDBMEntityStore(); } catch (Exception ex) { log.error("ReferenceEntityStoreFactory.newInstance(): " + ex); throw new GroupsException(ex); } }
java
protected Deque<XMLEvent> getAdditionalEvents(XMLEvent event) { final XMLEvent additionalEvent = this.getAdditionalEvent(event); if (additionalEvent == null) { return null; } final Deque<XMLEvent> additionalEvents = new LinkedList<XMLEvent>(); additionalEvents.push(a...
java
protected String getStyleSheetName(final HttpServletRequest request, PreferencesScope scope) { final String stylesheetNameFromRequest; if (scope.equals(PreferencesScope.STRUCTURE)) { stylesheetNameFromRequest = (String) request.getAttribute(STYLESHEET_STRUCTURE_OVERRIDE_...
java
@RequestMapping public void doLogout(HttpServletRequest request, HttpServletResponse response) throws IOException { String redirect = this.selectRedirectionUrl(request); final HttpSession session = request.getSession(false); if (session != null) { // Record that an ...
java
protected static void loadProps() { PropertiesManager.props = new Properties(); try { String pfile = System.getProperty(PORTAL_PROPERTIES_FILE_SYSTEM_VARIABLE); if (pfile == null) { pfile = PORTAL_PROPERTIES_FILE_NAME; } PropertiesManager.p...
java
public static String getProperty(String name) throws MissingPropertyException { if (log.isTraceEnabled()) { log.trace("entering getProperty(" + name + ")"); } if (PropertiesManager.props == null) loadProps(); String val = getPropertyUntrimmed(name); val = val.trim(); ...
java
public static String getPropertyUntrimmed(String name) throws MissingPropertyException { if (PropertiesManager.props == null) loadProps(); if (props == null) { boolean alreadyReported = registerMissingProperty(name); throw new MissingPropertyException(name, alreadyReported); ...
java
private static boolean registerMissingProperty(String name) { final boolean previouslyReported = !PropertiesManager.missingProperties.add(name); if (!previouslyReported && log.isInfoEnabled()) { log.info("Property [" + name + "] was requested but not found."); } return previ...
java
public static String getProperty(String name, String defaultValue) { if (PropertiesManager.props == null) loadProps(); String returnValue = defaultValue; try { returnValue = getProperty(name); } catch (MissingPropertyException mpe) { // Do nothing, since we have a...
java
public static boolean getPropertyAsBoolean(final String name, final boolean defaultValue) { if (PropertiesManager.props == null) loadProps(); boolean returnValue = defaultValue; try { returnValue = getPropertyAsBoolean(name); } catch (MissingPropertyException mpe) { ...
java
public static byte getPropertyAsByte(final String name, final byte defaultValue) { if (PropertiesManager.props == null) loadProps(); byte returnValue = defaultValue; try { returnValue = getPropertyAsByte(name); } catch (Throwable t) { log.error( ...
java
public static Version parseVersion(String versionString) { final Matcher versionMatcher = VERSION_PATTERN.matcher(versionString); if (!versionMatcher.matches()) { return null; } final int major = Integer.parseInt(versionMatcher.group(1)); final int minor = Integer.pa...
java
public static Version.Field getMostSpecificMatchingField(Version v1, Version v2) { if (v1.getMajor() != v2.getMajor()) { return null; } if (v1.getMinor() != v2.getMinor()) { return Version.Field.MAJOR; } if (v1.getPatch() != v2.getPatch()) { ...
java
public UrlStringBuilder setParameter(String name, String... values) { this.setParameter(name, values != null ? Arrays.asList(values) : null); return this; }
java
public UrlStringBuilder addParameter(String name, String... values) { this.addParameter(name, values != null ? Arrays.asList(values) : null); return this; }
java
public UrlStringBuilder setParameters(String namespace, Map<String, List<String>> parameters) { for (final String name : parameters.keySet()) { Validate.notNull(name, "parameter map cannot contain any null keys"); } this.parameters.clear(); this.addParameters(namespace, para...
java
public UrlStringBuilder setPath(String... elements) { Validate.noNullElements(elements, "elements cannot be null"); this.path.clear(); this.addPath(elements); return this; }
java
public UrlStringBuilder addPath(String element) { Validate.notNull(element, "element cannot be null"); this.path.add(element); return this; }
java
public UrlStringBuilder addPath(String... elements) { Validate.noNullElements(elements, "elements cannot be null"); for (final String element : elements) { this.path.add(element); } return this; }
java
@SuppressWarnings("unchecked") protected Map<String, IPortletPreference> getSessionPreferences( IPortletEntityId portletEntityId, HttpServletRequest httpServletRequest) { final HttpSession session = httpServletRequest.getSession(); final Map<IPortletEntityId, Map<String, IPortletPrefere...
java