<%@ page import="java.net.*, java.text.*, java.io.*, java.util.*, com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.util.*, com.artima.website.*" errorPage="../error.jsp" %> <%@ include file="../global.jincl" %> <% // Four ways to come in here. An initial add, which is just add.jsp // with no other values. An edit, which has doEdit set to true and // nickname set to some value, such as matt. And posting either // from an add or an edit, in which case doPost is set to true, and // all four fields nickname, picture, blogName, and bio should be // filled in. String vendorHandle = ParamUtils.getParameter(request, "handle"); String vendorName = ParamUtils.getParameter(request, "name"); String vendorDescription = ParamUtils.getParameter(request,"desc"); String vendorLogo = ParamUtils.getParameter(request,"logo"); String vendorOfficialName = ParamUtils.getParameter(request,"offname"); boolean whitePaperVendor = ParamUtils.getBooleanParameter(request,"white", false); boolean pavilionVendor = ParamUtils.getBooleanParameter(request,"pavilion", false); boolean announceVendor = ParamUtils.getBooleanParameter(request,"announce", false); boolean chapterVendor = ParamUtils.getBooleanParameter(request,"chapter", false); boolean doEdit = ParamUtils.getBooleanParameter(request,"edit", false); boolean doPost = ParamUtils.getBooleanParameter(request,"doPost", false); vendorHandle = StringCleaner.trimAndMakeNullIfEmpty(vendorHandle); vendorName = StringCleaner.trimAndMakeNullIfEmpty(vendorName); vendorDescription = StringCleaner.trimAndMakeNullIfEmpty(vendorDescription); vendorLogo = StringCleaner.trimAndMakeNullIfEmpty(vendorLogo); vendorOfficialName = StringCleaner.trimAndMakeNullIfEmpty(vendorOfficialName); // Login code. Usually the following code (below the parameter code) is in // ../global.jsp, but on this page we're not including global.jsp so we can // have better control over the way UnauthorizedExceptions are handled. // Check to see if a Jive authorization token exists. Wrap that check in a // try/catch block so we can correctly redirect to login if necessary authToken = null; String pageUserNickName = null; try { authToken = SkinUtils.getUserAuthorization(request, response); if (authToken == null) { // This case means the session died or the appserver restarted and // wiped the session data. Throw an UnauthorizedException so we kick // the user to the login page. After they login, they'll redirect // to this page. throw new UnauthorizedException("User was logged in but authorization token was lost."); } pageUser = forumFactory.getUserManager().getUser(authToken.getUserID()); pageUserNickName = pageUser.getUsername(); } catch (UnauthorizedException ue) { // Redirect to ../login.jsp. If the subject & body are not null, post those // in the session. // Next construct the ../login.jsp referrer (the link it will redirect to) String url = "announce/add.jsp"; if (doEdit) { url += "?edit=true&handle=" + vendorHandle; } // Do the redirect String redirect = "../login.jsp?unauth=true&referrer=" + URLEncoder.encode(url); response.sendRedirect(redirect); return; } %> <% if (!pageUserNickName.equals("bv")) { %>

Sorry, you do not have permission to access this page.

<% return; } %> Add a Vendor
artima.com

Add a Vendor
<% boolean errors = false; String errorMessage = null; if (doPost && (vendorHandle == null)) { errors = true; errorMessage = "Sorry, you can't post a blank vendor handle."; } else if (doPost && (vendorName == null)) { errors = true; errorMessage = "Sorry, you can't post a blank vendor name."; } else if (doPost && (vendorDescription == null)) { errors = true; errorMessage = "Sorry, you can't post a blank vendor description."; } if (doPost && (vendorLogo == null)) { vendorLogo = "NONE"; } if(doPost && vendorOfficialName == null) { vendorOfficialName = vendorName; } if (errors) { %>

"> <%= errorMessage %>

<% } else if (doPost) { Authorization adminAuth = AuthorizationFactory.getAuthorization( flapper, glibnob); ForumFactory adminFactory = ForumFactory.getInstance(adminAuth); GroupManager adminGroupManager = adminFactory.getGroupManager(); Group vendorGroup = null; try { vendorGroup = adminGroupManager.getGroup(vendorHandle); } catch (GroupNotFoundException e) { vendorGroup = adminGroupManager.createGroup(vendorHandle); } vendorGroup.setProperty(ArtimaConstants.VENDOR_NAME, vendorName); vendorGroup.setProperty(ArtimaConstants.VENDOR_DESCRIPTION, vendorDescription); vendorGroup.setProperty(ArtimaConstants.VENDOR_LOGO, vendorLogo); vendorGroup.setProperty(ArtimaConstants.VENDOR_OFFICIAL_NAME, vendorOfficialName); if (whitePaperVendor) { vendorGroup.setProperty(ArtimaConstants.WHITE_PAPER_VENDOR_PROPERTY, "true"); } else { vendorGroup.deleteProperty(ArtimaConstants.WHITE_PAPER_VENDOR_PROPERTY); } if (pavilionVendor) { vendorGroup.setProperty(ArtimaConstants.PAVILION_VENDOR_PROPERTY, "true"); } else { vendorGroup.deleteProperty(ArtimaConstants.PAVILION_VENDOR_PROPERTY); } if (announceVendor) { vendorGroup.setProperty(ArtimaConstants.ANNOUNCEMENT_VENDOR_PROPERTY, "true"); } else { vendorGroup.deleteProperty(ArtimaConstants.ANNOUNCEMENT_VENDOR_PROPERTY); } if (chapterVendor) { vendorGroup.setProperty(ArtimaConstants.CHAPTER_VENDOR_PROPERTY, "true"); } else { vendorGroup.deleteProperty(ArtimaConstants.CHAPTER_VENDOR_PROPERTY); } response.sendRedirect("index.jsp"); return; } else if (doEdit) { if (vendorHandle != null) { GroupManager groupManager = forumFactory.getGroupManager(); Group vendorGroup = groupManager.getGroup(vendorHandle); vendorName = vendorGroup.getProperty(ArtimaConstants.VENDOR_NAME); vendorDescription = vendorGroup.getProperty(ArtimaConstants.VENDOR_DESCRIPTION); vendorLogo = vendorGroup.getProperty(ArtimaConstants.VENDOR_LOGO); vendorOfficialName = vendorGroup.getProperty(ArtimaConstants.VENDOR_OFFICIAL_NAME); if (vendorGroup.getProperty(ArtimaConstants.WHITE_PAPER_VENDOR_PROPERTY) != null) { whitePaperVendor = true; } if (vendorGroup.getProperty(ArtimaConstants.PAVILION_VENDOR_PROPERTY) != null) { pavilionVendor = true; } if (vendorGroup.getProperty(ArtimaConstants.ANNOUNCEMENT_VENDOR_PROPERTY) != null) { announceVendor = true; } if (vendorGroup.getProperty(ArtimaConstants.CHAPTER_VENDOR_PROPERTY) != null) { chapterVendor = true; } } } %>

<% int textareaCols = 60; int textareaRows = 7; %>
"> Vendor handle " size="20" maxlength="30">
"> Vendor name " size="50" maxlength="50">
"> Official name " size="60" maxlength="60">
"> Description
"> Vendor logo " size="60" maxlength="100">
"> White paper vendor >
"> Pavilion vendor >
"> Announcement vendor >
"> Chapter vendor >
   

Copyright © 1996-2003 Artima Software, Inc. All Rights Reserved.
Artima.com is created by Bill Venners