/** Accepts submission from the configuration page. */ public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException { checkPermission(Hudson.ADMINISTER); fullName = req.getParameter("fullName"); description = req.getParameter("description"); JSONObject json = req.getSubmittedForm(); List<UserProperty> props = new ArrayList<UserProperty>(); int i = 0; for (UserPropertyDescriptor d : UserProperty.all()) { UserProperty p = getProperty(d.clazz); JSONObject o = json.optJSONObject("userProperty" + (i++)); if (o != null) { if (p != null) { p = p.reconfigure(req, o); } else { p = d.newInstance(req, o); } p.setUser(this); } if (p != null) props.add(p); } this.properties = props; save(); rsp.sendRedirect("."); }
/** Loads the other data from disk if it's available. */ private synchronized void load() { properties.clear(); XmlFile config = getConfigFile(); try { if (config.exists()) config.unmarshal(this); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to load " + config, e); } // remove nulls that have failed to load for (Iterator<UserProperty> itr = properties.iterator(); itr.hasNext(); ) { if (itr.next() == null) itr.remove(); } // allocate default instances if needed. // doing so after load makes sure that newly added user properties do get reflected for (UserPropertyDescriptor d : UserProperty.all()) { if (getProperty(d.clazz) == null) { UserProperty up = d.newInstance(this); if (up != null) properties.add(up); } } for (UserProperty p : properties) p.setUser(this); }
/** Updates the user object by adding a property. */ public synchronized void addProperty(UserProperty p) throws IOException { UserProperty old = getProperty(p.getClass()); List<UserProperty> ps = new ArrayList<UserProperty>(properties); if (old != null) ps.remove(old); ps.add(p); p.setUser(this); properties = ps; save(); }
@Override public synchronized void readUsers() { for (String userPropertyKey : config.listKeys()) { UserProperty property = new UserProperty(userPropertyKey, config.getString(userPropertyKey)); UserModel user = getUser(property.getUsername()); if (user == null) user = new UserModel(property.getUsername()); PropertyMapper mapper = new PropertyMapper<UserModel>(user); mapper.map(property.getPropertyName(), property.getPropertyValue()); users.put(user.getUserName(), user); } }
/** * Set the context. Overrides this method for a macro * * @see org.w3c.css.css.CssCascadingOrder#order * @see org.w3c.css.css.StyleSheetParser#handleRule */ public void setSelectors(CssSelectors selector) { super.setSelectors(selector); if (color != null) { color.setSelectors(selector); } if (width != null) { width.setSelectors(selector); } if (style != null) { style.setSelectors(selector); } }
/** * Update the source file and the line. Overrides this method for a macro * * @param line The line number where this property is defined * @param source The source file where this property is defined */ public void setInfo(int line, String source) { super.setInfo(line, source); if (color != null) color.setInfo(line, source); if (width != null) width.setInfo(line, source); if (style != null) style.setInfo(line, source); }
/** Set this property to be important. Overrides this method for a macro */ public void setImportant() { super.setImportant(); if (color != null) color.setImportant(); if (width != null) width.setImportant(); if (style != null) style.setImportant(); }
@Override protected void init(final Object... initArgs) { this.requestedProfile = ((HumanId) initArgs[0]).getSelfAsValid(); this.currUserAsVisitor = ((HumanId) initArgs[1]).getSelfAsValid(); final HumansIdentity currUserAsVisitorHI = UserProperty.HUMANS_IDENTITY_CACHE.get((currUserAsVisitor.getHumanId()), ""); final HumansIdentity requestedProfileHI = UserProperty.HUMANS_IDENTITY_CACHE.get((requestedProfile.getHumanId()), ""); super.setWallProfileName(currUserAsVisitorHI.getHuman().getDisplayName()); super.setWallProfilePhoto( UserProperty.formatProfilePhotoUrl(currUserAsVisitorHI.getHumansIdentityProfilePhoto())); super.setWallTitle( MessageFormat.format( RBGet.gui().getString(TALK_AT_DOWN_TOWN_ER_0_S), requestedProfileHI.getHuman().getDisplayName())); final int friendCount = ((List<HumansNetPeople>) $$getHumanUserFromRequest(request) .cache(requestedProfile.getHumanId(), DownTownFlow.FRIENDS)) .size(); UCAddFriends: if (requestedProfile.equals(currUserAsVisitor)) { // Accessing own profile UCInviteFriendsIfNoFriends: { if (friendCount < 2) { $$displayNone(WallWidgetIds.wallWidget); String title = "Without followers your updates will be useless"; // https://upload.wikimedia.org/wikipedia/commons/8/8d/Ambox_padlock_red.svg new Info( request, new InfoCriteria().setImage("/images/What_is_exciting_lately.png"), $$(WallWidgetIds.wallGame)); new Info( request, new InfoCriteria().setImage("/images/What_is_exciting_lately_Talk.png"), $$(WallWidgetIds.wallGame)); new Info(request, new InfoCriteria(), $$(WallWidgetIds.wallGame)) { /** * Use this only in conjunction with GENERIC constructor. * * @param infoCriteria */ @Override protected void init(InfoCriteria infoCriteria) { UCSetFriendAddWidget: { String addFollowerTitle = ""; if (friendCount == 0) { addFollowerTitle = "Add 2 Follower emails To Start Posting!"; } else if (friendCount == 1) { addFollowerTitle = "Almost there! Add 1 More Follower To Posting!"; } new AdaptableSignup( request, new AdaptableSignupCriteria() .setHumanId(requestedProfile) .setWidgetTitle(addFollowerTitle) .setAdaptableSignupCallback( new AdaptableSignupCallback() { @Override public String afterInvite(final HumanId invitee) { return ai.ilikeplaces.logic.Listeners.widgets .UserProperty .HUMANS_IDENTITY_CACHE .get(invitee.getHumanId(), invitee.getHumanId()) .getHuman() .getDisplayName() + " is now following you!"; } @Override public String jsToSend(HumanId invitee) { return JSCodeToSend.refreshPageIn(5); } }), $$(InfoIds.InfoAppend)); } } }; } else { String addFollowerTitle = "Add more followers!"; new AdaptableSignup( request, new AdaptableSignupCriteria() .setHumanId(requestedProfile) .setWidgetTitle(addFollowerTitle) .setAdaptableSignupCallback( new AdaptableSignupCallback() { @Override public String afterInvite(final HumanId invitee) { return ai.ilikeplaces.logic.Listeners.widgets .UserProperty .HUMANS_IDENTITY_CACHE .get(invitee.getHumanId(), invitee.getHumanId()) .getHuman() .getDisplayName() + " is now following you!"; } @Override public String jsToSend(HumanId invitee) { return JSCodeToSend.refreshPageIn(5); } }), $$(WallWidgetIds.wallFollowers)); } } } fetchToEmail(); final Wall wall = DB.getHumanCrudWallLocal(true) .readWall(requestedProfile, new Obj<HumanId>(currUserAsVisitor), REFRESH_SPEC) .returnValueBadly(); final List<Msg> wallEntries = DB.getHumanCrudWallLocal(true) .readWallLastEntries( requestedProfile, new Obj<HumanId>(currUserAsVisitor), 25, REFRESH_SPEC_EMPTY) .returnValueBadly(); for (final Msg msg : wallEntries) { new UserProperty(request, $$(WallWidgetIds.wallContent), new HumanId(msg.getMsgMetadata())) { protected void init(final Object... initArgs) { $$(Controller.Page.user_property_content).setTextContent(msg.getMsgContent()); } }; } DB.getHumanCRUDHumansUnseenLocal(false) .removeEntry(currUserAsVisitor.getObjectAsValid(), wall.getWallId()); $$displayWallAsMuted( $$(WallWidgetIds.wallMute), wall.getWallMutes().contains(currUserAsVisitor)); UCFiltering: { final List<HumansNetPeople> beFriends = (List<HumansNetPeople>) $$getHumanUserFromRequest(request) .cache(requestedProfile.getHumanId(), DownTownFlow.FRIENDS); @_see( seeClasses = { WallWidgetHumansWall.class, PrivateEventDelete.class, PrivateEventView.class, Tribe.class }) final String peopleFetchToEmail1 = new People( request, new PeopleCriteria().setPeople((List<HumanIdFace>) (List<?>) beFriends), $(Controller.Page.Skeleton_left_column)) .fetchToEmail; Loggers.debug("PEOPLE FETCH TO EMAIL CONTENT:" + peopleFetchToEmail1); fetchToEmailSetLeftSidebar(peopleFetchToEmail1); fetchToEmailSetRightSidebar(" "); } }