Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some bug fixes : 1350, 2798, 5218, 5508, 5555, 5598, 5601 #515

Merged
merged 7 commits into from May 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -83,7 +83,7 @@ scheduleEventVisible = true
display.all.components=false

# URL aide en ligne
helpURL = /help_fr/index.html
helpURL = https://extranet.silverpeas.com/help_fr

# Domain's Bar frameset
domainsBarFramesetWidth = 281
Expand Down
Expand Up @@ -78,7 +78,7 @@ fileSharingVisible = true
webconnectionsVisible = true

# URL aide en ligne
helpURL = /help_fr/index.html
helpURL = https://extranet.silverpeas.com/help_fr

# Domain's Bar frameset
domainsBarFramesetWidth = 255
Expand Down
Expand Up @@ -80,7 +80,7 @@ webconnectionsVisible = true
display.all.components=false

# URL aide en ligne
helpURL = /help_fr/index.html
helpURL = https://extranet.silverpeas.com/help_fr

# Domain's Bar frameset
domainsBarFramesetWidth = 255
Expand Down
Expand Up @@ -83,7 +83,7 @@ scheduleEventVisible = true
display.all.components=false

# URL aide en ligne
helpURL = /help_fr/index.html
helpURL = https://extranet.silverpeas.com/help_fr

# Domain's Bar frameset
domainsBarFramesetWidth =
Expand Down
Expand Up @@ -84,7 +84,7 @@ scheduleEventVisible=false
display.all.components=false

# URL aide en ligne
helpURL = /help_fr/index.html
helpURL = https://extranet.silverpeas.com/help_fr

# Domain's Bar frameset
domainsBarFramesetWidth = 255
Expand Down
Expand Up @@ -122,6 +122,7 @@ public class PublicationDetail extends AbstractI18NBean<PublicationI18N> impleme
public static final String REFUSED = "Unvalidate";
public static final String CLONE = "Clone";
public static final String TYPE = "Publication";
private boolean alias = false;

/**
* Default contructor, required for castor mapping in importExport.
Expand Down Expand Up @@ -1236,4 +1237,12 @@ public void setExplicitRank(int explicitRank) {
public int getExplicitRank() {
return explicitRank;
}

public void setAlias(boolean alias) {
this.alias = alias;
}

public boolean isAlias() {
return alias;
}
}
7 changes: 6 additions & 1 deletion lib-core/src/main/java/com/silverpeas/util/StringUtil.java
Expand Up @@ -167,6 +167,12 @@ public static String toAcceptableFilename(String name) {
fileName = fileName.replace('$', '_');
fileName = fileName.replace('%', '_');
fileName = fileName.replace('?', '_');
fileName = fileName.replace(':', '_');
fileName = fileName.replace('*', '_');
fileName = fileName.replace('"', '_');
fileName = fileName.replace('<', '_');
fileName = fileName.replace('>', '_');
fileName = fileName.replace('|', '_');
return fileName;
}

Expand Down Expand Up @@ -238,7 +244,6 @@ public static String regexReplace(String source, String regex, String replacemen
if (StringUtil.isNotDefined(source) || StringUtil.isNotDefined(regex)) {
return source;
}
String replacementText = StringUtil.isDefined(replacement) ? replacement : "";
return source.replaceAll(regex, replacement);
}

Expand Down
Expand Up @@ -40,7 +40,7 @@
public class AbstractNotification {

private ResourceLocator notifResources = new ResourceLocator(
"com.stratelia.silverpeas.notificationManager.settings.notificationManagerSettings", "");
"org.silverpeas.notificationManager.settings.notificationManagerSettings", "");

public String getApplicationURL() {
return URLManager.getApplicationURL();
Expand All @@ -54,10 +54,17 @@ public String computeURL(final String userId, final String urlBase) {
return (urlBase.startsWith("http") ? urlBase : getUserAutoRedirectURL(userId, urlBase));
}

public String getUserAutoRedirectURL(final String userId,
final String target) {
public String getUserAutoRedirectURL(final String userId, final String target) {
try {
return getUserAutoRedirectURL(userId) + URLEncoder.encode(target, "UTF-8");
final UserDetail ud = AdminReference.getAdminService().getUserDetail(userId);
final Domain dom = AdminReference.getAdminService().getDomain(ud.getDomainId());
String url = null;
if (URLManager.isPermalink(target)) {
url = dom.getSilverpeasServerURL() + getApplicationURL() + target;
} else {
url = getUserAutoRedirectURL(dom) + URLEncoder.encode(target, "UTF-8");
}
return url;
} catch (final Exception e) {
SilverTrace.error("peasCore",
"URLManager.getUserAutoRedirectURL(userId)", "root.EX_NO_MESSAGE",
Expand All @@ -66,16 +73,14 @@ public String getUserAutoRedirectURL(final String userId,
}
}

public String getUserAutoRedirectURL(final String userId) {
public String getUserAutoRedirectURL(final Domain dom) {
try {
final UserDetail ud = AdminReference.getAdminService().getUserDetail(userId);
final Domain dom = AdminReference.getAdminService().getDomain(ud.getDomainId());
return dom.getSilverpeasServerURL() + getApplicationURL()
+ "/autoRedirect.jsp?domainId=" + dom.getId() + "&goto=";
} catch (final Exception ae) {
SilverTrace.error("peasCore",
"URLManager.getUserAutoRedirectURL(userId)",
"admin.EX_ERR_GET_USER_DETAILS", "user id: '" + userId + "'", ae);
"URLManager.getUserAutoRedirectURL(domain)",
"admin.EX_ERR_GET_USER_DETAILS", "domainId : " + dom.getId(), ae);
return "ErrorGettingDomainServer";
}
}
Expand Down
Expand Up @@ -100,6 +100,51 @@ public class URLManager {
static Properties specialsURL = null;
static String httpMode = null;
static boolean universalLinksUsed = false;

private enum Permalink {
Publication(URL_PUBLI, "/Publication/"), Space(URL_SPACE, "/Space/"),
Component(URL_COMPONENT, "/Component/"), Folder(URL_TOPIC, "/Topic/"),
File(URL_FILE, "/File/"), Document(URL_DOCUMENT, "/Document/"),
Version(URL_VERSION, "/Version/"), Survey(URL_SURVEY, "/Survey/"),
Question(URL_QUESTION, "/Question/"), ForumMessage(URL_MESSAGE, "/ForumsMessage/");
private int type;
private String urlPrefix;

private Permalink(int type, String urlPrefix) {
this.type = type;
this.urlPrefix = urlPrefix;
}

public int getType() {
return type;
}

public String getURLPrefix() {
return urlPrefix;
}

public static Permalink fromType(int type) {
Permalink permalink = null;
for (Permalink aPermalink : values()) {
if (aPermalink.getType() == type) {
permalink = aPermalink;
break;
}
}
return permalink;
}

public static boolean isCompliant(String url) {
boolean compliant = false;
for (Permalink aPermalink : values()) {
if (url != null && url.contains(aPermalink.getURLPrefix())) {
compliant = true;
break;
}
}
return compliant;
}
}

static {
ResourceLocator resources = new ResourceLocator("com.stratelia.silverpeas.peasCore.URLManager",
Expand Down Expand Up @@ -222,9 +267,10 @@ public static String getSimpleURL(int type, String id, String componentId,
if (appendContext) {
url = getApplicationURL();
}
switch (type) {
case URL_MESSAGE:
url += "/ForumsMessage/" + id + "?ForumId=" + forumId;
Permalink permalink = Permalink.fromType(type);
switch (permalink) {
case ForumMessage:
url += permalink.getURLPrefix() + id + "?ForumId=" + forumId;
break;
}
return url;
Expand All @@ -240,40 +286,28 @@ public static String getSimpleURL(int type, String id, String componentId,
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
switch (type) {
case URL_SPACE:
Permalink permalink = Permalink.fromType(type);
switch (permalink) {
case Space:
if (!id.startsWith(Admin.SPACE_KEY_PREFIX)) {
id = Admin.SPACE_KEY_PREFIX + id;
}
url += "/Space/" + id;
break;
case URL_COMPONENT:
url += "/Component/" + id;
url += permalink.getURLPrefix() + id;
break;
case URL_PUBLI:
url += "/Publication/" + id;
case Publication:
url += permalink.getURLPrefix() + id;
if (isDefined(componentId)) {
url += "?ComponentId=" + componentId;
}
break;
case URL_TOPIC:
url += "/Topic/" + id + "?ComponentId=" + componentId;
break;
case URL_FILE:
url += "/File/" + id;
break;
case URL_SURVEY:
url += "/Survey/" + id;
break;
case URL_QUESTION:
url += "/Question/" + id;
break;
case URL_DOCUMENT:
url += "/Document/" + id;
break;
case URL_VERSION:
url += "/Version/" + id;
case Folder:
url += permalink.getURLPrefix() + id;
if (isDefined(componentId)) {
url += "?ComponentId=" + componentId;
}
break;
default:
url += permalink.getURLPrefix() + id;
}
return url;
}
Expand All @@ -297,4 +331,8 @@ public static String getSearchResultURL(SilverpeasContent content) {
}
return url;
}

public static boolean isPermalink(String url) {
return Permalink.isCompliant(url);
}
}
Expand Up @@ -61,6 +61,8 @@ public class ComponentInstLight extends AbstractI18NBean<ComponentI18N> implemen
private String removerName = null;
private List<SpaceInstLight> path = null;
private boolean isInheritanceBlocked = false;
private boolean hidden = false;
private boolean publicApp = false;

/**
* Constructor
Expand Down Expand Up @@ -99,6 +101,8 @@ public ComponentInstLight(ComponentInstanceRow compo) {
orderNum = compo.orderNum;

isInheritanceBlocked = compo.inheritanceBlocked == 1;
hidden = compo.hidden == 1;
publicApp = compo.publicAccess == 1;
}

/**
Expand Down Expand Up @@ -265,6 +269,14 @@ public void setInheritanceBlocked(boolean isInheritanceBlocked) {
this.isInheritanceBlocked = isInheritanceBlocked;
}

public boolean isHidden() {
return hidden;
}

public boolean isPublic() {
return publicApp;
}

public boolean isWorkflow() {
return Instanciateur.isWorkflow(getName());
}
Expand Down
Expand Up @@ -24,6 +24,7 @@

--%>

<%@page import="com.silverpeas.util.StringUtil"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="java.util.List"%>
Expand Down Expand Up @@ -224,9 +225,9 @@ if(listResult != null) {
ArrayLine arrayLine = arrayPane.addArrayLine();
arrayLine.addArrayCellText("<a href=\"#\" onclick=\""+url+"\">"+name+"</a>");

String desc = searchResult.getDesc();
if (desc != null && desc.length() > 200) {
desc = desc.substring(0, 200)+"...";
String desc = "";
if (StringUtil.isDefined(searchResult.getDesc())) {
desc = StringUtil.abbreviate(searchResult.getDesc(), 200);
}
arrayLine.addArrayCellText(desc);

Expand Down
11 changes: 9 additions & 2 deletions war-core/src/main/webapp/selection/jsp/javaScript/selection.js
Expand Up @@ -89,8 +89,15 @@ Selection.prototype.itemIdsAsString = function() {
Selection.prototype.itemNamesAsString = function() {
var names = '';
for (var i = 0; i < this.items.length - 1; i++)
names += this.items[i].name + ',';
names += getName(this.items[i]) + ', ';
if (this.items.length > 0)
names += this.items[this.items.length - 1].name;
names += getName(this.items[this.items.length - 1]);
return names;
};

function getName(item) {
if (typeof item.name !== 'undefined') {
return item.name;
}
return item.fullName;
}
Expand Up @@ -24,37 +24,13 @@

package com.silverpeas.importExport.control;

import java.io.File;
import com.silverpeas.util.StringUtil;

/**
* @author sdevolder Méthodes à factoriser
*/
public class DirectoryUtils {

/**
* Retourne une chaine ne contenant que des caractères autorisés pour le nommage des dossiers. en
* évitant de convertir les séparateurs de fichier. On suppose que ? ne pourra jamais être un
* séparateur de fichiers.
* @param directoryPath
* @return
*/
public static String formatToDirectoryPathNamingCompliant(String directoryPath) {
String tempDir = directoryPath.trim();
tempDir = tempDir.replace('?', '_');
tempDir = tempDir.replace(File.separatorChar, '?');
tempDir = tempDir.replace('\\', '_');
tempDir = tempDir.replace('/', '_');
tempDir = tempDir.replace(':', '_');
tempDir = tempDir.replace('*', '_');
tempDir = tempDir.replace('\"', '_');
tempDir = tempDir.replace('<', '_');
tempDir = tempDir.replace('>', '_');
tempDir = tempDir.replace('|', '_');
tempDir = removeDots(tempDir);
tempDir = tempDir.replace('?', File.separatorChar);
return tempDir;
}

/**
* Retourne une chaine ne contenant que des caractères autorisés pour le nommage des dossiers y
* compris les séparateurs de fichier éventuellement.
Expand All @@ -63,15 +39,7 @@ public static String formatToDirectoryPathNamingCompliant(String directoryPath)
*/
public static String formatToDirectoryNamingCompliant(String directoryName) {
String tempDir = directoryName.trim();
tempDir = tempDir.replace('?', '_');
tempDir = tempDir.replace('\\', '_');
tempDir = tempDir.replace('/', '_');
tempDir = tempDir.replace(':', '_');
tempDir = tempDir.replace('*', '_');
tempDir = tempDir.replace('\"', '_');
tempDir = tempDir.replace('<', '_');
tempDir = tempDir.replace('>', '_');
tempDir = tempDir.replace('|', '_');
tempDir = StringUtil.toAcceptableFilename(tempDir);
tempDir = removeDots(tempDir);
return tempDir;
}
Expand Down