/* overriden */ public void execute( Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, CoralSession coralSession) throws ProcessingException { String skin = parameters.get("skin"); String app = parameters.get("appName"); String screen = parameters.get("screenName"); String variant = parameters.get("variant", "Default"); String state = parameters.get("state", "Default"); ApplicationResource appRes = integrationService.getApplication(coralSession, app); ScreenResource screenRes = integrationService.getScreen(coralSession, appRes, screen); try { skinService.deleteScreenTemplate( coralSession, getSite(context), skin, screenRes.getApplicationName(), screenRes.getScreenName(), variant, state); } catch (Exception e) { templatingContext.put("result", "exception"); templatingContext.put("trace", new StackTrace(e)); } if (templatingContext.containsKey("result")) { mvcContext.setView("appearance.skin.DeletedScreenTemplate"); } else { templatingContext.put("result", "deleted_successfully"); } }
@Override public void process( Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, I18nContext i18nContext, CoralSession coralSession) throws org.objectledge.pipeline.ProcessingException { IncomingFeedResource feed = null; if (parameters.isDefined(IncomingFeedUtil.FEED_ID_PARAM)) { feed = getIncomingFeed(coralSession, parameters); templatingContext.put("feed", feed); } if (parameters.getBoolean("fromList", false)) { IncomingFeedResourceData.removeData(httpContext, feed); } // WARN: feed may be null -> creation of a new feed IncomingFeedResourceData feedData = IncomingFeedResourceData.getData(httpContext, feed); templatingContext.put("feed_data", feedData); List templates; try { templates = syndicationService.getIncomingFeedsManager().getTransformationTemplates(); } catch (IOException e) { throw new ProcessingException(e); } templatingContext.put("templates", templates); }
/** Performs the action. */ public void execute( Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, CoralSession coralSession) throws ProcessingException { long resClassId = parameters.getLong("res_class_id", -1L); try { ResourceClass resourceClass = coralSession.getSchema().getResourceClass(resClassId); coralSession.getSchema().deleteResourceClass(resourceClass); parameters.remove("res_class_id"); } catch (EntityDoesNotExistException e) { logger.error("ARLException: ", e); templatingContext.put("result", "exception"); // context.put("trace",StringUtils.stackTrace(e)); return; } catch (EntityInUseException e) { logger.error("ARLException: ", e); templatingContext.put("result", "exception"); // context.put("trace",StringUtils.stackTrace(e)); return; } templatingContext.put("result", "deleted_successfully"); }
public void process( Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, I18nContext i18nContext, CoralSession coralSession) throws ProcessingException { try { CmsData cmsData = cmsDataFactory.getCmsData(context); Parameters config = cmsData.getComponent().getConfiguration(); CategoryQueryResource includeQuery = myDocumentsImpl.getQueryResource("include", config); CategoryQueryResource excludeQuery = myDocumentsImpl.getQueryResource("exclude", config); String whereClause = "created_by = " + coralSession.getUserSubject().getIdString(); TableModel<DocumentNodeResource> model; if (includeQuery == null) { model = myDocumentsImpl.siteBasedModel(cmsData, i18nContext.get(), whereClause); } else { model = myDocumentsImpl.queryBasedModel( includeQuery, excludeQuery, cmsData, i18nContext.get(), whereClause); } List<TableFilter<? super DocumentNodeResource>> filters = myDocumentsImpl.excludeStatesFilter("expired"); TableState state = tableStateManager.getState( context, this.getClass().getName() + ":" + cmsData.getNode().getIdString() + ":" + cmsData.getComponent().getInstanceName()); if (state.isNew()) { state.setTreeView(false); state.setSortColumnName(config.get("sort_column", "creation.time")); state.setAscSort(config.getBoolean("sort_dir", false)); state.setPageSize(config.getInt("page_size", 5)); } templatingContext.put("table", new TableTool<DocumentNodeResource>(state, filters, model)); templatingContext.put("documentState", new DocumentStateTool(coralSession, logger)); templatingContext.put("header", config.get("header", "")); final long moreNodeId = config.getLong("more_node_id", -1l); if (moreNodeId != -1l) { templatingContext.put("moreNode", coralSession.getStore().getResource(moreNodeId)); } } catch (Exception e) { throw new ProcessingException("internal errror", e); } }
public void execute( Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, CoralSession coralSession) throws ProcessingException { try { long groupId = parameters.getLong("group_id"); RoleResource group = RoleResourceImpl.getRoleResource(coralSession, groupId); long[] roleIds = parameters.getLongs("role_id"); Set<Role> roles = new HashSet<Role>(); for (int i = 0; i < roleIds.length; i++) { roles.add(coralSession.getSecurity().getRole(roleIds[i])); } long[] selectedRoleIds = parameters.getLongs("selected_role_id"); Set<Role> selectedRoles = new HashSet<Role>(); for (int i = 0; i < selectedRoleIds.length; i++) { selectedRoles.add(coralSession.getSecurity().getRole(selectedRoleIds[i])); } RoleImplication[] roleImplications = group.getRole().getImplications(); Set<Role> currentRoles = new HashSet<Role>(); for (RoleImplication ri : roleImplications) { if (ri.getSuperRole().equals(group.getRole())) { currentRoles.add(ri.getSubRole()); } } CoralSession rootCoralSession = sessionFactory.getRootSession(); try { for (Role role : roles) { if (selectedRoles.contains(role)) { if (!currentRoles.contains(role)) { rootCoralSession.getSecurity().addSubRole(group.getRole(), role); } } else { if (currentRoles.contains(role)) { rootCoralSession.getSecurity().deleteSubRole(group.getRole(), role); } } } } finally { rootCoralSession.close(); } templatingContext.put("result", "updated_successfully"); } catch (Exception e) { templatingContext.put("result", "exception"); templatingContext.put("trace", new StackTrace(e)); } }
@Override public void process(TemplatingContext templatingContext) throws ProcessingException { RequestParameters parameters = RequestParameters.getRequestParameters(context); super.process(templatingContext); if (parameters.get("exportType").equals("full") || parameters.get("exportType").equals("xml")) { templatingContext.put("recordDetails", recordDetailsExport); templatingContext.put("dateConverter", new PatternDateConverter("yyyyMMdd")); } if (parameters.get("exportType").equals("xml")) { HttpContext httpContext = HttpContext.getHttpContext(context); httpContext.setContentType("application/xml"); } }
/** {@inheritDoc} */ public void process( Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, I18nContext i18nContext, CoralSession coralSession) throws ProcessingException { String skin = parameters.get("skin"); String path = parameters.get("path"); SiteResource site = getSite(); path = path.replace(',', '/'); boolean asText = parameters.get("type", "binary").equals("text"); boolean asXML = parameters.get("type", "binary").equals("xml"); try { String contentType; String contents; if (asText) { contentType = "text/plain"; contents = skinService.getContentFileContents(site, skin, path, httpContext.getEncoding()); } else if (asXML) { contentType = "text/xml"; contents = skinService.getContentFileContents(site, skin, path, httpContext.getEncoding()); contents = "<?xml version=\"1.0\" encoding=\"" + httpContext.getEncoding() + "\"?>\n" + "<contents>\n" + " <![CDATA[" + contents + "]]>\n" + "</contents>\n"; } else { contentType = "application/octet-stream"; contents = skinService.getContentFileContents(site, skin, path, httpContext.getEncoding()); } httpContext.disableCache(); httpContext.setResponseLength(StringUtils.getByteCount(contents, httpContext.getEncoding())); fileDownload.dumpData( new ByteArrayInputStream(contents.getBytes(httpContext.getEncoding())), contentType, (new Date()).getTime()); } catch (IOException e) { logger.error("Couldn't write to output", e); } catch (Exception e) { templatingContext.put("errorResult", "result.exception"); templatingContext.put("stackTrace", new StackTrace(e).toStringArray()); logger.error("exception occured", e); } }
public void prepareDefault(Context context) throws ProcessingException { Parameters parameters = RequestParameters.getRequestParameters(context); CoralSession coralSession = (CoralSession) context.getAttribute(CoralSession.class); HttpContext httpContext = HttpContext.getHttpContext(context); I18nContext i18nContext = I18nContext.getI18nContext(context); TemplatingContext templatingContext = TemplatingContext.getTemplatingContext(context); SiteResource site = getSite(); try { templatingContext.put("styles", Arrays.asList(styleService.getStyles(coralSession, site))); long parent_node_id = parameters.getLong("parent_node_id", -1); if (parent_node_id == -1) { templatingContext.put("parent_node", getHomePage()); } else { templatingContext.put( "parent_node", NavigationNodeResourceImpl.getNavigationNodeResource(coralSession, parent_node_id)); } } catch (Exception e) { throw new ProcessingException("Screen Error " + e); } }
// inherit doc public void execute( Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, CoralSession coralSession) throws ProcessingException { try { long periodicalId = parameters.getLong("periodical_id"); PeriodicalResource periodical = null; periodical = PeriodicalResourceImpl.getPeriodicalResource(coralSession, periodicalId); templatingContext.put("periodical", periodical); String recipient = null; if (periodical instanceof EmailPeriodicalResource) { templatingContext.put("isEmail", true); EmailPeriodicalsRootResource emailRoot = (EmailPeriodicalsRootResource) periodical.getParent(); recipient = emailRoot.getPreviewRecipient(); if (recipient != null && recipient.trim().length() == 0) { recipient = null; } templatingContext.put("recipient", recipient); } List<FileResource> results = periodicalsService.publishNow( coralSession, periodical, false, recipient != null, recipient); templatingContext.put("results", results); mvcContext.setView("periodicals.PreviewPeriodical"); } catch (Exception e) { templatingContext.put("result", "exception"); templatingContext.put("trace", new StackTrace(e)); } }
/** Performs the action. */ public void execute( Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, CoralSession coralSession) throws ProcessingException { Subject subject = coralSession.getUserSubject(); IndexResource index = getIndex(coralSession, parameters); try { searchService.getIndexingFacility().deleteDeleted(coralSession, index); } catch (SearchException e) { templatingContext.put("result", "exception"); templatingContext.put("trace", new StackTrace(e)); logger.error("problem incrementally cleaning up index '" + index.getIdString() + "'", e); return; } templatingContext.put("result", "cleaned_up_successfully"); }
public void prepareDefault(Context context) throws ProcessingException { CoralSession coralSession = (CoralSession) context.getAttribute(CoralSession.class); TemplatingContext templatingContext = TemplatingContext.getTemplatingContext(context); super.prepareDefault(context); CmsData cmsData = cmsDataFactory.getCmsData(context); try { EmailPeriodicalsRootResource root = periodicalsService.getEmailPeriodicalsRoot(coralSession, cmsData.getSite()); templatingContext.put("subscriptionNode", root.getSubscriptionNode()); } catch (PeriodicalsException e) { throw new ProcessingException("cannot get email periodicals root", e); } }
/** Performs the action. */ public void execute( Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, CoralSession coralSession) throws ProcessingException { Subject subject = coralSession.getUserSubject(); Long parentNodeId = parameters.getLong("node_id", -1L); Long originalNodeId = parameters.getLong("original_node_id", -1L); String name = parameters.get("name", ""); String title = parameters.get("title", ""); if (parentNodeId == -1L || originalNodeId == -1L) { return; } try { NavigationNodeResource parent = (NavigationNodeResource) coralSession.getStore().getResource(parentNodeId); DocumentNodeResource originalDocument = (DocumentNodeResource) coralSession.getStore().getResource(originalNodeId); DocumentAliasResource node = structureService.addDocumentAlias( coralSession, originalDocument, name, title, parent, subject); parameters.set("node_id", node.getIdString()); } catch (Exception e) { templatingContext.put("result", "exception"); logger.error("StructureException: ", e); templatingContext.put("trace", new StackTrace(e)); return; } cmsDataFactory.removeCmsData(context); templatingContext.put("result", "added_successeditfully"); }
public void process( Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, I18nContext i18nContext, CoralSession coralSession) throws ProcessingException { long fileId = parameters.getLong("item_id", -1); if (fileId == -1) { throw new ProcessingException("File id not found"); } try { templatingContext.put("file", FileResourceImpl.getFileResource(coralSession, fileId)); } catch (EntityDoesNotExistException e) { throw new ProcessingException("failed to retrieve the file resource", e); } }
public void process( Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, I18nContext i18nContext, CoralSession coralSession) throws ProcessingException { try { Parameters componentConfig = getConfiguration(); BannersResource bannersRoot = null; long bannersRootId = componentConfig.getLong("banner.rootId", -1); if (bannersRootId != -1) { bannersRoot = BannersResourceImpl.getBannersResource(coralSession, bannersRootId); } else { if (getSite(context) != null) { bannersRoot = bannerService.getBannersRoot(coralSession, getSite(context)); } } if (bannersRoot != null) { BannerResource bannerResource = bannerService.getBanner(coralSession, bannersRoot, componentConfig); if (bannerResource == null) { templatingContext.remove("banner"); } else { templatingContext.put("banner", bannerResource); } } else { componentError(context, "No site selected"); } } catch (Exception e) { componentError(context, "Exception", e); } }
public void process( Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, I18nContext i18nContext, CoralSession coralSession) throws ProcessingException { SimpleDateFormat df = new SimpleDateFormat(DateAttributeHandler.DATE_TIME_FORMAT); Resource[] states = coralSession .getStore() .getResourceByPath("/cms/workflow/automata/structure.navigation_node/states/*"); templatingContext.put("states", states); SiteResource site = getSite(); // categories CategoryQueryResourceData queryData = CategoryQueryResourceData.getData(httpContext, null); templatingContext.put("query_data", queryData); Set<Long> expandedCategoriesIds = new HashSet<Long>(); // setup pool data and table data if (queryData.isNew()) { queryData.init(coralSession, null, categoryQueryService, integrationService); // prepare expanded categories - includes inherited ones Map initialState = queryData.getCategoriesSelection().getEntities(coralSession); for (Iterator i = initialState.keySet().iterator(); i.hasNext(); ) { CategoryResource category = (CategoryResource) (i.next()); CategoryResource[] cats = categoryService.getImpliedCategories(category, true); for (int j = 0; j < cats.length; j++) { expandedCategoriesIds.add(cats[j].getIdObject()); } } } else { queryData.update(parameters); } // categories prepareGlobalCategoriesTableTool( coralSession, templatingContext, i18nContext, expandedCategoriesIds, false); prepareSiteCategoriesTableTool( coralSession, templatingContext, i18nContext, expandedCategoriesIds, site, false); templatingContext.put( "category_tool", new CategoryInfoTool(context, integrationService, categoryService)); if (parameters.get("show", "").length() == 0) { return; } CategoryQueryBuilder parsedQuery = new CategoryQueryBuilder( coralSession, queryData.getCategoriesSelection(), queryData.useIdsAsIdentifiers()); templatingContext.put("parsed_query", parsedQuery); Resource state = null; Date validityStart = null; Date validityEnd = null; Date createdStart = null; Date createdEnd = null; Subject creator = null; // prepare the conditions... if (parameters.get("validity_start", "").length() > 0) { validityStart = new Date(parameters.getLong("validity_start")); templatingContext.put("validity_start", validityStart); } if (parameters.get("validity_end", "").length() > 0) { validityEnd = new Date(parameters.getLong("validity_end")); templatingContext.put("validity_end", validityEnd); } if (parameters.get("created_start", "").length() > 0) { createdStart = new Date(parameters.getLong("created_start")); templatingContext.put("created_start", createdStart); } if (parameters.get("created_end", "").length() > 0) { createdEnd = new Date(parameters.getLong("created_end")); templatingContext.put("created_end", createdEnd); } String createdBy = parameters.get("created_by", ""); long stateId = parameters.getLong("selected_state", -1); boolean selectedCategory = false; HashSet<Resource> fromCategorySet = new HashSet<Resource>(); int counter = 0; try { if (stateId != -1) { state = coralSession.getStore().getResource(stateId); templatingContext.put("selected_state", state); } String catQuery = parsedQuery.getQuery(); if (catQuery != null && catQuery.length() > 0) { selectedCategory = true; try { Resource[] docs = categoryQueryService.forwardQuery(coralSession, catQuery); for (Resource doc : docs) { fromCategorySet.add(doc); } } catch (Exception e) { throw new ProcessingException("failed to execute category query", e); } } /** * if (parameters.get("category_id","").length() > 0) { long categoryId = * parameters.getLong("category_id", -1); category = * CategoryResourceImpl.getCategoryResource(coralSession, categoryId); * templatingContext.put("category", category); } */ if (createdBy.length() > 0) { try { String dn = userManager.getUserByLogin(createdBy).getName(); creator = coralSession.getSecurity().getSubject(dn); templatingContext.put("created_by", createdBy); } catch (Exception e) { // do nothing...or maybe report that user is unknown! templatingContext.put("result", "unknown_user"); } } } catch (Exception e) { throw new ProcessingException("Exception occured during query preparation"); } boolean nextCondition = false; StringBuilder sb = new StringBuilder("FIND RESOURCE FROM documents.document_node"); if (site != null) { nextCondition = true; sb.append(" WHERE site = "); sb.append(site.getIdString()); } if (state != null) { if (nextCondition) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("state = " + state.getIdString()); nextCondition = true; } if (creator != null) { if (nextCondition) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("created_by = " + creator.getIdString()); nextCondition = true; } if (validityStart != null) { if (nextCondition) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("validityStart > '" + df.format(validityStart) + "'"); nextCondition = true; } if (validityEnd != null) { if (nextCondition) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("validityStart < '" + df.format(validityEnd) + "'"); nextCondition = true; } if (createdStart != null) { if (nextCondition) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("creation_time > '" + df.format(createdStart) + "'"); nextCondition = true; } if (createdEnd != null) { if (nextCondition) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("creation_time < '" + df.format(createdEnd) + "'"); nextCondition = true; } String query = sb.toString(); templatingContext.put("query", query); try { QueryResults results = coralSession.getQuery().executeQuery(query); List<NavigationNodeResource> nodes = (List<NavigationNodeResource>) results.getList(1); if (selectedCategory) { nodes.retainAll(fromCategorySet); } templatingContext.put("counter", nodes.size()); if (site != null) { Map<Subject, StatisticsItem> statistics = new HashMap<Subject, StatisticsItem>(); for (NavigationNodeResource node : nodes) { updateStatistics(statistics, node); } TableModel<StatisticsItem> model = new ListTableModel<StatisticsItem>( new ArrayList<StatisticsItem>(statistics.values()), new BeanTableColumn<StatisticsItem>( StatisticsItem.class, "subject", new NameComparator(i18nContext.getLocale())), new BeanTableColumn<StatisticsItem>(StatisticsItem.class, "redactorCount"), new BeanTableColumn<StatisticsItem>(StatisticsItem.class, "acceptorCount"), new BeanTableColumn<StatisticsItem>(StatisticsItem.class, "editorCount"), new BeanTableColumn<StatisticsItem>(StatisticsItem.class, "creatorCount")); final Role teamMember = site.getTeamMember(); TableFilter<StatisticsItem> teamMemberFilter = new TableFilter<StatisticsItem>() { @Override public boolean accept(StatisticsItem item) { return item.getSubject().hasRole(teamMember); } }; TableState teamState = tableStateManager.getState(context, getClass().getName() + "$team"); if (teamState.isNew()) { teamState.setSortColumnName("subject"); teamState.setPageSize(0); } List<TableFilter<StatisticsItem>> filters = new ArrayList<TableFilter<StatisticsItem>>(); filters.add(teamMemberFilter); TableTool<StatisticsItem> teamTable = new TableTool<StatisticsItem>(teamState, filters, model); templatingContext.put("teamTable", teamTable); TableState nonTeamState = tableStateManager.getState(context, getClass().getName() + "$nonteam"); if (nonTeamState.isNew()) { nonTeamState.setSortColumnName("subject"); nonTeamState.setPageSize(0); } filters.clear(); filters.add(new InverseFilter<StatisticsItem>(teamMemberFilter)); TableTool<StatisticsItem> nonTeamTable = new TableTool<StatisticsItem>(nonTeamState, filters, model); templatingContext.put("nonTeamTable", nonTeamTable); StatisticsItem teamTotals = new StatisticsItem(null); StatisticsItem nonTeamTotals = new StatisticsItem(null); calculateTotals(statistics, teamMember, teamTotals, nonTeamTotals); templatingContext.put("teamTotals", teamTotals); templatingContext.put("nonTeamTotals", nonTeamTotals); } } catch (Exception e) { throw new ProcessingException("Exception occured during query execution", e); } }
@Override protected MultiIndexTableTool createHitsTable( TemplatingContext templatingContext, RequestParameters parameters, Locale locale, Collection<String> indexNames, String page) throws QueryCreationException, TableException { if (!parameters.isDefined("selected")) { QueryCreator queryCreator = queryCreatorFactory.getQueryCreator(parameters, locale); templatingContext.put("queryCreator", queryCreator); TableState state = tableStateManager.getState(context, this.getClass().getCanonicalName()); state.setPageSize(configurator.getPageSize()); if (page == null) state.setCurrentPage(1); else state.setCurrentPage(new Integer(page)); state.setOld(); log.debug("Query: " + queryCreator.getQuery()); List<TableFilter> filters = new ArrayList<TableFilter>(); MultiIndexTableTool hitsTable = (MultiIndexTableTool) searchExecutor.search( indexNames, queryCreator.getQuery(), queryCreator.getSortFields(), state, filters); templatingContext.put("page", page); List<Integer> selected = new LinkedList<Integer>(); for (int i = 0; i < hitsTable.getPageRowCount(); i++) { selected.add(i); templatingContext.put("selected", selected); } return hitsTable; } QueryCreator queryCreator = queryCreatorFactory.getQueryCreator(parameters, locale); templatingContext.put("queryCreator", queryCreator); TableState state = tableStateManager.getState(context, this.getClass().getCanonicalName()); SortedSet<String> selectedItems = new TreeSet<String>(); SortedSet<String> index = new TreeSet<String>(); for (String selected : parameters.getStrings("selected")) { String id = selected.replaceAll("\\.", ""); selectedItems.add(id); index.add(indexIdentifier.identify(id)); } state.setPageSize(0); List<String> indx = new LinkedList<String>(); indx.addAll(index); Collections.sort( indx, new Comparator<String>() { @Override public int compare(String a, String b) { if ("treaties".equals(a)) return -1; if ("treaties".equals(b)) return 1; if ("documents".equals(a)) return -1; if ("documents".equals(b)) return 1; if ("literature".equals(a)) return -1; if ("literature".equals(b)) return 1; if ("courtdecisions".equals(a)) return -1; if ("courtdecisions".equals(b)) return 1; return 1; } }); log.debug("Query: " + queryCreator.getQuery()); List<TableFilter> filters = new ArrayList<TableFilter>(); MultiIndexTableTool table = (MultiIndexTableTool) searchExecutor.search( indx, queryCreator.getQuery(), queryCreator.getSortFields(), state, filters); List<Integer> selected = new LinkedList<Integer>(); for (int i = 0; i < table.getRows().size(); i++) { String id = (String) ((LuceneSearchHit) ((TableRow) table.getRows().get(i)).getObject()).get("id"); if (selectedItems.contains(id)) { selected.add(i); } } templatingContext.put("selected", selected); return table; }