code
stringlengths
73
34.1k
label
stringclasses
1 value
private String getPropertyName(final String windowIdStr, final String fullAttributeName) { final String attributeName; if (this.nonNamespacedProperties.contains(fullAttributeName)) { attributeName = fullAttributeName; } else if (fullAttributeName.startsWith(windowIdStr)) { ...
java
public void addParameter(String paramName, String paramValue) { this.parameters.add(new StructureParameter(paramName, paramValue)); }
java
protected void addFetches(final Root<StylesheetUserPreferencesImpl> descriptorRoot) { descriptorRoot.fetch(StylesheetUserPreferencesImpl_.layoutAttributes, JoinType.LEFT); descriptorRoot.fetch(StylesheetUserPreferencesImpl_.outputProperties, JoinType.LEFT); descriptorRoot.fetch(StylesheetUserPre...
java
private void initialize() { String sep; try { sep = GroupServiceConfiguration.getConfiguration().getNodeSeparator(); } catch (Exception ex) { sep = DEFAULT_NODE_SEPARATOR; } groupNodeSeparator = sep; if (LOG.isDebugEnabled()) { LOG.debu...
java
@Override public void delete(IEntityGroup group) throws GroupsException { if (existsInDatabase(group)) { try { primDelete(group); } catch (SQLException sqle) { throw new GroupsException("Problem deleting " + group, sqle); } } }
java
private boolean existsInDatabase(IEntityGroup group) throws GroupsException { IEntityGroup ug = this.find(group.getLocalKey()); return ug != null; }
java
public java.util.Iterator findParentGroups(IEntity ent) throws GroupsException { String memberKey = ent.getKey(); Integer type = EntityTypesLocator.getEntityTypes().getEntityIDFromType(ent.getLeafType()); return findParentGroupsForEntity(memberKey, type.intValue()); }
java
public java.util.Iterator findParentGroups(IEntityGroup group) throws GroupsException { String memberKey = group.getLocalKey(); String serviceName = group.getServiceName().toString(); Integer type = EntityTypesLocator.getEntityTypes().getEntityIDFromType(group.getLeafType()); return find...
java
@Override public Iterator findParentGroups(IGroupMember gm) throws GroupsException { if (gm.isGroup()) { IEntityGroup group = (IEntityGroup) gm; return findParentGroups(group); } else { IEntity ent = (IEntity) gm; return findParentGroups(ent); ...
java
private java.util.Iterator findParentGroupsForEntity(String memberKey, int type) throws GroupsException { Connection conn = null; Collection groups = new ArrayList(); IEntityGroup eg = null; try { conn = RDBMServices.getConnection(); String sql = getF...
java
@Override public String[] findMemberGroupKeys(IEntityGroup group) throws GroupsException { Connection conn = null; Collection groupKeys = new ArrayList(); String groupKey = null; try { conn = RDBMServices.getConnection(); String sql = getFindMemberGroupKeysSq...
java
@Override public Iterator findMemberGroups(IEntityGroup group) throws GroupsException { Connection conn = null; Collection groups = new ArrayList(); IEntityGroup eg = null; String serviceName = group.getServiceName().toString(); String localKey = group.getLocalKey(); ...
java
private void primDelete(IEntityGroup group) throws SQLException { Connection conn = null; String deleteGroupSql = getDeleteGroupSql(group); String deleteMembershipSql = getDeleteMembersInGroupSql(group); try { conn = RDBMServices.getConnection(); Statement stmnt ...
java
private void primUpdate(IEntityGroup group, Connection conn) throws SQLException, GroupsException { try { PreparedStatement ps = conn.prepareStatement(getUpdateGroupSql()); try { Integer typeID = EntityTypesLocator.getEntityTypes() ...
java
@Override public void update(IEntityGroup group) throws GroupsException { Connection conn = null; boolean exists = existsInDatabase(group); try { conn = RDBMServices.getConnection(); setAutoCommit(conn, false); try { if (exists) { ...
java
@Override public void updateMembers(IEntityGroup eg) throws GroupsException { Connection conn = null; EntityGroupImpl egi = (EntityGroupImpl) eg; if (egi.isDirty()) try { conn = RDBMServices.getConnection(); setAutoCommit(conn, false); ...
java
protected String evaluateSpelExpression(String value, PortletRequest request) { if (StringUtils.isNotBlank(value)) { String result = portletSpELService.parseString(value, request); return result; } throw new IllegalArgumentException("SQL Query expression required"); }
java
private Cache getCache(PortletRequest req) { String cacheName = req.getPreferences().getValue(PREF_CACHE_NAME, DEFAULT_CACHE_NAME); if (StringUtils.isNotBlank(cacheName)) { log.debug("Looking up cache '{}'", cacheName); Cache cache = CacheManager.getInstance().getCache(cacheName)...
java
@Override public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { final List<IRequestParameterProcessor> incompleteDynamicProcessors = new LinkedList<IRequestParameterProcessor>(this.dynamicRequestParamete...
java
private HashMap<String, String> getPropertyFromRequest( HashMap<String, String> tokens, HttpServletRequest request) { // Iterate through all of the other property keys looking for the first property // named like propname that has a value in the request HashMap<String, String> retHas...
java
@Override public void add(IEntityLock lock) throws LockingException { Connection conn = null; try { conn = RDBMServices.getConnection(); primDeleteExpired(new Date(), lock.getEntityType(), lock.getEntityKey(), conn); primAdd(lock, conn); } catch (SQLExcept...
java
@Override public void delete(IEntityLock lock) throws LockingException { Connection conn = null; try { conn = RDBMServices.getConnection(); primDelete(lock, conn); } catch (SQLException sqle) { throw new LockingException("Problem deleting " + lock, sqle); ...
java
@Override public void deleteAll() throws LockingException { Connection conn = null; Statement stmnt = null; try { String sql = "DELETE FROM " + LOCK_TABLE; if (log.isDebugEnabled()) log.debug("RDBMEntityLockStore.deleteAll(): " + sql); conn = RDBMServices...
java
public void deleteExpired(IEntityLock lock) throws LockingException { deleteExpired(new Date(), lock.getEntityType(), lock.getEntityKey()); }
java
@Override public IEntityLock[] findUnexpired( Date expiration, Class entityType, String entityKey, Integer lockType, String lockOwner) throws LockingException { Timestamp ts = new Timestamp(expiration.getTime()); return selectUnexpired(ts, entityType, entityKey, lockType, loc...
java
private static String getDeleteLockSql() { if (deleteLockSql == null) { deleteLockSql = "DELETE FROM " + LOCK_TABLE + " WHERE " + ENTITY_TYPE_COLUMN + EQ ...
java
private static String getUpdateSql() { if (updateSql == null) { updateSql = "UPDATE " + LOCK_TABLE + " SET " + EXPIRATION_TIME_COLUMN + EQ +...
java
private void initialize() throws LockingException { Date expiration = new Date(System.currentTimeMillis() - (60 * 60 * 1000)); deleteExpired(expiration, null, null); }
java
private IEntityLock instanceFromResultSet(java.sql.ResultSet rs) throws SQLException, LockingException { Integer entityTypeID = rs.getInt(1); Class entityType = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(entityTypeID); String key = rs.getString(2); int lockType =...
java
private void primAdd(IEntityLock lock, Connection conn) throws SQLException, LockingException { Integer typeID = EntityTypesLocator.getEntityTypes().getEntityIDFromType(lock.getEntityType()); String key = lock.getEntityKey(); int lockType = lock.getLockType(); Timestamp t...
java
private IEntityLock[] primSelect(String sql) throws LockingException { Connection conn = null; Statement stmnt = null; ResultSet rs = null; List locks = new ArrayList(); if (log.isDebugEnabled()) log.debug("RDBMEntityLockStore.primSelect(): " + sql); try { c...
java
@Override public IEntityGroupStore newGroupStore(ComponentGroupServiceDescriptor svcDescriptor) throws GroupsException { FileSystemGroupStore fsGroupStore = (FileSystemGroupStore) getGroupStore(); String groupsRoot = (String) svcDescriptor.get("groupsRoot"); if (groupsRoot != nul...
java
@Deprecated public static DataSource getDataSource(String name) { if (PORTAL_DB.equals(name)) { return PortalDbLocator.getPortalDb(); } final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext(); final DataSource...
java
@Deprecated public static Connection getConnection(String dbName) { final DataSource dataSource = getDataSource(dbName); try { final long start = System.currentTimeMillis(); final Connection c = dataSource.getConnection(); lastDatabase = databaseTimes.add(System....
java
public static void closeResultSet(final ResultSet rs) { if (rs == null) { return; } try { rs.close(); } catch (Exception e) { if (LOG.isWarnEnabled()) LOG.warn("Error closing ResultSet: " + rs, e); } }
java
public static void closeStatement(final Statement st) { if (st == null) { return; } try { st.close(); } catch (Exception e) { if (LOG.isWarnEnabled()) LOG.warn("Error closing Statement: " + st, e); } }
java
public static final void rollback(final Connection connection) { try { connection.rollback(); } catch (Exception e) { if (LOG.isWarnEnabled()) LOG.warn("Error rolling back Connection: " + connection, e); } }
java
public static final boolean dbFlag(final String flag) { return flag != null && (FLAG_TRUE.equalsIgnoreCase(flag) || FLAG_TRUE_OTHER.equalsIgnoreCase(flag)); }
java
public static final String sqlEscape(final String sql) { if (sql == null) { return ""; } int primePos = sql.indexOf("'"); if (primePos == -1) { return sql; } final StringBuffer sb = new StringBuffer(sql.length() + 4); int startPos = 0; ...
java
protected EvaluationContext getEvaluationContext(WebRequest request) { final HttpServletRequest httpRequest = this.portalRequestUtils.getOriginalPortalRequest(request); final IUserInstance userInstance = this.userInstanceManager.getUserInstance(httpRequest); final IPerson person ...
java
@Override public IPermission[] getPermissions(String activity, String target) throws AuthorizationException { return getAuthorizationService().getPermissionsForOwner(getOwner(), activity, target); }
java
protected void addFetches(final Root<PortletEntityImpl> definitionRoot) { definitionRoot .fetch(PortletEntityImpl_.portletPreferences, JoinType.LEFT) .fetch(PortletPreferencesImpl_.portletPreferences, JoinType.LEFT) .fetch(PortletPreferenceImpl_.values, JoinType.L...
java
public void mark(int eventLimit) { this.eventLimit = eventLimit; // Buffering no events now, clear the buffer and buffered reader if (this.eventLimit == 0) { this.eventBuffer.clear(); this.bufferReader = null; } // Buffering limited set of events, lets tr...
java
private void addToLocaleList(List localeList, List<Locale> locales) { if (locales != null) { for (Locale locale : locales) { if (locale != null && !localeList.contains(locale)) localeList.add(locale); } } }
java
public static String permissionTargetIdForPortletDefinition( final IPortletDefinition portletDefinition) { Validate.notNull( portletDefinition, "Cannot compute permission target ID for a null portlet definition."); final String portletPublicationId = ...
java
public void startServer() { if (!System.getProperties().containsKey(JMX_ENABLED_PROPERTY)) { this.logger.info( "System Property '" + JMX_ENABLED_PROPERTY + "' is not set, skipping initialization."); return; ...
java
public void stopServer() { if (this.jmxConnectorServer == null) { this.logger.info("No JMXConnectorServer to stop"); return; } try { try { this.jmxConnectorServer.stop(); this.logger.info("Stopped JMXConnectorServer"); ...
java
protected int calculatePortTwo(final int portOne) { int portTwo = this.portTwo; if (portTwo <= 0) { portTwo = portOne + 1; } if (this.logger.isDebugEnabled()) { this.logger.debug("Using " + portTwo + " for portTwo."); } return portTwo; }
java
protected JMXServiceURL getServiceUrl(final int portOne, int portTwo) { final String jmxHost; if (this.host == null) { final InetAddress inetHost; try { inetHost = InetAddress.getLocalHost(); } catch (UnknownHostException uhe) { throw n...
java
protected Map<String, Object> getJmxServerEnvironment() { final Map<String, Object> jmxEnv = new HashMap<String, Object>(); // SSL Options final String enableSSL = System.getProperty(JMX_SSL_PROPERTY); if (Boolean.getBoolean(enableSSL)) { SslRMIClientSocketFactory csf = new ...
java
protected final Set<AggregatedGroupMapping> collectAllGroupsFromParams( Set<K> keys, AggregatedGroupMapping[] aggregatedGroupMappings) { final Builder<AggregatedGroupMapping> groupsBuilder = ImmutableSet.<AggregatedGroupMapping>builder(); // Add all groups from the keyset ...
java
public String getSelectedProfile(PortletRequest request) { // if a profile selection exists in the session, use it final PortletSession session = request.getPortletSession(); String profileName = (String) session.getAttribute( ...
java
public static void addParameter(IUrlBuilder urlBuilder, String name, String value) { urlBuilder.addParameter(name, value); }
java
public boolean nameExists(final String name) { boolean rslt = false; // default try { final ITenant tenant = this.tenantDao.getTenantByName(name); rslt = tenant != null; } catch (IllegalArgumentException iae) { // This exception is completely fine; it simply ...
java
public boolean fnameExists(final String fname) { boolean rslt = false; // default try { final ITenant tenant = getTenantByFName(fname); rslt = tenant != null; } catch (IllegalArgumentException iae) { // This exception is completely fine; it simply ...
java
public void validateName(final String name) { Validate.validState( TENANT_NAME_VALIDATOR_PATTERN.matcher(name).matches(), "Invalid tenant name '%s' -- names must match %s .", name, TENANT_NAME_VALIDATOR_REGEX); }
java
public void validateFname(final String fname) { Validate.validState( TENANT_FNAME_VALIDATOR_PATTERN.matcher(fname).matches(), "Invalid tenant fname '%s' -- fnames must match %s .", fname, TENANT_FNAME_VALIDATOR_REGEX); }
java
@RenderMapping public String showConfigPage( RenderRequest request, PortletPreferences preferences, Model model) { // Add skin names SortedSet<String> skins = skinService.getSkinNames(request); model.addAttribute("skinNames", skins); // Get the list of preferences and ad...
java
public static synchronized IEntityGroupStore getGroupStore() { if (groupStore == null) { groupStore = new GrouperEntityGroupStore(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("returning IEntityGroupStore: " + groupStore); } return groupStore; }
java
@Override public IEntityGroupStore newGroupStore(ComponentGroupServiceDescriptor svcDescriptor) throws GroupsException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Creating New Grouper IEntityGroupStore"); } return getGroupStore(); }
java
@Override public void onApplicationEvent(LoginEvent loginEvent) { if (enableMarketplacePreloading) { final IPerson person = loginEvent.getPerson(); /* * Passing an empty collection pre-loads an unfiltered collection; * instances of PortletMarketplace that sp...
java
private void collectSpecifiedAndDescendantCategories( PortletCategory specified, Set<PortletCategory> gathered) { final Set<PortletCategory> children = portletCategoryRegistry.getAllChildCategories(specified); for (PortletCategory child : children) { collectSpecif...
java
@Override @RequestCache public boolean mayAddPortlet(final IPerson user, final IPortletDefinition portletDefinition) { Validate.notNull(user, "Cannot determine if null users can browse portlets."); Validate.notNull( portletDefinition, "Cannot determine whether a u...
java
void lock(String serverId) { Assert.notNull(serverId); if (this.locked) { throw new IllegalStateException("Cannot lock already locked mutex: " + this); } this.locked = true; this.lockStart = new Date(); this.lastUpdate = this.lockStart; this.serverId =...
java
public static void setUserPreference( Element compViewNode, String attributeName, IPerson person) { Document doc = compViewNode.getOwnerDocument(); NodeList nodes = doc.getElementsByTagName("layout"); boolean layoutOwner = false; Attr attrib; Element e; // Se...
java
@Override public Set<String> getPossibleUserAttributeNames() { final Set<String> names = new HashSet<String>(); names.addAll(this.possibleUserAttributes); names.addAll(localAccountDao.getCurrentAttributeNames()); names.add(displayNameAttribute); return names; }
java
@Override public Set<String> getAvailableQueryAttributes() { if (this.queryAttributeMapping == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(this.queryAttributeMapping.keySet()); }
java
protected IPersonAttributes mapPersonAttributes(final ILocalAccountPerson person) { final Map<String, List<Object>> mappedAttributes = new LinkedHashMap<String, List<Object>>(); mappedAttributes.putAll(person.getAttributes()); // map the user's username to the portal's username...
java
@Override public EntityIdentifier[] searchForGroups( String query, IGroupConstants.SearchMethod method, Class leaftype) throws GroupsException { Set allIds = new HashSet(); for (Iterator services = getComponentServices().values().iterator(); services.hasNext(); ) { ...
java
public IEntityGroupStore newInstance() throws GroupsException { try { return new RDBMEntityGroupStore(); } catch (Exception ex) { log.error("ReferenceEntityGroupStoreFactory.newInstance(): " + ex); throw new GroupsException(ex); } }
java
private void initMapper() { final BeanPropertyFilter filterOutAllExcept = SimpleBeanPropertyFilter.filterOutAllExcept("fname", "executionTimeNano"); this.mapper.addMixInAnnotations( PortalEvent.class, PortletRenderExecutionEventFilterMixIn.class); final SimpleFilt...
java
@Override protected Properties mergeProperties() throws IOException { Properties rslt = null; /* * If properties file encryption is used in this deployment, the * encryption key will be made available to the application as an * environment variable called UP_JASYPT_KEY. ...
java
public String generateRandomToken(int length) { final char[] token = new char[length]; for (int i = 0; i < length; i++) { final int tokenIndex = random.nextInt(this.tokenChars.length); token[i] = tokenChars[tokenIndex]; } return new String(token); }
java
@PostLoad @PostPersist @PostUpdate @PostRemove private void init() { if (this.internalPortletDefinitionId != -1 && (this.portletDefinitionId == null || this.portletDefinitionId.getLongId() != this.internalPortletDefinitionId...
java
@BasePortalJpaDao.PortalTransactional public void resetUserLayoutAllProfiles(final IPersonAttributes personAttributes) { final IPerson person = PersonFactory.createRestrictedPerson(); person.setAttributes(personAttributes.getAttributes()); // get the integer uid into the person object withou...
java
@Override @PortalTransactional public IMarketplaceRating createOrUpdateRating( IMarketplaceRating marketplaceRatingImplementation) { Validate.notNull(marketplaceRatingImplementation, "MarketplaceRatingImpl must not be null"); final EntityManager entityManager = this.getEntityManager(...
java
protected void afterMarkup() { final Set<StackState> state = scopeState.getFirst(); state.add(StackState.WROTE_MARKUP); }
java
protected void afterData() { final Set<StackState> state = scopeState.getFirst(); state.add(StackState.WROTE_DATA); }
java
protected String getIndent(int depth, int size) { final int length = depth * size; String indent = indentCache.get(length); if (indent == null) { indent = getLineSeparator() + StringUtils.repeat(" ", length); indentCache.put(length, indent); } return inden...
java
protected Tuple<String, IPortletWindowId> parsePortletParameterName( HttpServletRequest request, String name, Set<String> additionalPortletIds) { // Look for a 2nd separator which might indicate a portlet window id for (final String additionalPortletId : additionalPortletIds) { f...
java
protected void addPortletUrlData( final HttpServletRequest request, final UrlStringBuilder url, final UrlType urlType, final IPortletUrlBuilder portletUrlBuilder, final IPortletWindowId targetedPortletWindowId, final boolean statelessUrl) { ...
java
protected String getEncoding(HttpServletRequest request) { final String encoding = request.getCharacterEncoding(); if (encoding != null) { return encoding; } return this.defaultEncoding; }
java
public void updateIndex() { if (!isEnabled()) { return; } final IndexWriterConfig indexWriterConfig = new IndexWriterConfig(new StandardAnalyzer()); indexWriterConfig .setCommitOnClose(true) .setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_A...
java
@Override public IEntitySearcher newEntitySearcher() throws GroupsException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Creating New Grouper GrouperEntitySearcherFactory"); } return (IEntitySearcher) new GrouperEntityGroupStoreFactory().newGroupStore(); }
java
private boolean checkDatabaseVersion(String databaseName) { final Version softwareVersion = this.requiredProductVersions.get(databaseName); if (softwareVersion == null) { throw new IllegalStateException("No version number is configured for: " + databaseName); } final Version...
java
@Override public SearchResults getSearchResults(PortletRequest request, SearchRequest query) { final String queryString = query.getSearchTerms().toLowerCase(); final List<IPortletDefinition> portlets = portletDefinitionRegistry.getAllPortletDefinitions(); final HttpServletR...
java
@Override public IOpaqueCredentials getOpaqueCredentials() { if (parentContext != null && parentContext.isAuthenticated()) { NotSoOpaqueCredentials oc = new CacheOpaqueCredentials(); oc.setCredentials(this.cachedcredentials); return oc; } else return null; }
java
public static boolean isAdmin(IPerson p) { IAuthorizationPrincipal iap = AuthorizationServiceFacade.instance() .newPrincipal( p.getEntityIdentifier().getKey(), p.getEntityIdentifier().getType()); ret...
java
public static boolean isAdmin(IAuthorizationPrincipal ap) { IGroupMember member = AuthorizationServiceFacade.instance().getGroupMember(ap); return isAdmin(member); }
java
public static boolean isAdmin(IGroupMember member) { IEntityGroup adminGroup = null; try { adminGroup = GroupService.getDistinguishedGroup(PORTAL_ADMINISTRATORS_DISTINGUISHED_GROUP); } catch (GroupsException ge) { // cannot determine whether or not th...
java
@Override public boolean skinCssFileExists(DynamicSkinInstanceData data) { final String cssInstanceKey = getCssInstanceKey(data); // Check the existing map first since it is faster than accessing the actual file. if (instanceKeysForExistingCss.contains(cssInstanceKey)) { return t...
java
@Override public void generateSkinCssFile(DynamicSkinInstanceData data) { final String cssInstanceKey = getCssInstanceKey(data); synchronized (cssInstanceKey) { if (instanceKeysForExistingCss.contains(cssInstanceKey)) { /* * Two or more threads needing th...
java
private void processLessFile(DynamicSkinInstanceData data) throws IOException, LessException { // Prepare the LESS sources for compilation final LessSource lessSource = new LessSource(new File(getSkinLessPath(data))); if (logger.isDebugEnabled()) { final String result = lessSource....
java
@Override public SortedSet<String> getSkinNames(PortletRequest request) { // Context to access the filesystem PortletContext ctx = request.getPortletSession().getPortletContext(); // Determine the full path to the skins directory String skinsFilepath = ctx.getRealPath(localRelativeR...
java
@Override public ClientHttpResponse intercept( HttpRequest req, byte[] body, ClientHttpRequestExecution execution) throws IOException { Assert.notNull(propertyResolver); Assert.notNull(id); try { String authString = getOAuthAuthString(req); req.getHeaders...
java
private String getOAuthAuthString(HttpRequest req) throws OAuthException, IOException, URISyntaxException { RealmOAuthConsumer consumer = getConsumer(); OAuthAccessor accessor = new OAuthAccessor(consumer); String method = req.getMethod().name(); URI uri = req.getURI(); ...
java
private synchronized RealmOAuthConsumer getConsumer() { // could just inject these, but I kinda prefer pushing this out // to the properties file... if (consumer == null) { OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", ""); String realm = ...
java
@RenderMapping public String getView(RenderRequest req, Model model) { final String[] images = imageSetSelectionStrategy.getImageSet(req); model.addAttribute("images", images); final String[] thumbnailImages = imageSetSelectionStrategy.getImageThumbnailSet(req); model.addAttribute(...
java
private int getElementIndex(Node node) { final String nodeName = node.getNodeName(); int count = 1; for (Node previousSibling = node.getPreviousSibling(); previousSibling != null; previousSibling = previousSibling.getPreviousSibling()) { if (previousS...
java
static void applyAndUpdateDeleteSet(Document plf, Document ilf, IntegrationResult result) { Element dSet = null; try { dSet = getDeleteSet(plf, null, false); } catch (Exception e) { LOG.error("Exception occurred while getting user's DLM delete-set.", e); } ...
java