mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Coding standards and consistency sweep across new services code in remote-api project.
Covers spacing, trailing {, @since tags, tabs and copyright headers. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30216 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -95,7 +95,7 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
|
||||
protected String getOrNull(JSONObject json, String key)
|
||||
{
|
||||
if(json.containsKey(key))
|
||||
if (json.containsKey(key))
|
||||
{
|
||||
return (String)json.get(key);
|
||||
}
|
||||
@@ -112,26 +112,26 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
int pageNumber = 1;
|
||||
|
||||
String pageSizeS = req.getParameter("pageSize");
|
||||
if(pageSizeS != null)
|
||||
if (pageSizeS != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pageSize = Integer.parseInt(pageSizeS);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
|
||||
}
|
||||
}
|
||||
|
||||
String pageNumberS = req.getParameter("page");
|
||||
if(pageNumberS != null)
|
||||
if (pageNumberS != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pageNumber = Integer.parseInt(pageNumberS);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
|
||||
}
|
||||
@@ -150,14 +150,14 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
{
|
||||
// What page is this for?
|
||||
String page = req.getParameter("page");
|
||||
if(page == null && json != null)
|
||||
if (page == null && json != null)
|
||||
{
|
||||
if(json.containsKey("page"))
|
||||
if (json.containsKey("page"))
|
||||
{
|
||||
page = (String)json.get("page");
|
||||
}
|
||||
}
|
||||
if(page == null)
|
||||
if (page == null)
|
||||
{
|
||||
// Default
|
||||
page = "wiki";
|
||||
@@ -176,10 +176,9 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
"org.alfresco.wiki.page-" + event,
|
||||
site.getShortName(),
|
||||
WIKI_SERVICE_ACTIVITY_APP_NAME,
|
||||
activityJson.toString()
|
||||
);
|
||||
activityJson.toString());
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
// Warn, but carry on
|
||||
logger.warn("Error adding wiki page " + event + " to activities feed", e);
|
||||
@@ -188,7 +187,7 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
|
||||
protected Object buildPerson(String username)
|
||||
{
|
||||
if(username == null || username.length() == 0)
|
||||
if (username == null || username.length() == 0)
|
||||
{
|
||||
// Empty string needed
|
||||
return "";
|
||||
@@ -220,9 +219,9 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
res.put("modifiedBY", buildPerson(page.getModifier()));
|
||||
|
||||
// We want blank instead of null
|
||||
for(String key : res.keySet())
|
||||
for (String key : res.keySet())
|
||||
{
|
||||
if(res.get(key) == null)
|
||||
if (res.get(key) == null)
|
||||
{
|
||||
res.put(key, "");
|
||||
}
|
||||
@@ -236,7 +235,7 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
Status status, Cache cache)
|
||||
{
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
if(templateVars == null)
|
||||
if (templateVars == null)
|
||||
{
|
||||
String error = "No parameters supplied";
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
|
||||
@@ -246,22 +245,22 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
// Parse the JSON, if supplied
|
||||
JSONObject json = null;
|
||||
String contentType = req.getContentType();
|
||||
if(contentType != null && contentType.indexOf(';') != -1)
|
||||
if (contentType != null && contentType.indexOf(';') != -1)
|
||||
{
|
||||
contentType = contentType.substring(0, contentType.indexOf(';'));
|
||||
}
|
||||
if(MimetypeMap.MIMETYPE_JSON.equals(contentType))
|
||||
if (MimetypeMap.MIMETYPE_JSON.equals(contentType))
|
||||
{
|
||||
JSONParser parser = new JSONParser();
|
||||
try
|
||||
{
|
||||
json = (JSONObject)parser.parse(req.getContent().getContent());
|
||||
}
|
||||
catch(IOException io)
|
||||
catch (IOException io)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + io.getMessage());
|
||||
}
|
||||
catch(ParseException pe)
|
||||
catch (ParseException pe)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + pe.getMessage());
|
||||
}
|
||||
@@ -270,17 +269,17 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
|
||||
// Get the site short name. Try quite hard to do so...
|
||||
String siteName = templateVars.get("siteId");
|
||||
if(siteName == null)
|
||||
if (siteName == null)
|
||||
{
|
||||
siteName = req.getParameter("site");
|
||||
}
|
||||
if(siteName == null && json != null)
|
||||
if (siteName == null && json != null)
|
||||
{
|
||||
if(json.containsKey("siteid"))
|
||||
if (json.containsKey("siteid"))
|
||||
{
|
||||
siteName = (String)json.get("siteid");
|
||||
}
|
||||
else if(json.containsKey("siteId"))
|
||||
else if (json.containsKey("siteId"))
|
||||
{
|
||||
siteName = (String)json.get("siteId");
|
||||
}
|
||||
@@ -289,7 +288,7 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
siteName = (String)json.get("site");
|
||||
}
|
||||
}
|
||||
if(siteName == null)
|
||||
if (siteName == null)
|
||||
{
|
||||
String error = "No site given";
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
|
||||
@@ -297,7 +296,7 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
|
||||
// Grab the requested site
|
||||
SiteInfo site = siteService.getSite(siteName);
|
||||
if(site == null)
|
||||
if (site == null)
|
||||
{
|
||||
String error = "Could not find site: " + siteName;
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, error);
|
||||
@@ -314,5 +313,4 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
|
||||
protected abstract Map<String, Object> executeImpl(SiteInfo site,
|
||||
String pageName, WebScriptRequest req, JSONObject json,
|
||||
Status status, Cache cache);
|
||||
|
||||
}
|
||||
|
@@ -39,12 +39,13 @@ public class WikiPageDelete extends AbstractWikiWebScript
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(SiteInfo site, String pageName,
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
// Try to find the page
|
||||
WikiPageInfo page = wikiService.getWikiPage(site.getShortName(), pageName);
|
||||
if(page == null)
|
||||
if (page == null)
|
||||
{
|
||||
String message = "The Wiki Page could not be found";
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, message);
|
||||
|
@@ -49,12 +49,13 @@ public class WikiPageGet extends AbstractWikiWebScript
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(SiteInfo site, String pageName,
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
// Try to find the page
|
||||
WikiPageInfo page = wikiService.getWikiPage(site.getShortName(), pageName);
|
||||
if(page == null)
|
||||
if (page == null)
|
||||
{
|
||||
String message = "The Wiki Page could not be found";
|
||||
status.setCode(Status.STATUS_NOT_FOUND);
|
||||
@@ -63,10 +64,10 @@ public class WikiPageGet extends AbstractWikiWebScript
|
||||
|
||||
// Grab the container, used in permissions checking
|
||||
NodeRef container = siteService.getContainer(
|
||||
site.getShortName(), WikiServiceImpl.WIKI_COMPONENT
|
||||
);
|
||||
site.getShortName(), WikiServiceImpl.WIKI_COMPONENT);
|
||||
|
||||
// If there's no container yet, the site will do for permissions
|
||||
if(container == null)
|
||||
if (container == null)
|
||||
{
|
||||
container = site.getNodeRef();
|
||||
}
|
||||
@@ -83,13 +84,13 @@ public class WikiPageGet extends AbstractWikiWebScript
|
||||
// Identify all the internal page links, valid and not
|
||||
// TODO This may be a candidate for the service in future
|
||||
List<String> links = new ArrayList<String>();
|
||||
if(page.getContents() != null)
|
||||
if (page.getContents() != null)
|
||||
{
|
||||
Matcher m = LINK_PATTERN.matcher(page.getContents());
|
||||
while(m.find())
|
||||
while (m.find())
|
||||
{
|
||||
String link = m.group(1);
|
||||
if(! links.contains(link))
|
||||
if (! links.contains(link))
|
||||
{
|
||||
links.add(link);
|
||||
}
|
||||
|
@@ -49,14 +49,15 @@ public class WikiPageListGet extends AbstractWikiWebScript
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(SiteInfo site, String pageName,
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache)
|
||||
{
|
||||
// Decide on what kind of request they wanted
|
||||
String filter = req.getParameter("filter");
|
||||
|
||||
// User?
|
||||
boolean userFiltering = false;
|
||||
String user = null;
|
||||
if("user".equals(filter) || "myPages".equals(filter))
|
||||
if ("user".equals(filter) || "myPages".equals(filter))
|
||||
{
|
||||
userFiltering = true;
|
||||
user = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
@@ -67,19 +68,19 @@ public class WikiPageListGet extends AbstractWikiWebScript
|
||||
boolean dateIsCreated = true;
|
||||
Date from = null;
|
||||
Date to = null;
|
||||
if("recentlyAdded".equals(filter) ||
|
||||
"recentlyCreated".equals(filter) ||
|
||||
"recentlyModified".equals(filter))
|
||||
if ("recentlyAdded".equals(filter) ||
|
||||
"recentlyCreated".equals(filter) ||
|
||||
"recentlyModified".equals(filter))
|
||||
{
|
||||
dateFiltering = true;
|
||||
if("recentlyModified".equals(filter))
|
||||
if ("recentlyModified".equals(filter))
|
||||
{
|
||||
dateIsCreated = false;
|
||||
}
|
||||
|
||||
int days = RECENT_SEARCH_PERIOD_DAYS;
|
||||
String daysS = req.getParameter("days");
|
||||
if(daysS != null && daysS.length() > 0)
|
||||
if (daysS != null && daysS.length() > 0)
|
||||
{
|
||||
days = Integer.parseInt(daysS);
|
||||
}
|
||||
@@ -93,13 +94,13 @@ public class WikiPageListGet extends AbstractWikiWebScript
|
||||
// Get the links for the list
|
||||
PagingRequest paging = buildPagingRequest(req);
|
||||
PagingResults<WikiPageInfo> pages;
|
||||
if(userFiltering)
|
||||
if (userFiltering)
|
||||
{
|
||||
pages = wikiService.listWikiPages(site.getShortName(), user, paging);
|
||||
}
|
||||
else if(dateFiltering)
|
||||
else if (dateFiltering)
|
||||
{
|
||||
if(dateIsCreated)
|
||||
if (dateIsCreated)
|
||||
{
|
||||
pages = wikiService.listWikiPagesByCreated(site.getShortName(), from, to, paging);
|
||||
}
|
||||
@@ -128,7 +129,7 @@ public class WikiPageListGet extends AbstractWikiWebScript
|
||||
data.put("itemCount", items.size());
|
||||
|
||||
int total = items.size();
|
||||
if(pages.getTotalResultCount() != null && pages.getTotalResultCount().getFirst() != null)
|
||||
if (pages.getTotalResultCount() != null && pages.getTotalResultCount().getFirst() != null)
|
||||
{
|
||||
total = pages.getTotalResultCount().getFirst();
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public class WikiPageListGet extends AbstractWikiWebScript
|
||||
|
||||
// We need the container node for permissions checking
|
||||
NodeRef container;
|
||||
if(pages.getPage().size() > 0)
|
||||
if (pages.getPage().size() > 0)
|
||||
{
|
||||
container = pages.getPage().get(0).getContainerNodeRef();
|
||||
}
|
||||
@@ -144,10 +145,9 @@ public class WikiPageListGet extends AbstractWikiWebScript
|
||||
{
|
||||
// Find the container (if it's been created yet)
|
||||
container = siteService.getContainer(
|
||||
site.getShortName(), WikiServiceImpl.WIKI_COMPONENT
|
||||
);
|
||||
site.getShortName(), WikiServiceImpl.WIKI_COMPONENT);
|
||||
|
||||
if(container == null)
|
||||
if (container == null)
|
||||
{
|
||||
// Brand new site, no write operations on links have happened
|
||||
// Fudge it for now with the site itself, the first write call
|
||||
|
@@ -25,7 +25,6 @@ import java.util.ResourceBundle;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.wiki.WikiPageInfo;
|
||||
import org.json.JSONException;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
@@ -48,13 +47,14 @@ public class WikiPageMovePost extends AbstractWikiWebScript
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(SiteInfo site, String pageName,
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache)
|
||||
{
|
||||
final Map<String, Object> model = new HashMap<String, Object>();
|
||||
final ResourceBundle rb = getResources();
|
||||
|
||||
// Try to find the page we're renaming
|
||||
WikiPageInfo page = wikiService.getWikiPage(site.getShortName(), pageName);
|
||||
if(page == null)
|
||||
if (page == null)
|
||||
{
|
||||
String message = "The Wiki Page could not be found";
|
||||
status.setCode(Status.STATUS_NOT_FOUND);
|
||||
@@ -80,7 +80,7 @@ public class WikiPageMovePost extends AbstractWikiWebScript
|
||||
page.setTitle(newTitle);
|
||||
page = wikiService.updateWikiPage(page);
|
||||
}
|
||||
catch(FileExistsException e)
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_CONFLICT, "Duplicate page name");
|
||||
}
|
||||
|
@@ -55,7 +55,8 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(SiteInfo site, String pageName,
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
// Grab the details of the change
|
||||
@@ -64,7 +65,7 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
|
||||
// Fetch the title, used only when creating
|
||||
String title;
|
||||
if(json.containsKey("title"))
|
||||
if (json.containsKey("title"))
|
||||
{
|
||||
title = (String)json.get("title");
|
||||
}
|
||||
@@ -76,17 +77,17 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
// Fetch the versioning details
|
||||
boolean forceSave = json.containsKey("forceSave");
|
||||
String currentVersion = null;
|
||||
if(json.containsKey("currentVersion"))
|
||||
if (json.containsKey("currentVersion"))
|
||||
{
|
||||
currentVersion = (String)json.get("currentVersion");
|
||||
}
|
||||
|
||||
// Fetch the tags, if given
|
||||
List<String> tags = null;
|
||||
if(json.containsKey("tags"))
|
||||
if (json.containsKey("tags"))
|
||||
{
|
||||
tags = new ArrayList<String>();
|
||||
if(json.get("tags").equals(""))
|
||||
if (json.get("tags").equals(""))
|
||||
{
|
||||
// Empty list given as a string, eg "tags":""
|
||||
}
|
||||
@@ -94,7 +95,7 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
{
|
||||
// Array of tags
|
||||
JSONArray tagsA = (JSONArray)json.get("tags");
|
||||
for(int i=0; i<tagsA.size(); i++)
|
||||
for (int i=0; i<tagsA.size(); i++)
|
||||
{
|
||||
tags.add((String)tagsA.get(i));
|
||||
}
|
||||
@@ -103,13 +104,13 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
|
||||
// Are we creating or editing?
|
||||
WikiPageInfo page = wikiService.getWikiPage(site.getShortName(), pageName);
|
||||
if(page == null)
|
||||
if (page == null)
|
||||
{
|
||||
// Create the page
|
||||
page = wikiService.createWikiPage(site.getShortName(), title, contents);
|
||||
|
||||
// Add tags if given
|
||||
if(tags != null && tags.size() > 0)
|
||||
if (tags != null && tags.size() > 0)
|
||||
{
|
||||
page.getTags().addAll(tags);
|
||||
wikiService.updateWikiPage(page);
|
||||
@@ -124,11 +125,11 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
else
|
||||
{
|
||||
// Updating, check about versioning first
|
||||
if(forceSave || pageVersionMatchesSubmitted(page, currentVersion))
|
||||
if (forceSave || pageVersionMatchesSubmitted(page, currentVersion))
|
||||
{
|
||||
// Update the page
|
||||
page.setContents(contents);
|
||||
if(tags != null && tags.size() > 0)
|
||||
if (tags != null && tags.size() > 0)
|
||||
{
|
||||
page.getTags().clear();
|
||||
page.getTags().addAll(tags);
|
||||
@@ -161,14 +162,14 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
private boolean pageVersionMatchesSubmitted(WikiPageInfo page, String currentVersion)
|
||||
{
|
||||
// If they didn't give version, it can't be right
|
||||
if(currentVersion == null)
|
||||
if (currentVersion == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Grab the current version
|
||||
Version version = versionService.getCurrentVersion(page.getNodeRef());
|
||||
if(version == null)
|
||||
if (version == null)
|
||||
{
|
||||
// It should be versioned already, fix that
|
||||
makeVersioned(page);
|
||||
@@ -178,7 +179,7 @@ public class WikiPagePut extends AbstractWikiWebScript
|
||||
}
|
||||
|
||||
// Check the label
|
||||
if(version.getVersionLabel().equals(currentVersion))
|
||||
if (version.getVersionLabel().equals(currentVersion))
|
||||
{
|
||||
// Match, no changes
|
||||
return true;
|
||||
|
@@ -54,25 +54,27 @@ public class WikiPageVersionGet extends AbstractWikiWebScript
|
||||
|
||||
private ContentService contentService;
|
||||
private VersionService versionService;
|
||||
|
||||
public void setVersionService(VersionService versionService)
|
||||
{
|
||||
this.versionService = versionService;
|
||||
}
|
||||
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(SiteInfo site, String pageName,
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||
WebScriptRequest req, JSONObject json, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
// Grab the version string
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
String versionId = templateVars.get("versionId");
|
||||
if(versionId == null)
|
||||
if (versionId == null)
|
||||
{
|
||||
String error = "No versionId supplied";
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
|
||||
@@ -80,7 +82,7 @@ public class WikiPageVersionGet extends AbstractWikiWebScript
|
||||
|
||||
// Try to find the page
|
||||
WikiPageInfo page = wikiService.getWikiPage(site.getShortName(), pageName);
|
||||
if(page == null)
|
||||
if (page == null)
|
||||
{
|
||||
String message = "The Wiki Page could not be found";
|
||||
status.setCode(Status.STATUS_NOT_FOUND);
|
||||
@@ -99,9 +101,9 @@ public class WikiPageVersionGet extends AbstractWikiWebScript
|
||||
{
|
||||
versionHistory = versionService.getVersionHistory(page.getNodeRef());
|
||||
}
|
||||
catch(AspectMissingException e) {}
|
||||
catch (AspectMissingException e) {}
|
||||
|
||||
if(versionHistory == null)
|
||||
if (versionHistory == null)
|
||||
{
|
||||
// Not been versioned, return an empty string
|
||||
model.put(PARAM_CONTENT, "");
|
||||
@@ -111,23 +113,23 @@ public class WikiPageVersionGet extends AbstractWikiWebScript
|
||||
|
||||
// Fetch the version by either ID or Label
|
||||
Matcher m = LABEL_PATTERN.matcher(versionId);
|
||||
if(m.matches())
|
||||
if (m.matches())
|
||||
{
|
||||
// It's a version label like 2.3
|
||||
try
|
||||
{
|
||||
version = versionHistory.getVersion(versionId);
|
||||
}
|
||||
catch(VersionDoesNotExistException e) {}
|
||||
catch (VersionDoesNotExistException e) {}
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's a version ID like ed00bac1-f0da-4042-8598-45a0d39cb74d
|
||||
// (The ID is usually part of the NodeRef of the frozen node, but we
|
||||
// don't assume to be able to just generate the full NodeRef)
|
||||
for(Version v : versionHistory.getAllVersions())
|
||||
for (Version v : versionHistory.getAllVersions())
|
||||
{
|
||||
if(v.getFrozenStateNodeRef().getId().equals(versionId))
|
||||
if (v.getFrozenStateNodeRef().getId().equals(versionId))
|
||||
{
|
||||
version = v;
|
||||
}
|
||||
@@ -137,10 +139,10 @@ public class WikiPageVersionGet extends AbstractWikiWebScript
|
||||
|
||||
// Did we find the right version in the end?
|
||||
String contents;
|
||||
if(version != null)
|
||||
if (version != null)
|
||||
{
|
||||
ContentReader reader = contentService.getReader(version.getFrozenStateNodeRef(), ContentModel.PROP_CONTENT);
|
||||
if(reader != null)
|
||||
if (reader != null)
|
||||
{
|
||||
contents = reader.getContentString();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -54,12 +54,13 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
||||
* Unit Test to test the Wiki Web Script API
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public class WikiRestApiTest extends BaseWebScriptTest
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(WikiRestApiTest.class);
|
||||
|
||||
|
||||
private MutableAuthenticationService authenticationService;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private TransactionService transactionService;
|
||||
@@ -191,14 +192,14 @@ public class WikiRestApiTest extends BaseWebScriptTest
|
||||
private JSONObject getPages(String filter, String username) throws Exception
|
||||
{
|
||||
String origUser = this.authenticationComponent.getCurrentUserName();
|
||||
if(username != null)
|
||||
if (username != null)
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser(username);
|
||||
filter = "myPages";
|
||||
}
|
||||
|
||||
String url = URL_WIKI_LIST;
|
||||
if(filter == null)
|
||||
if (filter == null)
|
||||
{
|
||||
filter = "all";
|
||||
}
|
||||
@@ -208,7 +209,7 @@ public class WikiRestApiTest extends BaseWebScriptTest
|
||||
Response response = sendRequest(new GetRequest(url), 200);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
|
||||
if(username != null)
|
||||
if (username != null)
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser(origUser);
|
||||
}
|
||||
@@ -222,13 +223,13 @@ public class WikiRestApiTest extends BaseWebScriptTest
|
||||
if (expectedStatus == Status.STATUS_OK)
|
||||
{
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
if(result.has("page"))
|
||||
if (result.has("page"))
|
||||
{
|
||||
return result.getJSONObject("page");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if(expectedStatus == Status.STATUS_NOT_FOUND)
|
||||
else if (expectedStatus == Status.STATUS_NOT_FOUND)
|
||||
{
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
return result;
|
||||
@@ -250,7 +251,7 @@ public class WikiRestApiTest extends BaseWebScriptTest
|
||||
{
|
||||
return response.getContentAsString();
|
||||
}
|
||||
else if(expectedStatus == Status.STATUS_NOT_FOUND)
|
||||
else if (expectedStatus == Status.STATUS_NOT_FOUND)
|
||||
{
|
||||
return response.getContentAsString();
|
||||
}
|
||||
@@ -275,14 +276,14 @@ public class WikiRestApiTest extends BaseWebScriptTest
|
||||
json.put("tags", "");
|
||||
json.put("page", "wiki-page"); // TODO Is this really needed?
|
||||
|
||||
if(version == null || "force".equals(version))
|
||||
if (version == null || "force".equals(version))
|
||||
{
|
||||
// Allow the save as-is, no versioning check
|
||||
json.put("forceSave", "true"); // Allow the save as-is
|
||||
}
|
||||
else
|
||||
{
|
||||
if("none".equals(version))
|
||||
if ("none".equals(version))
|
||||
{
|
||||
// No versioning
|
||||
}
|
||||
@@ -296,7 +297,7 @@ public class WikiRestApiTest extends BaseWebScriptTest
|
||||
if (expectedStatus == Status.STATUS_OK)
|
||||
{
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
if(result.has("page"))
|
||||
if (result.has("page"))
|
||||
{
|
||||
return result.getJSONObject("page");
|
||||
}
|
||||
|
Reference in New Issue
Block a user