/** * Get redirect url. * * @return redirect url * @throws PortalException */ public static String getRedirectURL(PortletRequest portletRequest) throws PortalException { StringBundler sb = new StringBundler(); sb.append(GSearchUtil.getCurrentLayoutFriendlyURL(portletRequest)); sb.append("?"); sb.append(GSearchWebKeys.KEYWORDS).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.KEYWORDS)); sb.append("&").append(GSearchWebKeys.FILTER_SCOPE).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.FILTER_SCOPE)); sb.append("&").append(GSearchWebKeys.FILTER_TIME).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.FILTER_TIME)); sb.append("&").append(GSearchWebKeys.FILTER_TYPE).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.FILTER_TYPE)); sb.append("&").append(GSearchWebKeys.SORT_FIELD).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.SORT_FIELD)); sb.append("&").append(GSearchWebKeys.SORT_DIRECTION).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.SORT_DIRECTION)); sb.append("&").append(GSearchWebKeys.START).append("=").append( ParamUtil.getString(portletRequest, GSearchWebKeys.START)); return HtmlUtil.escapeURL(sb.toString()); }
public String getIconURL(long applicationId) throws Exception { String result = ""; try { // _log.debug("getIconURL(applicationId " + applicationId + ")"); Application application = applicationLocalService.getApplication(applicationId); if (application.getLogoImageId() != 0) { DLFileEntry fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId()); result = "http://localhost/documents/10180/0/" + HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) + StringPool.SLASH + fe.getUuid() + "?version=" + fe.getVersion() + "&t=" + fe.getModifiedDate().getTime() + "&imageThumbnail=1"; } } catch (SystemException se) { _log.error("applicationId: " + applicationId); _log.error(se.getMessage()); } catch (PortalException pe) { _log.error("applicationId: " + applicationId); _log.error(pe.getMessage()); } return result; }
private String getExternIconURL(Application application) throws Exception { String result = ""; try { if (application.getLogoImageId() != 0) { DLFileEntry fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId()); result = "http://" + AppConstants.COMPANY_VIRTUAL_HOST + "/documents/10180/0/" + HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) + StringPool.SLASH + fe.getUuid() + "?version=" + fe.getVersion() + "&t=" + fe.getModifiedDate().getTime() + "&imageThumbnail=1"; } } catch (SystemException se) { _log.error(se.getMessage()); } catch (PortalException pe) { _log.error(pe.getMessage()); } return result; }
protected void handleEmail( StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags, IntegerWrapper marker, BBCodeItem bbCodeItem) { sb.append("<a href=\""); String href = bbCodeItem.getAttribute(); if (href == null) { href = extractData( bbCodeItems, marker, "email", BBCodeParser.TYPE_DATA, false); } if (!href.startsWith("mailto:")) { href = "mailto:" + href; } sb.append(HtmlUtil.escapeHREF(href)); sb.append("\">"); tags.push("</a>"); }
protected void handleYoutube( StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags, IntegerWrapper marker) { String videoId = extractData( bbCodeItems, marker, "youtube", BBCodeParser.TYPE_DATA, true); if (videoId.length() > 0) { int videoHeight = GetterUtil.get(PropsUtil.get("forum.video.height"), 349); int videoWidth = GetterUtil.get(PropsUtil.get("forum.video.width"), 560); // Extrai o identificador do video, parar criar o embbed for (Pattern p : YOUTUBE_PATTERNS) { Matcher m = p.matcher(videoId); if (m.find()) { sb.append("<iframe "); sb.append("width=\"").append(videoWidth).append("\" "); sb.append("height=\"").append(videoHeight).append("\" "); sb.append("src=\"http://www.youtube.com/embed/"); sb.append(HtmlUtil.escapeAttribute(m.group(1))); sb.append("\" frameborder=\"0\" allowfullscreen></iframe>"); break; } } } }
protected void handleURL( StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags, IntegerWrapper marker, BBCodeItem bbCodeItem) { sb.append("<a href=\""); String href = bbCodeItem.getAttribute(); if (href == null) { href = extractData( bbCodeItems, marker, "url", BBCodeParser.TYPE_DATA, false); } Matcher matcher = _urlPattern.matcher(href); if (matcher.matches()) { sb.append(HtmlUtil.escapeHREF(href)); } sb.append("\">"); tags.push("</a>"); }
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long siteRequestId = jsonObject.getLong("siteRequestId"); SiteRequest microsite = SiteRequestLocalServiceUtil.getSiteRequest(siteRequestId); if (Validator.isNull(microsite)) { UserNotificationEventLocalServiceUtil.deleteUserNotificationEvent(userNotificationEvent.getPrimaryKey()); return null; } long userId = jsonObject.getLong("userId"); String notificationType = jsonObject.getString("notificationType"); String title = getTitle(serviceContext, userId, notificationType); return StringUtil.replace( getBodyTemplate(), new String[] { "[$TITLE$]", "[$NAME$]", "[$BODY_TEXT$]" }, new String[] { title, HtmlUtil.escape(StringUtil.shorten(microsite.getName(), 50)), HtmlUtil.escape(StringUtil.shorten(microsite.getDescription(), 50)) }); }
private String getTitle(ServiceContext serviceContext, long userId, String notificationType) { String title = ""; switch(notificationType) { case MicroSiteConstants.REQUEST_STATUS_COMPLETE: title = "site-request-completed-notification"; break; case MicroSiteConstants.REQUEST_STATUS_PENDING: title = "site-request-processing-notification"; break; case MicroSiteConstants.REQUEST_STATUS_REJECTED: title = "site-request-rejected-notification"; default: break; } return serviceContext.translate(title, HtmlUtil.escape(PortalUtil.getUserName(userId, StringPool.BLANK))); }
protected String getStagedModelMessage(Locale locale) { StringBundler sb = new StringBundler(8); sb.append("<strong>"); sb.append(LanguageUtil.get(locale, getStatusMessageKey())); sb.append(StringPool.TRIPLE_PERIOD); sb.append("</strong>"); sb.append(ResourceActionsUtil.getModelResource(locale, _stagedModelType)); sb.append("<em>"); sb.append(HtmlUtil.escape(_stagedModelName)); sb.append("</em>"); return sb.toString(); }
@Override protected Map<String, Object> getTemplateVars() { Map<String, Object> templateVars = new HashMap<>(); templateVars.put("exported", MapUtil.getBoolean(backgroundTask.getTaskContextMap(), "exported")); templateVars.put("validated", MapUtil.getBoolean(backgroundTask.getTaskContextMap(), "validated")); templateVars.put("htmlUtil", HtmlUtil.getHtml()); return templateVars; }
@Override public void updateAsset(long userId, TaskRecord taskRecord, long[] assetCategoryIds, String[] assetTagNames, long[] assetLinkEntryIds, Double priority) throws PortalException { // TODO boolean visible = true; // boolean visible = false; // if (taskRecord.isApproved()) { // visible = true; // publishDate = taskRecord.getCreateDate(); // } Date publishDate = null; String summary = HtmlUtil.extractText(StringUtil.shorten(taskRecord.getWorkPackage(), 500)); String className = TaskRecord.class.getName(); long classPK = taskRecord.getTaskRecordId(); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, taskRecord.getGroupId(), taskRecord.getCreateDate(), taskRecord.getModifiedDate(), className, classPK, taskRecord.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML, taskRecord.getWorkPackage(), taskRecord.getWorkPackage(), summary, null, null, 0, 0, priority); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); }
@Override public void updateAsset(long userId, Contact contact, long[] assetCategoryIds, String[] assetTagNames, long[] assetLinkEntryIds, Double priority) throws PortalException { // TODO boolean visible = true; // boolean visible = false; // if (contact.isApproved()) { // visible = true; // publishDate = contact.getCreateDate(); // } Date publishDate = contact.getCreateDate(); // TODO String description = "TODO: contact description"; String summary = HtmlUtil.extractText(StringUtil.shorten(contact.getCard(), 500)); String className = Contact.class.getName(); long classPK = contact.getContactId(); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, contact.getGroupId(), contact.getCreateDate(), contact.getModifiedDate(), className, classPK, contact.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML, // contact.getName(), "TODO: contact.getName()", description, summary, null, null, 0, 0, priority); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); // assetEntryLocalService.updateVisible(Contact.class.getName(), // classPK, visible); }
/** * {@inheritDoc} */ @Override public String getDescription() throws SearchException { return HtmlUtil.stripHtml(getSummary().getContent()); }
/** * {@inheritDoc} */ @Override public String getTitle() throws NumberFormatException, PortalException { String title = getSummary().getTitle(); if (Validator.isNull(title)) { title = getAssetRenderer().getTitle(_locale); } return HtmlUtil.stripHtml(title); }
@Override public void updateAsset(long userId, Measurement measurement, long[] assetCategoryIds, String[] assetTagNames, Double priority) throws PortalException { // TODO boolean visible = true; // boolean visible = false; // if (measurement.isApproved()) { // visible = true; // publishDate = measurement.getCreateDate(); // } Date publishDate = null; String summary = HtmlUtil .extractText(StringUtil.shorten(measurement.getData(), 500)); String className = Measurement.class.getName(); long classPK = measurement.getMeasurementId(); assetEntryLocalService.updateEntry(userId, measurement.getGroupId(), measurement.getCreateDate(), measurement.getModifiedDate(), className, classPK, measurement.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML, measurement.getName(), measurement.getName(), summary, null, null, 0, 0, priority); }
public static String formataArtigo(String texto, boolean primeiraLinhaInline) { // Converte as linhas para páragrafos BufferedReader reader = new BufferedReader(new StringReader(texto)); StringBuilder sb = new StringBuilder(); String linha; int numero = 0; try { while ((linha = reader.readLine()) != null) { Matcher m = PATTERN_ARTIGO.matcher(linha); if (m.matches()) { StringBuilder sbLinha = new StringBuilder(linha); sbLinha.insert(m.end(1), "[/b]"); sbLinha.insert(0, "[b]"); linha = sbLinha.toString(); } if (numero != 0 || !primeiraLinhaInline) sb.append("<p>"); sb.append(HtmlUtil.escape(linha)); if (numero != 0 || !primeiraLinhaInline) sb.append("</p>"); numero++; } } catch (IOException e) { // Não deve acontecer } int pos = 0; while ((pos = sb.indexOf("[b]", pos)) != -1) { sb.replace(pos, pos + 3, "<b>"); pos += 3; } pos = 0; while ((pos = sb.indexOf("[/b]", pos)) != -1) { sb.replace(pos, pos + 4, "</b>"); pos += 4; } return sb.toString(); }
/** * Formata a estrutura para exibição * @param texto * @return */ public static String formataEstrutura(String texto) { // Separa em duas linhas Matcher m = PATTERN_ESTRUTURA.matcher(texto); if (m.matches()) { StringBuilder sb = new StringBuilder(); sb.append(m.group(1)); sb.append("\n"); sb.append(m.group(2)); texto = sb.toString(); } texto = HtmlUtil.escape(texto); return texto.replaceAll("\\n", "<br/>"); }
public String getHTML(String bbcode) { try { bbcode = parse(bbcode); } catch (Exception e) { _log.error("Unable to parse: " + bbcode, e); bbcode = HtmlUtil.escape(bbcode); } return bbcode; }
protected void handleCode( StringBundler sb, List<BBCodeItem> bbCodeItems, IntegerWrapper marker) { sb.append("<div class=\"code\">"); String code = extractData( bbCodeItems, marker, "code", BBCodeParser.TYPE_DATA, true); code = HtmlUtil.escape(code); code = code.replaceAll(StringPool.TAB, StringPool.FOUR_SPACES); String[] lines = code.split("\r?\n"); String digits = String.valueOf(lines.length + 1); for (int i = 0; i < lines.length; i++) { String index = String.valueOf(i + 1); sb.append("<span class=\"code-lines\">"); for (int j = 0; j < digits.length() - index.length(); j++) { sb.append(StringPool.NBSP); } lines[i] = StringUtil.replace( lines[i], StringPool.THREE_SPACES, " "); lines[i] = StringUtil.replace( lines[i], StringPool.DOUBLE_SPACE, " "); sb.append(index); sb.append("</span>"); sb.append(lines[i]); if (index.length() < lines.length) { sb.append("<br />"); } } sb.append("</div>"); }
protected void handleFontFamily( StringBundler sb, Stack<String> tags, BBCodeItem bbCodeItem) { sb.append("<span style=\"font-family: "); sb.append(HtmlUtil.escapeAttribute(bbCodeItem.getAttribute())); sb.append("\">"); tags.push("</span>"); }
private void obtemNomeDoUsuario(RenderRequest request, ThemeDisplay td, User usuario) { Locale locale = td.getLocale(); String nome = HtmlUtil.escape(usuario.getFullName()); if (td.isShowMyAccountIcon()) { nome = "<a href=\"" + HtmlUtil.escape(td.getURLMyAccount().toString()) + "\">" + nome + "</a>"; } request.setAttribute("logged-in", LanguageUtil.format(locale, "you-are-signed-in-as-x", nome)); }
public void initLiferay() { new FileUtil().setFile(new FileImpl()); new SAXReaderUtil().setSAXReader(new SAXReaderImpl()); new PortalUtil().setPortal(new PortalImpl()); new HtmlUtil().setHtml(new HtmlImpl()); ModelHintsImpl modelHints = new ModelHintsImpl(); modelHints.afterPropertiesSet(); new ModelHintsUtil().setModelHints(modelHints); }
public void initLiferay() { new FileUtil().setFile(new FileImpl()); new SAXReaderUtil().setSAXReader(new SAXReaderImpl()); new PortalUtil().setPortal(new PortalImpl()); new HtmlUtil().setHtml(new HtmlImpl()); ModelHintsImpl modelHints = new ModelHintsImpl(); modelHints.afterPropertiesSet(); new ModelHintsUtil().setModelHints(modelHints); new FastDateFormatFactoryUtil().setFastDateFormatFactory(new FastDateFormatFactoryImpl()); }
@Override public Response updateFormScript(HttpServletRequest request, HttpHeaders header, Company company, Locale locale, User user, ServiceContext serviceContext, long id, String partNo, DossierPartContentInputUpdateModel input) { DossierTemplateActions actions = new DossierTemplateActionsImpl(); long groupId = GetterUtil.getLong(header.getHeaderString("groupId")); BackendAuth auth = new BackendAuthImpl(); DossierPartContentInputUpdateModel result = new DossierPartContentInputUpdateModel(); try { if (!auth.isAuth(serviceContext)) { throw new UnauthenticationException(); } if (!auth.hasResource(serviceContext, DossierTemplate.class.getName(), ActionKeys.ADD_ENTRY)) { throw new UnauthorizationException(); } String content = actions.updateFormScript(groupId, id, partNo, input.getValue(), serviceContext); HtmlUtil.escape(content); result.setValue(content); return Response.status(200).entity(result).build(); } catch (Exception e) { ErrorMsg error = new ErrorMsg(); if (e instanceof UnauthenticationException) { error.setMessage("Non-Authoritative Information."); error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE); error.setDescription("Non-Authoritative Information."); return Response.status(HttpURLConnection.HTTP_NOT_AUTHORITATIVE).entity(error).build(); } else { if (e instanceof UnauthorizationException) { error.setMessage("Unauthorized."); error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE); error.setDescription("Unauthorized."); return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).entity(error).build(); } else { error.setMessage("Internal Server Error"); error.setCode(HttpURLConnection.HTTP_FORBIDDEN); error.setDescription(e.getMessage()); return Response.status(HttpURLConnection.HTTP_INTERNAL_ERROR).entity(error).build(); } } } }
public List<List> getNewApplications(long companyId, int year, int month, int day, int count) throws SystemException { List<List> result = new ArrayList<List>(); Date modifiedDate = PortalUtil.getDate(month, day, year); Date now = new Date(); List<Application> applications = applicationPersistence.findAll(); List<Application> applications2 = new ArrayList<Application>(); for (Application app: applications) { applications2.add(app); } OrderByComparator orderByComparator = CustomComparatorUtil.getApplicationOrderByComparator("modifiedDate", "desc"); Collections.sort(applications2, orderByComparator); applications2 = applications2.subList(0, count); for (Application application: applications2) { if (application.getLifeCycleStatus() >= 4) { List toAdd = new ArrayList(); toAdd.add(application); DLFileEntry fe; try { fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId()); String iconUrl = "http://localhost/documents/10180/0/" + HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) + StringPool.SLASH + fe.getUuid() + "?version=" + fe.getVersion() + "&t=" + fe.getModifiedDate().getTime() + "&imageThumbnail=1"; toAdd.add(iconUrl); } catch (PortalException e) { _log.error(e.getMessage()); } result.add(toAdd); } } return result; }
public List<List> getNewApplications(long companyId, int year, int month, int day, int count) throws SystemException { _log.debug("getNewApplications2: "); List<List> result = new ArrayList<List>(); try { Date modifiedDate = PortalUtil.getDate(month, day, year); Date now = new Date(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Application.class); Criterion criterion = null; criterion = RestrictionsFactoryUtil.between("modifiedDate",modifiedDate,now); dynamicQuery.add(criterion); dynamicQuery.add(PropertyFactoryUtil.forName("lifeCycleStatus").eq(E_Stati.APPLICATION_STATUS_VERIFIED.getIntStatus())); Order defaultOrder = OrderFactoryUtil.desc("modifiedDate"); dynamicQuery.addOrder(defaultOrder); dynamicQuery.setLimit(0, count); List<Application> applications = ApplicationLocalServiceUtil.dynamicQuery(dynamicQuery); for (Application application: applications) { List toAdd = new ArrayList(); toAdd.add(application); if (application.getLogoImageId() != 0) { DLFileEntry fe; fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId()); //String iconUrl = "http://localhost/documents/10180/0/" + HttpUtil.encodeURL(fe.getTitle(), true); String iconUrl = "http://localhost/documents/10180/0/" + HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) + StringPool.SLASH + fe.getUuid() + "?version=" + fe.getVersion() + "&t=" + fe.getModifiedDate().getTime() + "&imageThumbnail=1"; toAdd.add(iconUrl); } result.add(toAdd); } } catch (Exception e) { _log.error(e.getMessage()); e.printStackTrace(); } return result; }
@Override protected Document doGetDocument(Object obj) throws Exception { Course entry = (Course)obj; AssetEntry asset=AssetEntryLocalServiceUtil.getEntry(Course.class.getName(), entry.getCourseId()); long companyId = entry.getCompanyId(); long groupId = getParentGroupId(entry.getGroupId()); long scopeGroupId = entry.getGroupId(); long userId = entry.getUserId(); User user=UserLocalServiceUtil.getUser(userId); String userName = user.getFullName(); long entryId = entry.getCourseId(); String title = entry.getTitle(); String content = HtmlUtil.extractText(entry.getDescription()); Date displayDate = asset.getPublishDate(); long[] assetCategoryIds =AssetCategoryLocalServiceUtil.getCategoryIds(Course.class.getName(), entryId); String[] assetTagNames =AssetTagLocalServiceUtil.getTagNames(Course.class.getName(), entryId); ExpandoBridge expandoBridge = entry.getExpandoBridge(); Document document = new DocumentImpl(); document.addUID(PORTLET_ID, entryId); document.addModifiedDate(displayDate); document.addKeyword(Field.COMPANY_ID, companyId); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addKeyword(Field.GROUP_ID, groupId); document.addKeyword(Field.SCOPE_GROUP_ID, scopeGroupId); document.addKeyword(Field.USER_ID, userId); document.addText(Field.USER_NAME, userName); document.addText(Field.TITLE, title); document.addText(Field.CONTENT, content); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.ENTRY_CLASS_NAME, LearningActivity.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, entryId); ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge); return document; }
protected Document doGetDocument(Object obj) { try{ LearningActivity entry = (LearningActivity)obj; long companyId = entry.getCompanyId(); long groupId = getParentGroupId(entry.getGroupId()); long scopeGroupId = entry.getGroupId(); long userId = entry.getUserId(); String userName = PortalUtil.getUserName(userId, entry.getUserName()); long entryId = entry.getActId(); String title = entry.getTitle(); String content = HtmlUtil.extractText(entry.getDescription()); Date displayDate = entry.getCreateDate(); long[] assetCategoryIds = new long[0]; //AssetCategoryLocalServiceUtil.getCategoryIds( LearningActivity.class.getName(), entryId); String[] assetTagNames =new String[0]; //AssetTagLocalServiceUtil.getTagNames( BlogsEntry.class.getName(), entryId); ExpandoBridge expandoBridge = entry.getExpandoBridge(); Document document = new DocumentImpl(); document.addUID(PORTLET_ID, entryId); document.addModifiedDate(displayDate); document.addKeyword(Field.COMPANY_ID, companyId); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addKeyword(Field.GROUP_ID, groupId); document.addKeyword(Field.SCOPE_GROUP_ID, scopeGroupId); document.addKeyword(Field.USER_ID, userId); document.addText(Field.USER_NAME, userName); document.addText(Field.TITLE, title); document.addText(Field.CONTENT, content); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.ENTRY_CLASS_NAME, LearningActivity.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, entryId); ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge); return document; }catch(Exception e){ e.printStackTrace(); return null; } }
public void updateExtraContentScormActivities (ActionRequest request, ActionResponse response) throws Exception { String updateBD = ParamUtil.getString(request, "updateBD", "false"); List<LearningActivity> learningActivityList = LearningActivityLocalServiceUtil.getLearningActivities(0, LearningActivityLocalServiceUtil.getLearningActivitiesCount()); int conta = 1; String todas ="<p>Actualizado en base de datos:</p>", sqlUpdate = ""; for(LearningActivity activity: learningActivityList) { //Si es un scorm y tiene etiqueta scorm. if (activity.getTypeId() == 9 && activity.getExtracontent().contains("<scorm>")) { String uuid = LearningActivityLocalServiceUtil.getExtraContentValue(activity.getActId(), "uuid"); String openWindow = LearningActivityLocalServiceUtil.getExtraContentValue(activity.getActId(), "openWindow"); String assetEntry = LearningActivityLocalServiceUtil.getExtraContentValue(activity.getActId(), "assetEntry"); if (Validator.isNull(uuid) && Validator.isNotNull(assetEntry) && Validator.isNumber(assetEntry)) { AssetEntry entry = AssetEntryLocalServiceUtil.getEntry(Long.valueOf(assetEntry)); AssetRenderer scorm = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(entry.getClassName()).getAssetRenderer(entry.getClassPK()); uuid = scorm.getUuid(); if (Validator.isNotNull(openWindow)) { String key = "lms.scorm.windowable."+entry.getClassName(); if (Validator.isNull(key)) { key = "false"; } openWindow = PropsUtil.get(key); } } if(updateBD.equals("false")){ //Componemos la consulta para actualizar. String newExtraContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <scorm>"; if (Validator.isNotNull(openWindow)) { newExtraContent += "<openWindow>"+openWindow +"<openWindow/>"; } if (Validator.isNotNull(uuid)) { newExtraContent += "<uuid>"+uuid +"<uuid/>"; } if (Validator.isNotNull(assetEntry)) { newExtraContent += "<assetEntry>"+assetEntry +"</assetEntry>"; } newExtraContent += "</scorm>"; String updateQuery = "UPDATE lms_learningactivity SET extracontent = '"+newExtraContent+"' WHERE actId = "+activity.getActId()+";<br />"; sqlUpdate += HtmlUtil.escape(updateQuery); } //Actualizamos en la bd. else if(updateBD.equals("true")){ //Borramos lo que había. activity.setExtracontent("<scorm></scorm>"); LearningActivityLocalServiceUtil.updateLearningActivity(activity); //Anadimos los campos. LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "openWindow", openWindow); LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "uuid", uuid); LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "assetEntry", assetEntry); todas += "<p>Número: "+ (conta++) +", Activity: "+activity.getTitle(Locale.getDefault())+"<br /> openWindow: " + openWindow+"<br /> uuid: " + uuid+"<br /> assetEntry: " + assetEntry+"</p>"; } } } if(updateBD.equals("true")){ response.setRenderParameter("resultados", todas); }else if(updateBD.equals("false")){ response.setRenderParameter("resultados", sqlUpdate); } }
@SuppressWarnings("unchecked") @Override public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { Map<String, Object> vmVariables = null; if (request.getAttribute(WebKeys.VM_VARIABLES) == null) { vmVariables = new HashMap<String, Object>(); request.setAttribute(WebKeys.VM_VARIABLES, vmVariables); } else { vmVariables = (Map<String,Object>) request.getAttribute(WebKeys.VM_VARIABLES); } String urlImagem = "/e-democracia-theme/images/custom/simbol-edemocracia.png"; String urlImagemThumb = urlImagem; try { ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(td.getScopeGroupId(), 0, "icone"); if (fileEntry != null) { FileVersion versaoAtual = fileEntry.getFileVersion(); if (versaoAtual != null) { String nomeImage = HttpUtil.encodeURL(HtmlUtil.unescape(fileEntry.getTitle()), true); urlImagem = td.getPortalURL() + td.getPathContext() + "/documents/" + fileEntry.getRepositoryId() + "/" + fileEntry.getFolderId() + "/" + nomeImage + "?version=" + versaoAtual.getVersion() + "&t=" + versaoAtual.getModifiedDate().getTime(); urlImagemThumb = urlImagem + "&imageThumbnail=1"; } } } catch (Exception e) { } /* #set($caminhoImg = ) #set($dlService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppLocalService")) #set($imageEntry = $dlService.getFileEntry($themeDisplay.scopeGroupId, 0, "icone")) #if ($imageEntry) #set($fileVersion = $imageEntry.fileVersion) #if ($fileVersion) #set($imageName = $httpUtil.encodeURL($htmlUtil.unescape($imageEntry.title),true)) #set($caminhoImg = $themeDisplay.portalURL + $themeDisplay.pathContext + "/documents/" + $imageEntry.repositoryId + "/" + $imageEntry.folderId + "/" + $imageName + "?version=" + $fileVersion.version + "&t=" + $fileVersion.modifiedDate.time + "&imageThumbnail=1") #end #end */ vmVariables.put("caminho_img", urlImagemThumb); vmVariables.put("caminho_img_orig", urlImagem); }
protected void handleData( StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags, IntegerWrapper marker, BBCodeItem bbCodeItem) { String value = HtmlUtil.escape(bbCodeItem.getValue()); value = handleNewLine(bbCodeItems, tags, marker, value); for (int i = 0; i < _EMOTICONS.length; i++) { String[] emoticon = _EMOTICONS[i]; value = StringUtil.replace(value, emoticon[1], emoticon[0]); } sb.append(value); }
protected void handleImage( StringBundler sb, List<BBCodeItem> bbCodeItems, IntegerWrapper marker) { sb.append("<img src=\""); String src = extractData( bbCodeItems, marker, "img", BBCodeParser.TYPE_DATA, true); Matcher matcher = _imagePattern.matcher(src); if (matcher.matches()) { sb.append(HtmlUtil.escapeAttribute(src)); } sb.append("\" />"); }
public void initLiferay() { new FileUtil().setFile(new FileImpl()); new SAXReaderUtil().setSAXReader(new SAXReaderImpl()); new PortalUtil().setPortal(new PortalImpl()); new HtmlUtil().setHtml(new HtmlImpl()); }