public void init(Object obj) { if (!Config.getBooleanProperty("ENABLE_SCRIPTING", false)) { return; } ViewContext context = (ViewContext) obj; this.request = context.getRequest(); ctx = context.getVelocityContext(); try { host = WebAPILocator.getHostWebAPI().getCurrentHost(request); } catch (PortalException e1) { Logger.error(this, e1.getMessage(), e1); } catch (SystemException e1) { Logger.error(this, e1.getMessage(), e1); } catch (DotDataException e1) { Logger.error(this, e1.getMessage(), e1); } catch (DotSecurityException e1) { Logger.error(this, e1.getMessage(), e1); } userAPI = WebAPILocator.getUserWebAPI(); try { user = userAPI.getLoggedInFrontendUser(request); backuser = userAPI.getLoggedInUser(request); respectFrontendRoles = true; } catch (Exception e) { Logger.error(this, "Error finding the logged in user", e); } }
public CalendarAjax() { eventAPI = APILocator.getEventAPI(); categoryAPI = APILocator.getCategoryAPI(); contAPI = APILocator.getContentletAPI(); userAPI = WebAPILocator.getUserWebAPI(); perAPI = APILocator.getPermissionAPI(); }
public List<NavResult> getChildren() throws Exception { if (children == null && hostId != null && folderId != null) { // lazy loadinge children Host host = APILocator.getHostAPI().find(hostId, sysuser, true); Folder folder = APILocator.getFolderAPI().find(folderId, sysuser, true); Identifier ident = APILocator.getIdentifierAPI().find(folder); NavResult lazyMe = NavTool.getNav(host, ident.getPath()); children = lazyMe.getChildren(); childrenFolderIds = lazyMe.getChildrenFolderIds(); } if (children != null) { ArrayList<NavResult> list = new ArrayList<NavResult>(); for (NavResult nn : children) { if (nn.isFolder()) { // for folders we avoid returning the same instance // it could be changed elsewhere and we need it to // load its children lazily NavResult ff = new NavResult(folderId, nn.hostId, nn.folderId); ff.setTitle(nn.getTitle()); ff.setHref(nn.getHref()); ff.setOrder(nn.getOrder()); ff.setType(nn.getType()); ff.setPermissionId(nn.getPermissionId()); list.add(ff); } else { list.add(nn); } } if (checkPermissions) { // now filtering permissions List<NavResult> allow = new ArrayList<NavResult>(list.size()); Context ctx = (VelocityContext) VelocityServlet.velocityCtx.get(); HttpServletRequest req = (HttpServletRequest) ctx.get("request"); User currentUser = WebAPILocator.getUserWebAPI().getLoggedInUser(req); if (currentUser == null) currentUser = APILocator.getUserAPI().getAnonymousUser(); for (NavResult nv : list) { try { if (APILocator.getPermissionAPI() .doesUserHavePermission(nv, PermissionAPI.PERMISSION_READ, currentUser)) { allow.add(nv); } } catch (Exception ex) { Logger.error(this, ex.getMessage(), ex); } } return allow; } else return list; } else { return new ArrayList<NavResult>(); } }
/** * Workflow actionlet that call the link checker on the given content fields. * * @author Graziano Aliberti - Engineering Ingegneria Informatica * @author Jorge Urdaneta - dotCMS * @date Feb 28, 2012 */ public class CheckURLAccessibilityActionlet extends WorkFlowActionlet { private static final long serialVersionUID = 5110097144813925204L; private static List<WorkflowActionletParameter> paramList = null; private UserWebAPI uWebAPI = WebAPILocator.getUserWebAPI(); @Override public List<WorkflowActionletParameter> getParameters() { try { if (null == paramList) { paramList = new ArrayList<WorkflowActionletParameter>(); paramList.add( new WorkflowActionletParameter( "fieldList", LanguageUtil.get(APILocator.getUserAPI().getSystemUser(), "checkURL.fieldList"), "", true)); } } catch (Exception e) { } return paramList; } @Override public String getName() { return "Link Checker"; } @Override public String getHowTo() { return "This actionlet check the links into the specified fields and reject the content with broken links"; } @Override public void executeAction( WorkflowProcessor processor, Map<String, WorkflowActionClassParameter> params) throws WorkflowActionFailureException { if (LicenseUtil.getLevel() < 200) return; // the apis will do nothing anyway WebContext ctx = WebContextFactory.get(); HttpServletRequest request = ctx.getHttpServletRequest(); User user = null; try { user = uWebAPI.getLoggedInUser(request); } catch (Exception exx) { throw new WorkflowActionFailureException(exx.getMessage()); } Contentlet con = processor.getContentlet(); List<InvalidLink> httpResponse = null; try { httpResponse = APILocator.getLinkCheckerAPI().findInvalidLinks(con); } catch (Exception e1) { Logger.error(this, e1.getMessage(), e1); throw new WorkflowActionFailureException(e1.getMessage()); } // if there are unreachable URL... if (httpResponse.size() > 0) { String msg = ""; try { msg = LanguageUtil.get(user, "checkURL.errorBrokenLinks"); } catch (Exception e) { } throw new WorkflowActionFailureException( LinkCheckerUtil.buildPopupMsgWithLinksList(msg, httpResponse)); } } }
public TemplateAjax() { templateAPI = APILocator.getTemplateAPI(); userWebAPI = WebAPILocator.getUserWebAPI(); hostAPI = APILocator.getHostAPI(); }