Skip to content
Snippets Groups Projects
Commit c3cf531e authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

Update code to work with master branch.

parent a2cc52be
No related merge requests found
Showing
with 103 additions and 160 deletions
Follow this steps to integrate the Alfresco plugin on XE 2.7.2:
Follow this steps to integrate the Alfresco plugin on XE:
1. Copy the following jars to WEB-INF/lib
http://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpclient/4.0.2/httpclient-4.0.2.jar (new)
xwiki-platform-wysiwyg-client-x.y-SNAPSHOT-shared.jar (overwrite existing jar)
http://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar (new)
xwiki-platform-wysiwyg-server-x.y-SNAPSHOT.jar (overwrite existing jar)
http://maven.xwiki.org/externals/com/google/gwt/gwt-servlet/2.3.0-xwiki-20110506/gwt-servlet-2.3.0-xwiki-20110506.jar (remove existing jar gwt-servlet-2.0.4.jar)
xwiki-platform-wysiwyg-client-3.2-SNAPSHOT-shared.jar (remove existing jar xwiki-web-gwt-wysiwyg-client-2.7.2-shared.jar)
xwiki-web-gwt-wysiwyg-server-2.7.2.jar (overwrite existing jar)
xwiki-platform-wysiwyg-plugin-alfresco-server-3.2-SNAPSHOT.jar (new)
xwiki-platform-wysiwyg-plugin-alfresco-server-x.y-SNAPSHOT.jar (new)
2. Update resources/js/xwiki/wysiwyg/xwe directory (delete the existing folder and copy the new one from the zip; don't overwrite!)
3. Enable Alfresco WYSIWYG editor plugin. Edit templates/macros.vm and replace this line:
#set($ok = $parameters.put('plugins', $xwiki.getXWikiPreference('wysiwyg.plugins', "submit line separator embed text valign list indent history format symbol link image table macro import#if($full && $request.sync) sync#end")
))
with:
#set($ok = $parameters.put('plugins', $xwiki.getXWikiPreference('wysiwyg.plugins', "submit line separator embed text valign list indent history format symbol link image table macro import alfresco")))
4. Add Alfresco menu entries. Edit templates/macros.vm and replace this line:
#set($ok = $parameters.put('menu', $xwiki.getXWikiPreference('wysiwyg.menu', 'link image table macro import')))
3. Enable "alfresco" WYSIWYG editor plugin from the administration section (don't forget to save the administration section!).
with:
4. Add Alfresco menu entries. For this you have to edit XWiki.WysiwygEditorConfig page in object mode and set the value of the menu property to:
#set($ok = $parameters.put('menu', $xwiki.getXWikiPreference('wysiwyg.menu', '[{"feature": "link", "subMenu":["linkEdit", "linkRemove", "linkWikiPage", "linkAttachment", "|", "linkWebPage", "linkEmail", "alfrescoLink"]}, {"fe
ature":"image", "subMenu":["imageInsertAttached", "imageInsertURL", "imageEdit", "alfrescoImage", "imageRemove"]}, {"feature":"table", "subMenu":["inserttable", "insertcolbefore", "insertcolafter", "deletecol", "|", "insertro
wbefore", "insertrowafter", "deleterow", "|", "deletetable"]}, {"feature":"macro", "subMenu":["macroInsert", "macroEdit", "|", "macroRefresh", "|", "macroCollapse", "macroExpand"]}, {"feature":"import", "subMenu":["importOffi
ce"]}]')))
[{"feature": "link", "subMenu":["linkEdit", "linkRemove", "linkWikiPage", "linkAttachment", "|", "linkWebPage", "linkEmail", "alfrescoLink"]}, {"feature":"image", "subMenu":["imageInsertAttached", "imageInsertURL", "imageEdit", "alfrescoImage", "imageRemove"]}, {"feature":"table", "subMenu":["inserttable", "insertcolbefore", "insertcolafter", "deletecol", "|", "insertrowbefore", "insertrowafter", "deleterow", "|", "deletetable"]}, {"feature":"macro", "subMenu":["macroInsert", "macroEdit", "|", "macroRefresh", "|", "macroCollapse", "macroExpand"]}, {"feature":"import", "subMenu":["importOffice"]}]
5. Edit xwiki.properties and add the following configuration properties:
......
......@@ -36,6 +36,7 @@
<modules>
<module>xwiki-platform-wysiwyg-client</module>
<module>xwiki-platform-wysiwyg-plugin-api</module>
<module>xwiki-platform-wysiwyg-plugin-alfresco-server</module>
<module>xwiki-platform-wysiwyg-server</module>
<module>xwiki-platform-wysiwyg-war</module>
</modules>
......
......@@ -26,13 +26,23 @@
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-wysiwyg</artifactId>
<version>3.2-SNAPSHOT</version>
<version>3.5-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-wysiwyg-plugin-alfresco-server</artifactId>
<name>XWiki Platform - WYSIWYG Editor - Plugins - Alfresco - Server Side</name>
<packaging>jar</packaging>
<description>The service used to fetch data from an Alfresco server.</description>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<!-- GWT core dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>provided</scope>
</dependency>
<!-- GWT libraries -->
<dependency>
<groupId>org.xwiki.platform</groupId>
......@@ -68,7 +78,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -21,9 +21,10 @@
import java.io.IOException;
import javax.inject.Inject;
import org.apache.http.client.methods.HttpRequestBase;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.component.manager.ComponentLookupException;
import org.xwiki.component.manager.ComponentManager;
import org.xwiki.wysiwyg.plugin.alfresco.server.AlfrescoConfiguration;
......@@ -40,20 +41,15 @@ public class AuthSimpleHttpClient extends NoAuthSimpleHttpClient
/**
* The component used to get the authenticator hint.
*/
@Requirement
@Inject
private AlfrescoConfiguration configuration;
/**
* The component used to lookup the authenticator.
*/
@Requirement
@Inject
private ComponentManager componentManager;
/**
* {@inheritDoc}
*
* @see NoAuthSimpleHttpClient#sendRequest(HttpRequestBase, ResponseHandler)
*/
@Override
protected <T> T sendRequest(HttpRequestBase request, ResponseHandler<T> handler) throws IOException
{
......
......@@ -19,11 +19,13 @@
*/
package org.xwiki.wysiwyg.internal.plugin.alfresco.server;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.auth.BasicScheme;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.wysiwyg.plugin.alfresco.server.AlfrescoConfiguration;
import org.xwiki.wysiwyg.plugin.alfresco.server.Authenticator;
......@@ -32,20 +34,17 @@
*
* @version $Id$
*/
@Component("basic")
@Component
@Named("basic")
public class BasicAuthenticator implements Authenticator
{
/**
* The component that specifies the user name and password.
*/
@Requirement
@Inject
private AlfrescoConfiguration configuration;
/**
* {@inheritDoc}
*
* @see Authenticator#authenticate(HttpRequestBase)
*/
@Override
public void authenticate(HttpRequestBase request)
{
UsernamePasswordCredentials credentials =
......
......@@ -19,8 +19,10 @@
*/
package org.xwiki.wysiwyg.internal.plugin.alfresco.server;
import javax.inject.Inject;
import javax.inject.Named;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.configuration.ConfigurationSource;
import org.xwiki.wysiwyg.plugin.alfresco.server.AlfrescoConfiguration;
......@@ -35,44 +37,29 @@ public class DefaultAlfrescoConfiguration implements AlfrescoConfiguration
/**
* The configuration source.
*/
@Requirement("all")
@Inject
@Named("all")
private ConfigurationSource configurationSource;
/**
* {@inheritDoc}
*
* @see AlfrescoConfiguration#getServerURL()
*/
@Override
public String getServerURL()
{
return configurationSource.getProperty("alfresco.serverURL", "http://localhost:8080");
}
/**
* {@inheritDoc}
*
* @see AlfrescoConfiguration#getUserName()
*/
@Override
public String getUserName()
{
return configurationSource.getProperty("alfresco.username", "Admin");
}
/**
* {@inheritDoc}
*
* @see AlfrescoConfiguration#getPassword()
*/
@Override
public String getPassword()
{
return configurationSource.getProperty("alfresco.password", "admin");
}
/**
* {@inheritDoc}
*
* @see AlfrescoConfiguration#getDefaultNodeReference()
*/
@Override
public String getDefaultNodeReference()
{
return configurationSource.getProperty("alfresco.defaultNodeRef",
......
......@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
......@@ -35,7 +36,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.gwt.wysiwyg.client.plugin.alfresco.AlfrescoEntity;
import org.xwiki.gwt.wysiwyg.client.wiki.URIReference;
import org.xwiki.wysiwyg.plugin.alfresco.server.AlfrescoConfiguration;
......@@ -64,26 +64,22 @@ public class DefaultAlfrescoResponseParser implements AlfrescoResponseParser
/**
* The object used to parse node references.
*/
@Requirement
@Inject
private NodeReferenceParser nodeReferenceParser;
/**
* The component used to get the Alfresco server URL.
*/
@Requirement
@Inject
private AlfrescoConfiguration configuration;
/**
* The component used to resolve XML entities.
*/
@Requirement
@Inject
private EntityResolver entityResolver;
/**
* {@inheritDoc}
*
* @see AlfrescoResponseParser#parseAuthTicket(InputStream)
*/
@Override
public String parseAuthTicket(InputStream json)
{
try {
......@@ -94,11 +90,7 @@ public String parseAuthTicket(InputStream json)
}
}
/**
* {@inheritDoc}
*
* @see AlfrescoResponseParser#parseParent(InputStream)
*/
@Override
public AlfrescoEntity parseParent(InputStream xml)
{
NodeList cmisPropertiesElements = parseXML(xml).getElementsByTagName(CMIS_PROPERTIES_TAG);
......@@ -151,11 +143,7 @@ private AlfrescoEntity createEntity(Node cmisProperties)
return entity;
}
/**
* {@inheritDoc}
*
* @see AlfrescoResponseParser#parseChildren(InputStream)
*/
@Override
public List<AlfrescoEntity> parseChildren(InputStream xml)
{
List<AlfrescoEntity> children = new ArrayList<AlfrescoEntity>();
......
......@@ -26,8 +26,10 @@
import java.util.List;
import java.util.Map.Entry;
import javax.inject.Inject;
import javax.inject.Named;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.gwt.wysiwyg.client.plugin.alfresco.AlfrescoEntity;
import org.xwiki.gwt.wysiwyg.client.plugin.alfresco.AlfrescoService;
import org.xwiki.gwt.wysiwyg.client.wiki.EntityReference;
......@@ -60,38 +62,35 @@ public class DefaultAlfrescoService implements AlfrescoService
/**
* The component that controls the Alfresco access configuration.
*/
@Requirement
@Inject
private AlfrescoConfiguration configuration;
/**
* The object used to parse the responses received for Alfresco REST requests.
*/
@Requirement
@Inject
private AlfrescoResponseParser responseParser;
/**
* The HTTP client used to make REST requests to Alfresco.
*/
@Requirement
@Inject
private SimpleHttpClient httpClient;
/**
* The object used to parse node references.
*/
@Requirement
@Inject
private NodeReferenceParser nodeReferenceParser;
/**
* The object used to extract the node reference out of an Alfresco URL.
*/
@Requirement("url")
@Inject
@Named("url")
private NodeReferenceParser urlNodeReferenceParser;
/**
* {@inheritDoc}
*
* @see AlfrescoService#getChildren(EntityReference)
*/
@Override
public List<AlfrescoEntity> getChildren(final EntityReference parentReference)
{
String parentPath = createNodeReference(parentReference).asPath();
......@@ -113,11 +112,7 @@ public List<AlfrescoEntity> read(InputStream content)
}
}
/**
* {@inheritDoc}
*
* @see AlfrescoService#getParent(EntityReference)
*/
@Override
public AlfrescoEntity getParent(final EntityReference childReference)
{
String childPath = createNodeReference(childReference).asPath();
......
......@@ -21,7 +21,7 @@
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.xwiki.component.annotation.Component;
import org.xwiki.wysiwyg.plugin.alfresco.server.NodeReference;
import org.xwiki.wysiwyg.plugin.alfresco.server.NodeReferenceParser;
......@@ -42,11 +42,7 @@ public class DefaultNodeReferenceParser implements NodeReferenceParser
*/
private static final Pattern SEPARATOR = Pattern.compile("(?:\\:\\/)?\\/");
/**
* {@inheritDoc}
*
* @see NodeReferenceParser#parse(String)
*/
@Override
public NodeReference parse(String serializedReference)
{
if (StringUtils.isEmpty(serializedReference)) {
......
......@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Map.Entry;
import javax.inject.Named;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
......@@ -50,7 +52,8 @@
*
* @version $Id$
*/
@Component("noauth")
@Component
@Named("noauth")
public class NoAuthSimpleHttpClient implements SimpleHttpClient
{
/**
......@@ -58,11 +61,7 @@ public class NoAuthSimpleHttpClient implements SimpleHttpClient
*/
private HttpClient httpClient;
/**
* {@inheritDoc}
*
* @see SimpleHttpClient#doGet(String, List, ResponseHandler)
*/
@Override
public <T> T doGet(String url, List<Entry<String, String>> queryStringParameters, ResponseHandler<T> handler)
throws IOException
{
......@@ -73,11 +72,7 @@ public <T> T doGet(String url, List<Entry<String, String>> queryStringParameters
return sendRequest(new HttpGet(url + '?' + URLEncodedUtils.format(parameters, "UTF-8")), handler);
}
/**
* {@inheritDoc}
*
* @see SimpleHttpClient#doPost(String, String, String, ResponseHandler)
*/
@Override
public <T> T doPost(String url, String content, String contentType, ResponseHandler<T> handler) throws IOException
{
HttpPost request = new HttpPost(url);
......
......@@ -23,6 +23,9 @@
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.http.Header;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.cookie.ClientCookie;
......@@ -30,7 +33,6 @@
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.impl.cookie.BrowserCompatSpec;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.container.Container;
import org.xwiki.container.servlet.ServletRequest;
import org.xwiki.wysiwyg.plugin.alfresco.server.Authenticator;
......@@ -40,7 +42,8 @@
*
* @version $Id$
*/
@Component("siteMinder")
@Component
@Named("siteMinder")
public class SiteMinderAuthenticator implements Authenticator
{
/**
......@@ -51,14 +54,10 @@ public class SiteMinderAuthenticator implements Authenticator
/**
* The component used to access the current HTTP request, from where we copy the SMSESSION cookie.
*/
@Requirement
@Inject
private Container container;
/**
* {@inheritDoc}
*
* @see Authenticator#authenticate(HttpRequestBase)
*/
@Override
public void authenticate(HttpRequestBase request)
{
List<Cookie> cookies = getSiteMinderCookies();
......
......@@ -24,6 +24,8 @@
import java.net.URISyntaxException;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpSession;
import org.apache.http.NameValuePair;
......@@ -33,7 +35,6 @@
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.container.Container;
import org.xwiki.container.servlet.ServletRequest;
import org.xwiki.gwt.wysiwyg.client.plugin.alfresco.AlfrescoService;
......@@ -48,7 +49,8 @@
*
* @version $Id$
*/
@Component("ticket")
@Component
@Named("ticket")
public class TicketAuthenticator implements Authenticator
{
/**
......@@ -70,32 +72,29 @@ public class TicketAuthenticator implements Authenticator
/**
* The component used to access the HTTP session to store the authentication ticket.
*/
@Requirement
@Inject
private Container container;
/**
* The component that controls the Alfresco access configuration.
*/
@Requirement
@Inject
private AlfrescoConfiguration configuration;
/**
* The component used to request the authentication ticket.
*/
@Requirement("noauth")
@Inject
@Named("noauth")
private SimpleHttpClient httpClient;
/**
* The component used to parse the ticket response.
*/
@Requirement
@Inject
private AlfrescoResponseParser responseParser;
/**
* {@inheritDoc}
*
* @see Authenticator#authenticate(HttpRequestBase)
*/
@Override
public void authenticate(HttpRequestBase request)
{
HttpSession session = ((ServletRequest) container.getRequest()).getHttpServletRequest().getSession();
......
......@@ -24,10 +24,12 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.wysiwyg.plugin.alfresco.server.NodeReference;
import org.xwiki.wysiwyg.plugin.alfresco.server.NodeReferenceParser;
import org.xwiki.wysiwyg.plugin.alfresco.server.StoreReference;
......@@ -37,7 +39,8 @@
*
* @version $Id$
*/
@Component("url")
@Component
@Named("url")
public class UrlNodeReferenceParser implements NodeReferenceParser
{
/**
......@@ -49,14 +52,10 @@ public class UrlNodeReferenceParser implements NodeReferenceParser
/**
* The object used to parse node references.
*/
@Requirement
@Inject
private NodeReferenceParser nodeReferenceParser;
/**
* {@inheritDoc}
*
* @see NodeReferenceParser#parse(String)
*/
@Override
public NodeReference parse(String url)
{
String nodeReference = null;
......
......@@ -39,7 +39,7 @@ public interface SimpleHttpClient
*
* @param <T> the type of object read from the response content
*/
static interface ResponseHandler<T>
interface ResponseHandler<T>
{
/**
* Read the response content stream.
......
......@@ -23,8 +23,10 @@
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.gwt.wysiwyg.client.plugin.alfresco.AlfrescoEntity;
import org.xwiki.gwt.wysiwyg.client.plugin.alfresco.AlfrescoService;
import org.xwiki.gwt.wysiwyg.client.wiki.Attachment;
......@@ -42,13 +44,14 @@
*
* @version $Id$
*/
@Component()
@Component
@Singleton
public class XWikiAlfrescoService implements AlfrescoService
{
/**
* The component used to access the wiki.
*/
@Requirement
@Inject
private WikiService wikiService;
/**
......@@ -56,11 +59,7 @@ public class XWikiAlfrescoService implements AlfrescoService
*/
private final EntityReferenceConverter entityReferenceConverter = new EntityReferenceConverter();
/**
* {@inheritDoc}
*
* @see AlfrescoService#getChildren(EntityReference)
*/
@Override
public List<AlfrescoEntity> getChildren(EntityReference clientParentReference)
{
org.xwiki.model.reference.EntityReference parentReference =
......@@ -84,11 +83,7 @@ public List<AlfrescoEntity> getChildren(EntityReference clientParentReference)
return children;
}
/**
* {@inheritDoc}
*
* @see AlfrescoService#getParent(EntityReference)
*/
@Override
public AlfrescoEntity getParent(EntityReference clientChildReference)
{
org.xwiki.model.reference.EntityReference childReference =
......
......@@ -65,6 +65,11 @@
<artifactId>xwiki-platform-wysiwyg-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-wysiwyg-plugin-alfresco-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-wysiwyg-plugin-api</artifactId>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment