%@ include file="globalPaths.jsp" %><%@ include file="globalDefinitions.jsp" %><%@ page import="java.awt.*" %><%@ page import="javax.swing.*" %><%@ page import="java.awt.image.*" %><%
/*
* Show one artwork (Lobby, Portfolio, Open Studio).
* Redirect to appropriate page for other packages (Artist Studio, Artist Gallery, Gallery).
*/
Cookie[] cookies;
cookies = request.getCookies();
String cookieArtist = "";
for (int icook = 0; cookies!=null && icook < cookies.length; icook++)
{
Cookie cookie = cookies[icook];
if ((cookie.getName()).equals("galleryArtistID"))
{
cookieArtist = cookie.getValue();
}
}
String remoteIP = "UndefinedIP";
if (request.getRemoteAddr() != null)
{
remoteIP = request.getRemoteAddr();
}
/*
* Get page parameters.
*/
Integer artwork = getIntegerParameter("artwork");
/*
* Redirect to 404-ERROR page if missing OR incorrect parameters.
*/
if (artwork == null)
{
session.setAttribute("404.errorDescription", "Incorrect parameter value");
response.sendError(response.SC_NOT_FOUND);
return;
}
String prevArtwork = null;
String nextArtwork = null;
int countAll = 0;
int countArtwork = 0;
int iiwidth = 0;
int iiheight = 0;
URL iiurl=null;
String name = null;
String keywords = null;
String targetkeywords=null;
String artistName = null;
String artistID = null;
String technique = null;
String height = null;
String width = null;
String depth = null;
String available = null;
String price = null;
String printPrice = null;
String screenshot = null;
String md = "0";
String bigshot = null;
boolean bigshotExists = false;
String description = null;
String category = null;
String portfolio = null;
String siteURL = null;
String businessName = null;
String pack = null;
String shortBio = null;
String addition = null;
String company = null;
String sold = "";
String server = "";
String discount = "0";
String buyType = "N";
String oName = "";
String preferredHeight = null;
String preferredWidth = null;
String preferredWidthOfImageTD = null;
String openStudioHTMLText = "";
String divString = "";
String version = null;
String [] openStudioNames = {"Silicon Valley OPS",
"East Bay Open Studios (Pro Arts)",
"San Francisco OPS"};
String [] openStudioLinks = {"/openstudios/svopenstudios.jsp",
"/openstudios/ebos06.jsp",
"/openstudios/openstudios_SanFrancisco.jsp"};
String [] openStudioOutputNames = {"Silicon Valley OPS",
"Pro Arts East Bay
Open Studios",
"San Francisco OPS"};
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
String query = null;
boolean likeIt = false;
/*
* Load database record.
*/
boolean needCaching = true;
try
{
connection = openConnection();
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
query = "SELECT W.name, W.keywords,"
+ "W.technique, W.height, W.width, W.depth, W.available,"
+ "W.price, W.printPrice,"
+ "W.smallshot, W.screenshot, W.bigshot, W.category,"
+ "W.description, W.addition, W.sold,"
+ "W.targetkeywords, W.modifiedDate, W.discount, W.activeflag,"
+ "A.activeflag, A.id, A.firstName, A.lastName, A.company, A.package,"
+ "A.buyType,A.shortBiography, A.ipLastLoggedFrom, A.portfolio,"
+ "A.version, A.likeIt, Srv.httppath "
+ "FROM galleryArtwork W LEFT JOIN galleryArtist A ON W.artist = A.id "
+ "LEFT JOIN galleryServer Srv ON W.ftpserver=Srv.id "
+ "WHERE A.activeflag!='F' AND W.id=" + quoteString(artwork.toString())
+ " AND (W.activeflag='Y' OR W.activeflag='L' OR W.activeflag='V')";
resultSet = statement.executeQuery(query);
if (resultSet.next())
{
String af = resultSet.getString("A.activeflag");
if (!"Y".equals(af))
{
needCaching = false;
}
artistID = resultSet.getString("A.id");
if (!"Y".equals(af) && !artistID.equals(cookieArtist)
&& !remoteIP.equals(resultSet.getString("A.ipLastLoggedFrom"))
&& !artistID.equals((String)session.getValue("loggedartist"))
&& !"admin".equals((String)session.getValue("admin.logged")))
{
throw new UserInputException("The artwork "
+ "you are trying to view belongs to an account that "
+ "is not currently activated. If this is a new account, "
+ "the artist needs to complete the setup process before "
+ "the artwork will be available on the Internet.");
}
buyType=resultSet.getString("A.buyType");
company = resultSet.getString("A.company");
name = resultSet.getString("W.name");
keywords = resultSet.getString("W.keywords");
if (keywords == null)
keywords="";
targetkeywords = resultSet.getString("W.targetkeywords");
if (targetkeywords == null)
targetkeywords = "";
shortBio = resultSet.getString("A.shortBiography");
if (resultSet.getString("A.firstName").equals(""))
artistName = resultSet.getString("A.lastName");
else
artistName = resultSet.getString("A.firstName")
+ " " + resultSet.getString("A.lastName");
pack = resultSet.getString("A.package");
portfolio = resultSet.getString("A.portfolio");
if (portfolio.startsWith("http://") || portfolio.startsWith("https://")
|| portfolio.startsWith("www."))
{
siteURL = portfolio;
}
else
{
siteURL = globalSite + "/" + portfolio;
}
if (siteURL.endsWith("/"))
{
siteURL = siteURL.substring(0, siteURL.length() - 1);
}
request.setAttribute("siteURL", siteURL);
version = resultSet.getString("A.version");
likeIt = resultSet.getBoolean("A.likeIt");
technique = resultSet.getString("W.technique");
height = resultSet.getString("W.height");
width = resultSet.getString("W.width");
depth = resultSet.getString("W.depth");
discount=resultSet.getString("W.discount");
if (height!=null)
{
while (height.indexOf(".") >-1
&& (height.endsWith("0")
|| height.endsWith(".")))
{
height=height.substring(0,height.length()-1);
}
}
if (width != null)
{
while (width.indexOf(".") > -1
&& (width.endsWith("0")
|| width.endsWith(".")))
{
width = width.substring(0,width.length()-1);
}
}
if (depth!=null)
{
while (depth.indexOf(".") >- 1
&& (depth.endsWith("0")
|| depth.endsWith(".")))
{
depth = depth.substring(0,depth.length()-1);
}
}
server=resultSet.getString("Srv.httppath");
available = resultSet.getString("W.available");
price = resultSet.getString("W.price");
printPrice = resultSet.getString("W.printPrice");
screenshot = server + resultSet.getString("W.screenshot");
bigshot = resultSet.getString("W.bigshot");
bigshotExists = (bigshot != null) && (bigshot.length() > 0);
if (bigshotExists)
bigshot = server + bigshot;
md = getTimestampDigits(resultSet, "W.modifiedDate");
category = resultSet.getString("W.category");
description = resultSet.getString("W.description");
addition = resultSet.getString("W.addition");
sold = resultSet.getString("W.sold");
}
else
{
throw new UserInputException("Artwork not found");
}
resultSet.close();
if (company == null || company.length() == 0)
{
businessName = artistName;
}
else
{
businessName = company;
}
String redirectURL = null;
// Redirect to appropriate page at Artist Studio account
if ("3".equals(pack))
{
redirectURL = "artworkps.jsp";
String queryString = getQueryString();
// AP 091010 Add artist parameter to reference to artworkps.jsp
// to avoid showing one artist's art in another's account
if (queryString != null && queryString.indexOf("artist=") == -1)
redirectURL += "?artist=" + artistID;
redirectURL = addQueryString(redirectURL);
sendRedirect(redirectURL);
return;
}
// Redirect to appropriate page at Artist Gallery and Gallery Package.
// Exception: Do not redirect if version is 0, which indicates
// a really old artist gallery (Mikhail Gorshunov) which uses
// the same artwork.jsp as portfolio, so redirecting in such case
// would result in an infinite loop.
if ("2".equals(pack) && Double.valueOf(version) == 0.0)
pack = "1";
if (("2".equals(pack) && Double.valueOf(version) > 0.0) || "4".equals(pack))
{
redirectURL = portfolio + "/artwork.vm";
redirectURL = addQueryString(redirectURL);
// AP- temp Started having a lot of 'File not found' errors in the log
//if (Double.valueOf(version) >= 2.0)
// artworkURL = artworkURL.replace("artwork.jsp", "artwork.vm");
sendRedirect(redirectURL);
return;
}
if (!"0".equals(pack) && !"1".equals(pack) && !"5".equals(pack))
{
throw new Exception("Incorrect package");
}
query = "SELECT W.id FROM galleryArtwork W "
+ "LEFT JOIN gallerySeries S ON W.series = S.id "
+ "WHERE W.artist = " + quoteString(artistID) + " AND "
+ "(W.activeflag='Y' OR W.activeflag='L' OR W.activeflag='V') "
+ "ORDER BY S.sortid, W.sortid";
resultSet = statement.executeQuery(query);
while (resultSet.next())
{
if (countArtwork <= 0)
countArtwork --;
countAll ++;
if ((resultSet.getString("W.id")).equals(artwork.toString()))
{
countArtwork = -countArtwork;
if (resultSet.previous())
{
prevArtwork = resultSet.getString("W.id");
}
resultSet.next();
if (resultSet.next())
{
countAll ++;
nextArtwork = resultSet.getString("W.id");
}
}
}
resultSet.close();
}
catch (UserInputException uie)
{
session.setAttribute("404.errorDescription", uie.getMessage());
// AP 030309 Do not log these errors since they clutter logs/missing.log
session.setAttribute("404.log", "0");
response.sendError(response.SC_NOT_FOUND);
return;
}
catch (Exception e)
{
errorLog(e, query);
sendRedirect(globalErrorPage + "?errorDescription="
+ URLEncoder.encode(e.getMessage() + "."));
return;
}
finally
{
if (resultSet != null) resultSet.close();
if (connection != null && !connection.isClosed()) connection.close();
}
%><%@ include file="cacheBegin.jsp" %><%
if (needCaching)
{
%><%@ include file="cacheLaunch.jsp" %><%
}
%><%
String plainDescription = description != null ? unfilterHTML(description) : "";
String pageTechnique = toUpperCaseFirstLetter(technique);
String pageTitle = artistName + "'s " + name + " (" + pageTechnique + ")";
if (targetkeywords != null && targetkeywords.length() > 0)
pageTitle = targetkeywords;
keywords = keywords.replace(name + ",", ""); // Remove artwork name from keyword string, so that it is not repeated.
keywords = keywords.replace(name, "");
String pageKeywords = name + ", " + pageTechnique + (keywords.length() > 0 ? ", " + keywords : "")
+ (targetkeywords.length() > 0 ? ", " + targetkeywords : "");
String pageDescription = artistName + "'s" + " '" + name + "' " + technique
+ (keywords.length() > 0 ? " (" + keywords + ")" : "")
+ (plainDescription.length() > 0 ? ": " + plainDescription : "")
+ (targetkeywords.length() > 0 ? " (" + targetkeywords + ")" : "");
pageDescription = HTML.sanitizeHtmlTags(pageDescription, true);
String originalURL = globalSite + "/" + getPageName() + getQueryTail();
String htmlTag = "xmlns:art=\"http://www.mesart.com/ns#\"";
String ogType = pageTechnique;
ogType = ogType.replace(' ', '_'); // og:type doesn't allow whitespace
String metatags =
"\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "";
try
{
iiurl=new URL(screenshot);
ImageIcon ii=new ImageIcon(iiurl);
iiwidth=ii.getIconWidth();
iiheight=ii.getIconHeight();
if ((float)iiheight/iiwidth > 1.15)
{
preferredHeight = "457";
preferredWidth = "" + (457*iiwidth/iiheight >= 390 ? 390 : 457*iiwidth/iiheight);
}
else
{
if ((float)iiheight/iiwidth < 1/1.15)
{
preferredWidth = "390";
}
else
{
preferredWidth = "380";
}
}
}
catch(Exception e)
{
preferredWidth = "200";
}
preferredWidthOfImageTD = "462";
boolean availableToBuy = false;
boolean possibleForNegotiating = false;
boolean availableArtwork = "1".equals(available);
if (availableArtwork
|| (!(printPrice == null || (new Double(printPrice).doubleValue() < 2.0)
|| printPrice.equals(""))))
availableToBuy = true;
if (discount != null && !discount.equals("0") && !discount.equals("")
&& !"D".equals(buyType))
possibleForNegotiating = true;
String convertedShortBio =
substituteTokens(convertHTMLSymbolsToPlainNew(shortBio),"
"," ");
boolean packageLobby = false;
boolean packageOpenStudio = false;
boolean packagePortfolio = false;
boolean packageArtistStudio = false;
boolean packageAutoPrivateStudio = false;
packageLobby = "0".equals(pack);
packagePortfolio = "1".equals(pack);
packageArtistStudio = "2".equals(pack);
packageAutoPrivateStudio = "3".equals(pack);
packageOpenStudio = "5".equals(pack);
session.setAttribute("orderReferrerURL", getURL());
session.setAttribute("orderReferrerArtist", artistID);
session.setAttribute("orderReferrerPack", pack);
%> >
<%
if (possibleForNegotiating)
{
%>
<%
}
}
else
{
if ("1".equals(sold))
{
needLine = true;
%>
<%
}
}
if (needLine)
{
%>
<%
}
%>" onClick="resetSlideshow();return true;">
| <% if (prevArtwork != null) { %> Previous <% } %> | <%
if (prevArtwork != null)
{
%> |
<%= countArtwork %> of <%= countAll %> | <%
if (nextArtwork != null)
{
%> |
<% if (nextArtwork != null) { %> Next <% } %> All |
| <% if (packagePortfolio || packageOpenStudio) { %><% } %><% //if (packageArtistStudio) { %>More art by <%= artistName %><% } %> | ||||
![]() <%= convertedShortBio %> |
||
| <% if (packagePortfolio || packageOpenStudio) { %><% } %><%= artistName %><% if (packagePortfolio || packageOpenStudio) { %><% } %> | |
| <%= name %> | |
| <%= technique %> | |
| <% boolean needPrintIn = false; if (!((height == null) || "0".equals(height) || "0.0".equals(height))) { needPrintIn = true; %><%= height %><% } if (!((width == null) || "0".equals(width) || "0.0".equals(width))) { needPrintIn = true; %> x <%= width %><% } if (!((depth == null) || "0".equals(depth) || "0.0".equals(depth))) { needPrintIn = true; %> x <%= depth %> <% } if (needPrintIn) { %> in<% } %> | |
| <%= addition %> | |
| <% if (availableArtwork ||(!((new Double(printPrice).doubleValue() < 2.0) || "".equals(printPrice)))) { %><% } %><%= "1".equals(available) ? formatPrice(price, true) : ("1".equals(sold) ? "Sold" : "") %><% if (availableArtwork ||(!((new Double(printPrice).doubleValue() < 2.0) || "".equals(printPrice)))) { %><% } %> | |
| Giclee Print: <%= formatPrice(printPrice, true) %> | |
![]() |
|
| Send this artwork to friends Wishlist: Add | Remove | View |
|
![]() |
|
<%
if (packagePortfolio || packageOpenStudio)
{
%><%
}
%> <%
if (packagePortfolio || packageOpenStudio)
{
%><%
}
%>
<%
if (packagePortfolio || packageOpenStudio)
{
%>
<%
}
%> |
|
![]() |
|
| Contact info | |
![]() |
|
|
<%= description %>
|
|