Skip to content

Commit

Permalink
SAK-43091 Deprecated utils.FormattedText => api.FormattedText (sakaip…
Browse files Browse the repository at this point in the history
…roject#7824)

* SAK-43091 Deprecated utils.FormattedText => api.FormattedText

* SAK-43091 Deprecated Web, Validator  => api.FormattedText
  • Loading branch information
axxter99 authored Jan 31, 2020
1 parent 82f142f commit c35e570
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.sakaiproject.chat2.model.ChatChannel;
import org.sakaiproject.chat2.model.ChatManager;
import org.sakaiproject.chat2.model.ChatMessage;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.EntityManager;
Expand All @@ -64,7 +65,7 @@
import org.sakaiproject.user.cover.UserDirectoryService;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.StringUtil;
import org.sakaiproject.util.Web;
import org.sakaiproject.util.api.FormattedText;

/**
* @author chrismaurer
Expand Down Expand Up @@ -404,7 +405,7 @@ public void handleAccess(HttpServletRequest req, HttpServletResponse res, Refere
//{
// groups += "<li>" + i.next() + "</li>";
//}
String body = Web.escapeHtml(message.getBody());
String body = ComponentManager.get(FormattedText.class).escapeHtml(message.getBody());

sw
.write("<!DOCTYPE html>\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
import org.sakaiproject.user.cover.UserDirectoryService;
import org.sakaiproject.util.DateFormatterUtil;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.Validator;
import org.sakaiproject.util.api.FormattedText;

@Slf4j
@Getter @Setter
Expand Down Expand Up @@ -1262,7 +1262,7 @@ protected String getContext() {
* @return
*/
public String getFramePlacementId() {
return Validator.escapeJavascript("Main" + getToolManager().getCurrentPlacement().getId());
return ComponentManager.get(FormattedText.class).escapeJavascript("Main" + getToolManager().getCurrentPlacement().getId());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

import org.sakaiproject.chat2.model.ChatManager;
import org.sakaiproject.chat2.model.ChatMessage;
import org.sakaiproject.util.FormattedText;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.api.FormattedText;

public class DecoratedChatMessage {

Expand Down Expand Up @@ -89,7 +90,7 @@ public String getId()
* @return
*/
public String getRestrictedBody() {
String message = FormattedText.convertFormattedTextToPlaintext(chatMessage.getBody());
String message = ComponentManager.get(FormattedText.class).convertFormattedTextToPlaintext(chatMessage.getBody());
int maxLength = chatTool.lookupSynopticOptions().getChars();
int actualLength = message.length();
if (maxLength < actualLength && maxLength >= 0) {
Expand All @@ -99,7 +100,7 @@ public String getRestrictedBody() {
}

public String getUnformattedBody() {
return FormattedText.convertFormattedTextToPlaintext(chatMessage.getBody());
return ComponentManager.get(FormattedText.class).convertFormattedTextToPlaintext(chatMessage.getBody());
}

public boolean getCanRemoveMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
import org.sakaiproject.profile2.logic.ProfileConnectionsLogic;
import org.sakaiproject.profile2.model.BasicConnection;
import org.sakaiproject.profile2.util.ProfileConstants;
import org.sakaiproject.util.FormattedText;
import org.sakaiproject.util.api.FormattedText;


/**
* @author Adrian Fish ([email protected])
Expand All @@ -56,6 +57,7 @@ public class CommonsManagerImpl implements CommonsManager, Observer {
private PersistenceManager persistenceManager;
private ProfileConnectionsLogic profileConnectionsLogic;
private SakaiProxy sakaiProxy;
private FormattedText formattedText;

public void init() {

Expand Down Expand Up @@ -119,7 +121,7 @@ public Post savePost(Post post) {

if (commonsSecurityManager.canCurrentUserEditPost(post)) {
try {
post.setContent(FormattedText.processFormattedText(post.getContent(), new StringBuilder(), true, false));
post.setContent(formattedText.processFormattedText(post.getContent(), new StringBuilder(), true, false));
Post newOrUpdatedPost = persistenceManager.savePost(post);
if (newOrUpdatedPost != null) {
String commonsId = post.getCommonsId();
Expand Down
1 change: 1 addition & 0 deletions commons/impl/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<property name="commonsSecurityManager"><ref bean="org.sakaiproject.commons.api.CommonsSecurityManager"/></property>
<property name="persistenceManager"><ref bean="org.sakaiproject.commons.api.PersistenceManager"/></property>
<property name="profileConnectionsLogic"><ref bean="org.sakaiproject.profile2.logic.ProfileConnectionsLogic"/></property>
<property name="formattedText" ref="org.sakaiproject.util.api.FormattedText" />
</bean>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;

import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.jsf.util.RendererUtil;
import org.sakaiproject.util.FormattedText;
import org.sakaiproject.util.api.FormattedText;


public class RichTextAreaRenderer extends Renderer
{
Expand All @@ -57,7 +59,7 @@ public void encodeBegin(FacesContext context, UIComponent component)

//escape the value so the wysiwyg editors don't get too clever and turn things
//into tags that are not tags.
value = FormattedText.escapeHtmlFormattedTextarea((String) value);
value = ComponentManager.get(FormattedText.class).escapeHtmlFormattedTextarea((String) value);

// character height of the textarea
int columns = -1;
Expand Down

0 comments on commit c35e570

Please sign in to comment.