[jboss-svn-commits] JBL Code SVN: r9772 - in labs/jbosslabs/trunk/portal-extensions: jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Feb 26 17:57:00 EST 2007


Author: szimano
Date: 2007-02-26 17:57:00 -0500 (Mon, 26 Feb 2007)
New Revision: 9772

Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/WikiCommandFactory.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/RequestInvocationHandler.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/WikiPortletMyFaces.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiEdit.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiView.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/web/views/wiki_edit.xhtml
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/com/ecyrd/jspwiki/plugin/ImagePlugin.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java
   labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/configuration/ConfigurationParser.java
Log:
wiki bugs and mapper fix

Modified: labs/jbosslabs/trunk/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/WikiCommandFactory.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/WikiCommandFactory.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/forge-mapper/src/java/org/jboss/labs/mapper/command/WikiCommandFactory.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -15,109 +15,121 @@
  * @author <a href="mailto:adamw at aster.pl">Adam Warski</a>
  */
 public class WikiCommandFactory extends AbstractLabsDelegateCommandFactory {
-    private String pageName;
-    private PortalObjectId wikiPageId;
+	private String pageName;
 
-    private String windowName;
-    private PortalObjectId windowId;
+	private PortalObjectId wikiPageId;
 
-    private LabsPortalObjectCommandFactory portalObjectCF;
+	private String windowName;
 
-    private void setIds() {
-        if ((pageName != null) && (windowName != null)) {
-            wikiPageId = PortalObjectId.parse("/" + Constants.LABS_PORTAL + "/" + pageName,
-                    PortalObjectId.CANONICAL_FORMAT);
+	private PortalObjectId windowId;
 
-            windowId = PortalObjectId.parse("/" + Constants.LABS_PORTAL + "/" + pageName +
-                    "/" + windowName, PortalObjectId.CANONICAL_FORMAT);
-        }
-    }
+	private LabsPortalObjectCommandFactory portalObjectCF;
 
-    public String getPageName() {
-        return pageName;
-    }
+	private void setIds() {
+		if ((pageName != null) && (windowName != null)) {
+			wikiPageId = PortalObjectId.parse("/" + Constants.LABS_PORTAL + "/"
+					+ pageName, PortalObjectId.CANONICAL_FORMAT);
 
-    public void setPageName(String pageName) {
-        this.pageName = pageName;
-        setIds();
-    }
+			windowId = PortalObjectId.parse("/" + Constants.LABS_PORTAL + "/"
+					+ pageName + "/" + windowName,
+					PortalObjectId.CANONICAL_FORMAT);
+		}
+	}
 
-    public String getWindowName() {
-        return windowName;
-    }
+	public String getPageName() {
+		return pageName;
+	}
 
-    public void setWindowName(String windowName) {
-        this.windowName = windowName;
-        setIds();
-    }
+	public void setPageName(String pageName) {
+		this.pageName = pageName;
+		setIds();
+	}
 
-    public LabsPortalObjectCommandFactory getPortalObjectCF() {
-        return portalObjectCF;
-    }
+	public String getWindowName() {
+		return windowName;
+	}
 
-    public void setPortalObjectCF(LabsPortalObjectCommandFactory portalObjectCF) {
-        this.portalObjectCF = portalObjectCF;
-    }
+	public void setWindowName(String windowName) {
+		this.windowName = windowName;
+		setIds();
+	}
 
-    private ControllerCommand getDefaultCommand() {
-        return new RenderPageCommand(wikiPageId);
-    }
+	public LabsPortalObjectCommandFactory getPortalObjectCF() {
+		return portalObjectCF;
+	}
 
-    public ControllerCommand doMapping(ServerInvocation invocation, String host,
-                                       String contextPath, PathParser parser) {
-        String firstToken = parser.getFirstToken();
-        String language = null;
-        String current = parser.getCurrent();
+	public void setPortalObjectCF(LabsPortalObjectCommandFactory portalObjectCF) {
+		this.portalObjectCF = portalObjectCF;
+	}
 
-        if ((firstToken != null) && (firstToken.length() == 2) &&
-                (Character.isUpperCase(firstToken.charAt(1)))) {
-            language = firstToken;
-            parser.proceed();
-        }
+	private ControllerCommand getDefaultCommand() {
+		return new RenderPageCommand(wikiPageId);
+	}
 
-        String page = null;
-        while (parser.hasFirstToken()) {
-            firstToken = parser.getFirstToken();
-            if (Character.isUpperCase(firstToken.charAt(0))) {
-                if (page == null) {
-                    page = firstToken;
-                } else {
-                    page += "/" + firstToken;
-                }
-            } else {
-                sendRedirect(invocation, "/wiki-files/" + current);
-                return null;
-            }
+	public ControllerCommand doMapping(ServerInvocation invocation,
+			String host, String contextPath, PathParser parser) {
+		String firstToken = parser.getFirstToken();
+		String language = null;
+		String current = parser.getCurrent();
 
-            parser.proceed();
-        }
+		if ((firstToken != null)
+				&& (firstToken.length() == 2)
+				&& (Character.isLowerCase(firstToken.charAt(0)) && Character
+						.isLowerCase(firstToken.charAt(1)))) {
+			language = firstToken.toUpperCase();
+			parser.proceed();
+		}
 
-        String version = null;
-        if ((page != null) && (page.contains(":"))) {
-            String[] tokens = page.split("[:]", 2);
-            if ((tokens.length == 2)) {
-                page = tokens[0];
-                version = tokens[1];
-            } else {
-                return getDefaultCommand();
-            }
-        }
+		String page = null;
+		while (parser.hasFirstToken()) {
+			firstToken = parser.getFirstToken();
+			if (Character.isUpperCase(firstToken.charAt(0))) {
+				if (page == null) {
+					page = firstToken;
+				} else {
+					page += "/" + firstToken;
+				}
+			} else {
+				sendRedirect(invocation, "/wiki-files/" + current);
+				return null;
+			}
 
-        PortletParametersStateString params = new PortletParametersStateString();
-        params.setValue(MapperTools.JSF_VIEW_ID_PARAM, "/views/wiki_view.xhtml");
-        if (page != null) params.setValue("page", page);
-        if (language != null) { params.setValue("language", language); }
-        if (version != null) { params.setValue("version", version); }
-        
-        Window wikiWindow = (Window) getContainer().getObject(windowId);
-        if (hasMetaParameter(invocation)) {
-            return getPortalObjectCF().doMapping(invocation, wikiWindow, params.getMap(),
-                    false);
-        } else {
-            params.setValue(PortletRequestDecoder.META_PARAMETER,
-                    Integer.toString(PortletRequestDecoder.RENDER_MASK));
-            return getPortalObjectCF().doMapping(invocation, wikiWindow, params.getMap(),
-                    false);
-        }
-    }
+			parser.proceed();
+		}
+
+		String version = null;
+		if ((page != null) && (page.contains(":"))) {
+			String[] tokens = page.split("[:]", 2);
+			if ((tokens.length == 2)) {
+				page = tokens[0];
+				version = tokens[1];
+			} else {
+				return getDefaultCommand();
+			}
+		}
+
+		PortletParametersStateString params = new PortletParametersStateString();
+		params
+				.setValue(MapperTools.JSF_VIEW_ID_PARAM,
+						"/views/wiki_view.xhtml");
+		if (page != null)
+			params.setValue("page", page);
+		if (language != null) {
+			params.setValue("language", language);
+		}
+		if (version != null) {
+			params.setValue("version", version);
+		}
+
+		Window wikiWindow = (Window) getContainer().getObject(windowId);
+		if (hasMetaParameter(invocation)) {
+			return getPortalObjectCF().doMapping(invocation, wikiWindow,
+					params.getMap(), false);
+		} else {
+			params.setValue(PortletRequestDecoder.META_PARAMETER, Integer
+					.toString(PortletRequestDecoder.RENDER_MASK));
+			return getPortalObjectCF().doMapping(invocation, wikiWindow,
+					params.getMap(), false);
+		}
+	}
 }

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -150,6 +150,8 @@
 
 			String requestURI = URLDecoder.decode(httpRequest.getRequestURI(),
 					"UTF-8");
+			
+			log.info("RequestURI: "+requestURI);
 
 			// get off "/wiki/" from the begining
 			requestURI = requestURI.substring((httpRequest.getContextPath() + "/").length());
@@ -338,6 +340,9 @@
 				WikiAttachment wikiAttachment;
 
 				if (version == -1) {
+					
+					log.info("Page: " + pageName+" File: "+fileName+" LangCode: "+langCode);
+					
 					wikiAttachment = wikiEngine.getAttachment(pageName,
 							fileName, langCode);
 				} else {

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/RequestInvocationHandler.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/RequestInvocationHandler.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/RequestInvocationHandler.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -24,6 +24,7 @@
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.util.Enumeration;
 import java.util.Map;
 
 import javax.portlet.ActionRequest;
@@ -38,10 +39,33 @@
 
 	private ActionRequest request;
 
-	private Map<String, String> paramMap;
+	private Map paramMap;
 
-	public RequestInvocationHandler(ActionRequest request,
-			Map<String, String> paramMap) {
+	private MapHandler mapHandler = new MapHandler();
+
+	class MapHandler {
+		public String getParameter(String name) {
+			if (name == null) {
+				return null;
+			}
+			String[] value = (String[]) paramMap.get(name);
+			return value == null ? null : value[0];
+		}
+
+		public Map getParameterMap() {
+			return paramMap;
+		}
+
+		public Enumeration getParameterNames() {
+			return new MyEnumeration(paramMap.keySet());
+		}
+
+		public String[] getParameterValues(String name) {
+			return (String[]) paramMap.get(name);
+		}
+	}
+
+	public RequestInvocationHandler(ActionRequest request, Map paramMap) {
 		this.request = request;
 		this.paramMap = paramMap;
 	}
@@ -49,28 +73,16 @@
 	public Object invoke(Object proxy, Method method, Object[] args)
 			throws Throwable {
 
-		Class c = paramMap.getClass();
+		if (method.getName().equals("getParameter")
+				|| method.getName().equals("getParameterMap")
+				|| method.getName().equals("getParameterNames()")
+				|| method.getName().equals("getParameterValues")) {
 
-		if (method.getName().equals("getParameter")) {
-
-			Method m = c.getMethod("get", new Class[] { Object.class });
-			return m.invoke(paramMap, args);
-		} else if (method.getName().equals("getParameterMap")) {
-			Method m = RequestInvocationHandler.class.getMethod("getParamMap",
-					new Class[] {});
-			return m.invoke(this, args);
-		} else if (method.getName().equals("getParameterNames()")) {
-			Method m = c.getMethod("keySet", new Class[] {});
-			return m.invoke(paramMap, args);
-		} else if (method.getName().equals("getParameterValues")) {
-			Method m = c.getMethod("values", new Class[] {});
-			return m.invoke(paramMap, args);
+			Method m = MapHandler.class.getMethod(method.getName(), new Class[] { Object.class });
+			
+			return m.invoke(mapHandler, args);
 		} else {
 			return method.invoke(request, args);
 		}
 	}
-
-	public Map<String, String> getParamMap() {
-		return paramMap;
-	}
 }

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/WikiPortletMyFaces.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/WikiPortletMyFaces.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/portlet/WikiPortletMyFaces.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -24,6 +24,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -112,6 +114,17 @@
 
 			request = new MultipartRequestWrapper(request, paramMap);
 
+			// request proxy unusable here, as we need to access specifics for
+			// Requests later
+			/*
+			 * InvocationHandler handler = new RequestInvocationHandler(request,
+			 * paramMap);
+			 * 
+			 * request = (ActionRequest)
+			 * Proxy.newProxyInstance(ActionRequest.class.getClassLoader(), new
+			 * Class[] { ActionRequest.class }, handler);
+			 */
+
 		} else {
 			this.prepareParams(request, response);
 		}
@@ -119,8 +132,9 @@
 		FacesContext facesContext = facesContext(request, response);
 
 		try {
+			log.info("before exec");
 			lifecycle.execute(facesContext);
-
+			log.info("after exec");
 			if (!facesContext.getResponseComplete()) {
 				response.setRenderParameter(VIEW_ID, facesContext.getViewRoot()
 						.getViewId());

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiEdit.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiEdit.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiEdit.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -25,6 +25,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.util.Date;
 import java.util.List;
 import java.util.Set;
 import java.util.Vector;
@@ -61,9 +62,21 @@
 
 	private File newFile;
 
+	private String lockMsg;
+
 	public WikiEdit() {
 		attributesExtractor = WikiHelper.getAttributesExtractor(WikiHelper
 				.getRequest(), WikiHelper.getResponse());
+
+		editSessionId = WikiHelper.getWikiEngine().getEditSessionId();
+		Date lock = getWikiPage().lock(attributesExtractor.getCredentials(),
+				editSessionId);
+
+		if (lock != null) {
+
+		} else {
+			lockMsg = "";
+		}
 	}
 
 	public String getPageContent() {
@@ -93,6 +106,10 @@
 					editSessionId,
 					WikiHelper.getWikiCommonSession().getLangCode(),
 					attributesExtractor.getWikiSession(), pageContent);
+
+			getWikiPage().unlock(attributesExtractor.getCredentials(),
+					editSessionId);
+
 		} catch (EditSessionExpired e) {
 			log.error(e);
 			return "error";
@@ -108,12 +125,6 @@
 	}
 
 	public String getEditSessionId() {
-		if (editSessionId == null) {
-			editSessionId = WikiHelper.getWikiEngine().getEditSessionId();
-			getWikiPage().lock(attributesExtractor.getCredentials(),
-					editSessionId);
-		}
-
 		return editSessionId.toString();
 	}
 
@@ -139,8 +150,7 @@
 			newFile = WikiHelper.getFile();
 			if (attName.equals(WikiHelper.getMessage("new_att"))) {
 				fileName = WikiHelper.getFileName();
-			}
-			else {
+			} else {
 				fileName = attName;
 			}
 		}
@@ -174,9 +184,10 @@
 
 		List<SelectItem> attNames = new Vector<SelectItem>();
 
-		for (String att : attSet) {
-			attNames.add(new SelectItem(att, att));
-		}
+		if (attSet != null)
+			for (String att : attSet) {
+				attNames.add(new SelectItem(att, att));
+			}
 
 		attNames.add(0, new SelectItem(WikiHelper.getMessage("new_att"),
 				WikiHelper.getMessage("new_att")));
@@ -191,4 +202,15 @@
 	public void setAttName(String attName) {
 		this.attName = attName;
 	}
+
+	public String cancel() {
+		getWikiPage().unlock(attributesExtractor.getCredentials(),
+				editSessionId);
+
+		return "goback";
+	}
+
+	public String getLockMsg() {
+		return lockMsg;
+	}
 }

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiView.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiView.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/ui/WikiView.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -55,7 +55,7 @@
 	private AttributesExtractor attrExtractor;
 
 	private WikiPage currentPage;
-	
+
 	private String searchQuery;
 
 	public WikiView() {
@@ -63,7 +63,7 @@
 				.getRequest(), WikiHelper.getResponse());
 
 		WikiHelper.getWikiCommonSession().update(attrExtractor);
-		
+
 		getCurrentPage();
 	}
 
@@ -88,14 +88,25 @@
 	}
 
 	public String getWikiFriendlyURL() {
-		return attrExtractor.getHostURL() + attrExtractor.getAppContext() + "/"
-				+ WikiHelper.getWikiCommonSession().getPageName();
+		return attrExtractor.getHostURL()
+				+ attrExtractor.getAppContext()
+				+ "/"
+				+ ((!WikiHelper.getWikiCommonSession().getLangCode().equals(
+						ConfigurationParser.getDefaultLangugeCode())) ? WikiHelper
+						.getWikiCommonSession().getLangCode().toLowerCase()
+						+ "/"
+						: "") + WikiHelper.getWikiCommonSession().getPageName();
 	}
 
 	public String getWikiMainPageURL() {
-		return attrExtractor.getHostURL() + attrExtractor.getAppContext() + "/"
-				+ WikiHelper.getWikiCommonSession().getLangCode() + "/"
-				+ ConfigurationParser.getDefaultPage();
+		return attrExtractor.getHostURL()
+				+ attrExtractor.getAppContext()
+				+ "/"
+				+ ((!WikiHelper.getWikiCommonSession().getLangCode().equals(
+						ConfigurationParser.getDefaultLangugeCode())) ? WikiHelper
+						.getWikiCommonSession().getLangCode().toLowerCase()
+						+ "/"
+						: "") + ConfigurationParser.getDefaultPage();
 	}
 
 	public String getPageName() {
@@ -143,8 +154,8 @@
 
 		}
 
-		log.info("page loaded: "+currentPage.getName());
-		
+		log.info("page loaded: " + currentPage.getName());
+
 		return currentPage;
 	}
 
@@ -157,7 +168,7 @@
 					.getExternalContext().getRequestParameterMap().get(
 							TYPE_PARAM);
 		}
-		
+
 		if (attrExtractor.getWikiSession().getAttribute(FIND_ATTRIBUTE) != null) {
 			type = "find";
 		}
@@ -193,19 +204,18 @@
 		return false;
 	}
 
-	
 	public String search() {
-		
+
 		Map<String, Integer> pages = WikiHelper.getWikiEngine().findPages(
 				searchQuery, WikiHelper.getWikiCommonSession().getLangCode());
 
 		WikiHelper.getWikiCommonSession().setSearchResults(pages);
-		
+
 		attrExtractor.getWikiSession().setAttribute(FIND_ATTRIBUTE, pages);
 
 		// show the results
-		//rResp.setRenderParameter("page", "FindResult");
-		
+		// rResp.setRenderParameter("page", "FindResult");
+
 		return "";
 	}
 

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/web/views/wiki_edit.xhtml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/web/views/wiki_edit.xhtml	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/forge-wiki/src/web/views/wiki_edit.xhtml	2007-02-26 22:57:00 UTC (rev 9772)
@@ -11,7 +11,7 @@
     			<h:inputTextarea rows="40" cols="80" value="#{wikiEdit.pageContent}" styleClass="editPageArea" acceptcharset="UTF-8" />
 				<h:panelGroup>
 					<h:commandButton value="#{msg.edit_save}" action="#{wikiEdit.save}" />
-					<h:commandButton value="#{msg.edit_cancel}" action="goback" />
+					<h:commandButton value="#{msg.edit_cancel}" action="#{wikiEdit.cancel}" />
 				</h:panelGroup>
 			</h:panelGrid>
 			<h:inputHidden value="#{wikiEdit.editSessionId}" />

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties	2007-02-26 22:57:00 UTC (rev 9772)
@@ -1,6 +1,6 @@
 #JBoss Wiki properties file
 #
-#(C) 2005 by JBoss Labs Team
+#(C) 2005-2007 by JBoss Labs Team
 
 #sessionIdExpireTime (in minutes) - time after edit session expires
 sessionIdExpireTime=120
@@ -28,3 +28,6 @@
 
 #default wikicontext - if you wanna use application context instead - just delete this property
 wikiContext=/wiki
+
+#number of minutes after which page lock will expire
+lockTime=30
\ No newline at end of file

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/com/ecyrd/jspwiki/plugin/ImagePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/com/ecyrd/jspwiki/plugin/ImagePlugin.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/com/ecyrd/jspwiki/plugin/ImagePlugin.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -12,30 +12,46 @@
 	@Override
 	public String process(WikiPage wikiPage, WikiSession wikiSession,
 			HashMap<String, String> attributes) {
-	/*
-    * src = Image source. This can either be a full URL (http://...) or a WikiAttachment? name. Required.
-    * align = left|right|center. The image alignment.
-    * height = integer. Force the height of the image.
-    * width = integer. Force the width of the image.
-    * alt = alt text. The alt text of an image. This is very useful when doing 
-    * pages that can be navigated with text-only browsers
-    * caption = caption text. The text that should be shown as a caption under the image.
-    * link = hyperlink. A hyperlink (http://...). In the future, you can also use WikiPages?.
-    * border = integer. Size of the image border.
-    * style = style info. Any style markup you would like to apply to the table surrounding the image.
-    * class = class name. Redefine the default class for this image, which is "imageplugin".
-    */
-		
+		/*
+		 * src = Image source. This can either be a full URL (http://...) or a
+		 * WikiAttachment? name. Required. align = left|right|center. The image
+		 * alignment. height = integer. Force the height of the image. width =
+		 * integer. Force the width of the image. alt = alt text. The alt text
+		 * of an image. This is very useful when doing pages that can be
+		 * navigated with text-only browsers caption = caption text. The text
+		 * that should be shown as a caption under the image. link = hyperlink.
+		 * A hyperlink (http://...). In the future, you can also use WikiPages?.
+		 * border = integer. Size of the image border. style = style info. Any
+		 * style markup you would like to apply to the table surrounding the
+		 * image. class = class name. Redefine the default class for this image,
+		 * which is "imageplugin".
+		 */
+
 		String src = attributes.get("src");
-		
+
 		if (src == null) {
 			return "<i>Image Plugin Error: \"src\" value has to be set !</i>";
 		}
-		
+
 		if (!HTMLTranslatorParts.isExternalLink(src)) {
-			src = wikiSession.getAttribute("hostURL") + "/wiki/" + src;
+			src = wikiSession.getAttribute("hostURL") + "/wiki/"
+					+ wikiPage.getLangCode().toLowerCase() + "/" + src;
+			String[] tokens = src.split("/");
+			String imgName = tokens[tokens.length - 1];
+
+			if (HTMLTranslatorParts.checkImageLink(imgName)
+					&& !imgName.startsWith("file:")) {
+				String newSrc = tokens[0];
+				tokens[tokens.length - 1] = wikiPage.getName() + "/" + "file:" + imgName;
+
+				for (int i = 1; i < tokens.length; i++) {
+					newSrc += "/" + tokens[i];
+				}
+
+				src = newSrc;
+			}
 		}
-		
+
 		String align = attributes.get("align");
 		String height = attributes.get("height");
 		String width = attributes.get("width");
@@ -45,25 +61,32 @@
 		String border = attributes.get("border");
 		String style = attributes.get("style");
 		String classAtr = attributes.get("class");
-		
+
 		StringBuffer imageLink = new StringBuffer();
-		
-		imageLink.append((caption != null) ? "<table><tr><td>" : "")
-				 .append((link != null) ? "<a href=\""+link+"\">" : "")
-				 .append("<img ")
-				 .append("src=\"")
-				 .append(src)
-				 .append("\" ")
-				 .append((align != null) ? "align"+align+"\" " : "")
-				 .append((height != null) ? "height=\""+height+"\" " : "")
-				 .append((width != null) ? "width=\""+width+"\" " : "")
-				 .append((alt != null) ? "alt=\""+alt+"\" " : "")
-				 .append((border != null) ? "border=\""+border+"\" " : "")
-				 .append((style != null) ? "style=\""+style+"\" " : "")
-				 .append("class=\""+((classAtr != null) ? classAtr : "imageplugin") + "\" ")
-				 .append((link != null) ? "</a>" : "")
-				 .append((caption != null) ? "</td></tr><tr><td style=\"text-align: center\">"+caption+"</td></tr></table>" : "");
-		
+
+		imageLink
+				.append((caption != null) ? "<table><tr><td>" : "")
+				.append((link != null) ? "<a href=\"" + link + "\">" : "")
+				.append("<img ")
+				.append("src=\"")
+				.append(src)
+				.append("\" ")
+				.append((align != null) ? "align" + align + "\" " : "")
+				.append((height != null) ? "height=\"" + height + "\" " : "")
+				.append((width != null) ? "width=\"" + width + "\" " : "")
+				.append((alt != null) ? "alt=\"" + alt + "\" " : "")
+				.append((border != null) ? "border=\"" + border + "\" " : "")
+				.append((style != null) ? "style=\"" + style + "\" " : "")
+				.append(
+						"class=\""
+								+ ((classAtr != null) ? classAtr
+										: "imageplugin") + "\" ")
+				.append((link != null) ? "</a>" : "")
+				.append(
+						(caption != null) ? "</td></tr><tr><td style=\"text-align: center\">"
+								+ caption + "</td></tr></table>"
+								: "");
+
 		return imageLink.toString();
 	}
 

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -33,6 +33,7 @@
 
 import org.jboss.logging.Logger;
 
+import org.jboss.wiki.configuration.ConfigurationParser;
 import org.jboss.wiki.exceptions.DataSourceException;
 import org.jboss.wiki.exceptions.EditSessionExpired;
 import org.jboss.wiki.exceptions.EditingNotAllowedException;
@@ -63,9 +64,6 @@
 	 */
 	private static final long serialVersionUID = 1L;
 
-	/* number of minutes after which page lock will expire */
-	private static final int LOCK_TIME = 30;
-
 	private Date lockTime = null;
 
 	private String lockUser;
@@ -301,7 +299,7 @@
 
 			Calendar calExpireDate = Calendar.getInstance();
 			calExpireDate.setTime(this.lockTime);
-			calExpireDate.add(Calendar.MINUTE, LOCK_TIME);
+			calExpireDate.add(Calendar.MINUTE, ConfigurationParser.getLockTime());
 			expDate = calExpireDate.getTime();
 
 			if (expDate.before(now)) {

Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/configuration/ConfigurationParser.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/configuration/ConfigurationParser.java	2007-02-26 21:09:58 UTC (rev 9771)
+++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/configuration/ConfigurationParser.java	2007-02-26 22:57:00 UTC (rev 9772)
@@ -41,6 +41,8 @@
 	private static final String PROPERTIES_FILENAME = "JBossWiki.properties";
 
 	private static final String DEFAULT_LANGUAGE_PROP = "defaultLanguageCode";
+	
+	private static final String LOCK_TIME_PROP = "lockTime";
 
 	private static String defaultLangugeCode = "EN";
 
@@ -56,6 +58,9 @@
 
 	private static Class credentialsClass;
 	
+	/* number of minutes after which page lock will expire */
+	private static int lockTime = 30;
+	
 	private static final Logger log = Logger.getLogger(ConfigurationParser.class);
 
 	static {
@@ -120,6 +125,12 @@
 		}
 		
 		log.info("CredentialsClass: " + credentialsClass);
+		
+		if (jbosswikiprops.getProperty(LOCK_TIME_PROP) != null) {
+			lockTime = Integer.parseInt(jbosswikiprops
+					.getProperty(LOCK_TIME_PROP));
+		}
+		log.info("Lock time: " + lockTime);
 	}
 
 	public static String getDefaultLangugeCode() {
@@ -154,4 +165,8 @@
 		return credentialsClass;
 	}
 
+	public static int getLockTime() {
+		return lockTime;
+	}
+
 }




More information about the jboss-svn-commits mailing list