/** * @param group the group to set * @param updatePerms if we are to trigger a superperms update. */ public void setGroup(Group group, Boolean updatePerms) { if (!this.getDataSource().groupExists(group.getName())) { getDataSource().addGroup(group); } group = getDataSource().getGroup(group.getName()); String oldGroup = this.group; this.group = group.getName(); flagAsChanged(); if (GroupManager.isLoaded()) { if (!GroupManager.BukkitPermissions.isPlayer_join() && (updatePerms)) GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); // Do we notify of the group change? String defaultGroupName = getDataSource().getDefaultGroup().getName(); // if we were not in the default group // or we were in the default group and the move is to a different // group. boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName))); if (notify) GroupManager.notify( this.getName(), String.format(" moved to the group %s.", group.getName())); GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED); } }
/** * @param entity * @param userDn * @return * @throws org.apache.directory.fortress.core.UpdateException */ Group deassign(Group entity, String userDn) throws FinderException, UpdateException { LdapConnection ld = null; String dn = getDn(entity.getName(), entity.getContextId()); LOG.debug("deassign group property dn [{}], member dn [{}]", dn, userDn); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, SchemaConstants.MEMBER_AT, userDn)); ld = getAdminConnection(); modify(ld, dn, mods, entity); } catch (LdapException e) { String error = "deassign group name [" + entity.getName() + "] user dn [" + userDn + "] caught " + "LDAPException=" + e.getMessage(); throw new UpdateException(GlobalErrIds.GROUP_USER_DEASSIGN_FAILED, error, e); } finally { closeAdminConnection(ld); } return get(entity); }
/** * @param group * @throws org.apache.directory.fortress.core.CreateException */ Group create(Group group) throws CreateException { LdapConnection ld = null; String nodeDn = getDn(group.getName(), group.getContextId()); try { LOG.debug("create group dn [{}]", nodeDn); Entry myEntry = new DefaultEntry(nodeDn); myEntry.add(SchemaConstants.OBJECT_CLASS_AT, GROUP_OBJ_CLASS); myEntry.add(SchemaConstants.CN_AT, group.getName()); // protocol is required: myEntry.add(GROUP_PROTOCOL_ATTR_IMPL, group.getProtocol()); // type is required: myEntry.add(GlobalIds.TYPE, group.getType().toString()); loadAttrs(group.getMembers(), myEntry, SchemaConstants.MEMBER_AT); loadProperties(group.getProperties(), myEntry, GROUP_PROPERTY_ATTR_IMPL, '='); if (StringUtils.isNotEmpty(group.getDescription())) { myEntry.add(SchemaConstants.DESCRIPTION_AT, group.getDescription()); } ld = getAdminConnection(); add(ld, myEntry); } catch (LdapException e) { String error = "create group node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage(); throw new CreateException(GlobalErrIds.GROUP_ADD_FAILED, error, e); } finally { closeAdminConnection(ld); } return group; }
public boolean addSubGroup(Group subGroup) { // Don't allow adding a subgroup if it's already set as the primary. if (this.group.equalsIgnoreCase(subGroup.getName())) { return false; } // User already has this subgroup if (containsSubGroup(subGroup)) return false; // If the group doesn't exists add it if (!this.getDataSource().groupExists(subGroup.getName())) { getDataSource().addGroup(subGroup); } subGroups.add(subGroup.getName()); flagAsChanged(); if (GroupManager.isLoaded()) { if (!GroupManager.BukkitPermissions.isPlayer_join()) GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED); } return true; // subGroup = getDataSource().getGroup(subGroup.getName()); // removeSubGroup(subGroup); // subGroups.add(subGroup.getName()); }
public BeanInjectionInfo(Class<?> clazz) { LOG.logDebug("Collect bean injection info for " + clazz); try { this.clazz = clazz; clazzAnnotation = clazz.getAnnotation(InjectionSupported.class); if (clazzAnnotation == null) { throw new RuntimeException("Injection not supported in " + clazz); } Group gr0 = new Group(""); groupsList.add(gr0); groupsMap.put(gr0.getName(), gr0); for (String group : clazzAnnotation.groups()) { Group gr = new Group(group); groupsList.add(gr); groupsMap.put(gr.getName(), gr); } BeanLevelInfo root = new BeanLevelInfo(); root.leafClass = clazz; root.init(this); properties = Collections.unmodifiableMap(properties); groupsList = Collections.unmodifiableList(groupsList); groupsMap = null; } catch (Throwable ex) { LOG.logError( "Error bean injection info collection for " + clazz + ": " + ex.getMessage(), ex); throw ex; } }
void addUserGroup(Group group) { if (group == null || group.getName() == null || group.getName().trim().length() <= 0) { return; } if (!groups.contains(group)) { groups.add(group); } }
void removeUserGroup(Group group) { if (group == null || group.getName() == null || group.getName().trim().length() <= 0) { return; } if (groups.contains(group)) { groups.remove(group); } }
/** * Deletes a group from the system. * * @param group the group to delete. */ public void deleteGroup(Group group) { // Fire event. GroupEventDispatcher.dispatchEvent( group, GroupEventDispatcher.EventType.group_deleting, Collections.emptyMap()); // Delete the group. provider.deleteGroup(group.getName()); // Expire all relevant caches. groupCache.remove(group.getName()); }
/** * Deletes a group from the system. * * @param group the group to delete. */ public void deleteGroup(Group group) { Map<String, Object> emptyMap = new HashMap<String, Object>(); // Fire event. GroupEventDispatcher.dispatchEvent( group, GroupEventDispatcher.EventType.group_deleting, emptyMap); // Delete the group. provider.deleteGroup(group.getName()); // Expire cache. groupCache.remove(group.getName()); }
public void load() throws IOException { File file = getFile(); if (file.exists()) { JsonObject rootObject = JSON_PARSER.parse(new FileReader(file)).getAsJsonObject(); for (JsonElement element : rootObject.getAsJsonArray("players")) { Player player = new Player(element.getAsJsonObject()); playerDB.put(player.getName(), player); } for (JsonElement element : rootObject.getAsJsonArray("groups")) { Group group = new Group(element.getAsJsonObject()); groupDB.put(group.getName(), group); } } else { //noinspection ResultOfMethodCallIgnored file.createNewFile(); JsonObject rootObject = new JsonObject(); rootObject.add("players", new JsonArray()); rootObject.add("groups", new JsonArray()); BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write(GSON.toJson(rootObject)); bw.close(); } }
public AggregationPipeline<T, U> group(final List<Group> id, final Group... groupings) { DBObject idGroup = new BasicDBObject(); for (Group group : id) { idGroup.put(group.getName(), group.getSourceField()); } DBObject group = new BasicDBObject("_id", idGroup); for (Group grouping : groupings) { Accumulator accumulator = grouping.getAccumulator(); group.put( grouping.getName(), new BasicDBObject(accumulator.getOperation(), accumulator.getField())); } stages.add(new BasicDBObject("$group", group)); return this; }
/** * Deletes a user from all the groups where he/she belongs. The most probable cause for this * request is that the user has been deleted from the system. * * @param user the deleted user from the system. */ public void deleteUser(User user) { JID userJID = XmppServer.getInstance().createJID(user.getUsername(), null); for (Group group : getGroups(userJID)) { if (group.getAdmins().contains(userJID)) { if (group.getAdmins().remove(userJID)) { // Remove the group from cache. groupCache.remove(group.getName()); } } else { if (group.getMembers().remove(userJID)) { // Remove the group from cache. groupCache.remove(group.getName()); } } } }
public Group getGroup(String groupName) { for (Group g : groups) { if (g.getName().equalsIgnoreCase(groupName)) return g; } return null; }
public void removeMemberFromGroup(Member member, Group group) throws InternalErrorException { // Remove member from group Attribute uniqueMember = new BasicAttribute( "uniqueMember", "perunUserId=" + member.getUserId() + ",ou=People," + ldapProperties.getLdapBase()); ModificationItem uniqueMemberItem = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, uniqueMember); this.updateGroup(group, new ModificationItem[] {uniqueMemberItem}); // Remove member from vo if this group is membersGroup if (group.getName().equals(VosManager.MEMBERS_GROUP) && group.getParentGroupId() == null) { // Remove info from vo this.updateVo(group.getVoId(), new ModificationItem[] {uniqueMemberItem}); // Remove also information from user Attribute memberOfPerunVo = new BasicAttribute("memberOfPerunVo", String.valueOf(group.getVoId())); ModificationItem memberOfPerunVoItem = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, memberOfPerunVo); this.updateUserWithUserId( String.valueOf(member.getUserId()), new ModificationItem[] {memberOfPerunVoItem}); } // Remove group info from member Attribute memberOf = new BasicAttribute( "memberOf", "perunGroupId=" + group.getId() + ",perunVoId=" + group.getVoId() + "," + ldapProperties.getLdapBase()); ModificationItem memberOfItem = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, memberOf); this.updateUserWithUserId( String.valueOf(member.getUserId()), new ModificationItem[] {memberOfItem}); }
public void parseGroup(Group g) throws Hdf5Exception, EndOfSequenceException { startGroup(g); java.util.List members = g.getMemberList(); // NOTE: parsing contents twice to ensure subgroups are handled before datasets // This is mainly because synapse_props groups will need to be parsed before dataset of // connections for (int j = 0; j < members.size(); j++) { HObject obj = (HObject) members.get(j); if (obj instanceof Group) { Group subGroup = (Group) obj; logger.logComment("--------- Found a sub group: " + subGroup.getName()); parseGroup(subGroup); } } for (int j = 0; j < members.size(); j++) { HObject obj = (HObject) members.get(j); if (obj instanceof Dataset) { Dataset ds = (Dataset) obj; logger.logComment("Found a dataset: " + ds.getName()); dataSet(ds); } } endGroup(g); }
private void createClasses(Group group, SGStateInfo sInfo) { if (sInfo.verbose()) { System.out.print("Creating classes for group: "); System.out.println(group.getName()); if (group.getName() == null) { System.out.println("cannot create classes for unnamed nested groups"); return; } } JClass[] classes = sourceFactory.createSourceCode(group, sInfo); processContentModel(group, sInfo); for (int i = 0; i < classes.length; i++) processJClass(classes[i], sInfo); } //-- createClasses
public Group getGroupByName(String name) { for (Group g : this.groups) { if (g.getName().equals(name)) { return g; } } return null; }
protected void addPropertiesWithPrefix(Properties properties, Group group) { if (properties != null) { if (group != null) { String prefix = group.getName() + "."; Properties suffixProperties = group.getProperties(); addPropertiesWithPrefix(properties, prefix, suffixProperties); } } }
private void _buildParentGroupsBreadcrumb( LayoutSet layoutSet, PortletURL portletURL, ThemeDisplay themeDisplay, StringBundler sb) throws Exception { Group group = layoutSet.getGroup(); if (group.isOrganization()) { Organization organization = OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId()); Organization parentOrganization = organization.getParentOrganization(); if (parentOrganization != null) { Group parentGroup = parentOrganization.getGroup(); LayoutSet parentLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet( parentGroup.getGroupId(), layoutSet.isPrivateLayout()); _buildParentGroupsBreadcrumb(parentLayoutSet, portletURL, themeDisplay, sb); } } else if (group.isUser()) { User groupUser = UserLocalServiceUtil.getUser(group.getClassPK()); List<Organization> organizations = OrganizationLocalServiceUtil.getUserOrganizations(groupUser.getUserId(), true); if (!organizations.isEmpty()) { Organization organization = organizations.get(0); Group parentGroup = organization.getGroup(); LayoutSet parentLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet( parentGroup.getGroupId(), layoutSet.isPrivateLayout()); _buildParentGroupsBreadcrumb(parentLayoutSet, portletURL, themeDisplay, sb); } } int layoutsPageCount = 0; if (layoutSet.isPrivateLayout()) { layoutsPageCount = group.getPrivateLayoutsPageCount(); } else { layoutsPageCount = group.getPublicLayoutsPageCount(); } if ((layoutsPageCount > 0) && !group.getName().equals(GroupConstants.GUEST)) { String layoutSetFriendlyURL = PortalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay); sb.append("<li><span><a href=\""); sb.append(layoutSetFriendlyURL); sb.append("\">"); sb.append(HtmlUtil.escape(group.getDescriptiveName())); sb.append("</a></span></li>"); } }
private void setTexts() { mTxtGroupName.setText(mGroup.getName()); mTxtGroupCreated.setText(mGroup.getCreatedString()); mTxtGroupDescription.setText(mGroup.getDescription()); mTxtGroupOwnerName.setText(mGroup.getOwner().getName()); mTxtGroupUsersCount.setText(Integer.toString(mGroup.getUsersCount())); mTxtGroupVideosCount.setText(Integer.toString(mGroup.getVideosCount())); }
public void addGroup(Group group) throws InternalErrorException { // Create a set of attributes Attributes attributes = new BasicAttributes(); // Create the objectclass to add Attribute objClasses = new BasicAttribute("objectClass"); objClasses.add("top"); objClasses.add("perunGroup"); // Add attributes attributes.put(objClasses); attributes.put("cn", group.getName()); attributes.put("perunGroupId", String.valueOf(group.getId())); attributes.put( "perunUniqueGroupName", new String(this.getVoShortName(group.getVoId()) + ":" + group.getName())); attributes.put("perunVoId", String.valueOf(group.getVoId())); if (group.getDescription() != null && !group.getDescription().isEmpty()) attributes.put("description", group.getDescription()); if (group.getParentGroupId() != null) { attributes.put( "perunParentGroup", "perunGroupId=" + group.getParentGroupId().toString() + ",perunVoId=" + group.getVoId() + "," + ldapProperties.getLdapBase()); attributes.put("perunParentGroupId", group.getParentGroupId().toString()); } // Create the entry try { ldapTemplate.bind( getGroupDN(String.valueOf(group.getVoId()), String.valueOf(group.getId())), null, attributes); log.debug( "New entry created in LDAP: Group {} in Vo with Id=" + group.getVoId() + ".", group); } catch (NameNotFoundException e) { throw new InternalErrorException(e); } }
private GroupIndex( Group group, String indexName, Integer indexId, Boolean isUnique, Boolean isPrimary, JoinType joinType) { super(group.getName(), indexName, indexId, isUnique, isPrimary, null, joinType); this.group = group; }
private boolean isAdminUser(User user) { if (user == null) { return false; } for (Group group : user.getGroups()) { if (ADMIN_GROUP.equals(group.getName())) { return true; } } return false; }
public AggregationPipeline<T, U> group(final String id, final Group... groupings) { DBObject group = new BasicDBObject("_id", "$" + id); for (Group grouping : groupings) { Accumulator accumulator = grouping.getAccumulator(); group.put( grouping.getName(), new BasicDBObject(accumulator.getOperation(), accumulator.getField())); } stages.add(new BasicDBObject("$group", group)); return this; }
public boolean isInGroup(String playerName, String groupName) { // boolean returnValue = false; for (Group group : groups) { if (group.getName().equalsIgnoreCase(groupName)) { return group.isInGroup(playerName); } } // Kikkit.MinecraftLog.info("isInGroup(" + playerName +", " + groupName + "): " + returnValue); return false; }
@Override public synchronized String toString() { StringWriter buf = new StringWriter(); PrintWriter printer = new PrintWriter(buf); printer.println("Profiler name = \"Default profiler\""); // $NON-NLS-1$ printer.printf( "%-70s%-10s%-10s%-10s%-10s%-10s\n", "Name", "OwnTotal", "Childs", "Total", "AvgTotal", "Count"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // //$NON-NLS-6$ //$NON-NLS-7$ repeat(printer, '=', 120, true); for (Group group : getStat().values()) { repeat(printer, '-', 4, false); printer.printf(" Group: %s ", group.getName()); // $NON-NLS-1$ repeat(printer, '-', 120 - 9 - 4 - group.getName().length(), true); for (Item item : group.getItems()) { String name[] = disassembleString(item.getName(), new int[] {69, 66, 66}); printer.printf( "%-69s %9s %9s %9s %9s %9d\n", //$NON-NLS-1$ name[0], formatTime(item.getOwnTime(), 9), formatTime(item.getChildsTime(), 9), formatTime(item.getTotalTime(), 9), formatTime(item.getAvgTotalTime(), 9), item.getItNum()); for (int i = 1; i < 3; i++) { if (name[i] != null) printer.printf(" %-46s\n", name[i]); // $NON-NLS-1$ else break; } } } printer.close(); buf.flush(); return buf.toString(); }
private boolean isWorldAllowedOperation(ProjectInstance projectInstance, Operation operation) { for (GroupOperation groupOperation : projectInstance.getAllowedGroupOperations()) { Group group = groupOperation.getAllowedGroup(); String groupName = group.getName(); if (MetaProjectConstants.USER_WORLD.equals(groupName)) { Set<Operation> operations = groupOperation.getAllowedOperations(); if (operations.contains(operation)) { return true; } } } return false; }
private void loadGroups() { FileInputStream inputStream; InputStreamReader reader; Scanner scanner = null; try { inputStream = new FileInputStream(currentGroupFileName); reader = new InputStreamReader(inputStream, "UTF-8"); scanner = new Scanner(reader); String line = ""; while (scanner.hasNextLine()) { line = scanner.nextLine(); // Check for comments. if (line.startsWith("#") || line.startsWith("//")) continue; String[] data = line.split(":"); if (data.length < 2) continue; if (data.length >= 2) { Group newGroup = new Group(data[0]); groups.add(newGroup); newGroup.setColor(ChatColor.getByCode(Integer.parseInt(data[1]))); if (Kikkit.IsDebugging) Kikkit.MinecraftLog.info(" Added group: " + newGroup.getName()); if (data.length > 2) { String[] commands = data[2].split(","); // TODO: Why must we do a foreach here? // Because java doesn't understand IEnumerable for (String str : commands) { if (Kikkit.IsDebugging) Kikkit.MinecraftLog.info(" command: " + str); newGroup.Commands.add(str); } } } } } catch (Exception e) { // TODO Auto-generated catch block // e.printStackTrace(); Kikkit.MinecraftLog.info(e.getMessage()); } finally { if (scanner != null) scanner.close(); } }
public boolean removeSubGroup(Group subGroup) { try { if (subGroups.remove(subGroup.getName())) { flagAsChanged(); if (GroupManager.isLoaded()) if (!GroupManager.BukkitPermissions.isPlayer_join()) GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED); return true; } } catch (Exception e) { } return false; }
/** * This method will remove group node from diretory. * * @param group * @throws org.apache.directory.fortress.core.RemoveException */ Group remove(Group group) throws RemoveException { LdapConnection ld = null; String nodeDn = getDn(group.getName(), group.getContextId()); LOG.debug("remove group dn [{}]", nodeDn); try { ld = getAdminConnection(); delete(ld, nodeDn, group); } catch (LdapException e) { String error = "remove group node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage(); throw new RemoveException(GlobalErrIds.GROUP_DELETE_FAILED, error, e); } finally { closeAdminConnection(ld); } return group; }