/** Test default document content. */
 @Test
 public void testDefaultDocumentContent() {
   final Content content = defaultGroup.getDefaultContent();
   assertEquals(TYPE_DOCUMENT, content.getTypeId());
   final Container rootDocFolder = content.getContainer();
   assertEquals(true, rootDocFolder.isRoot());
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * cc.kune.core.server.content.CreationService#createContent(java.lang.String,
   * java.lang.String, cc.kune.domain.User, cc.kune.domain.Container,
   * java.lang.String)
   */
  @Override
  public Content createContent(
      final String title,
      final String body,
      final User user,
      final Container container,
      final String typeId,
      final WaveRef waveRef,
      final boolean publishExistingWave) {
    final ServerTool tool = tools.get(container.getToolName());
    tool.checkTypesBeforeContentCreation(container.getTypeId(), typeId);
    final URL gagdetUrl =
        tool instanceof ServerToolWithWaveGadget
            ? ((ServerToolWithWaveGadget) tool).getGadgetUrl()
            : KuneWaveService.WITHOUT_GADGET;
    final String[] otherParticipants =
        tool instanceof ServerToolWithWave
            ? ((ServerToolWithWave) tool).getNewContentAdditionalParts(container)
            : NO_MORE_PARTICIPANTS;

    final Content content =
        contentManager.createContent(
            title,
            body,
            publishExistingWave,
            waveRef,
            user,
            container,
            typeId,
            gagdetUrl,
            NO_PROPERTIES,
            otherParticipants);
    tool.onCreateContent(content, container);
    return content;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.content.CreationService#createFolder(cc.kune.domain
  * .Group, java.lang.Long, java.lang.String, cc.kune.domain.I18nLanguage,
  * java.lang.String)
  */
 @Override
 public Container createFolder(
     final Group group,
     final Long parentFolderId,
     final String name,
     final I18nLanguage language,
     final String typeId) {
   final Container parent = containerManager.find(parentFolderId);
   final String toolName = parent.getToolName();
   tools.get(toolName).checkTypesBeforeContainerCreation(parent.getTypeId(), typeId);
   final Container child = containerManager.createFolder(group, parent, name, language, typeId);
   tools.get(toolName).onCreateContainer(child, parent);
   return child;
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.content.CreationService#copyContent(cc.kune.domain.
  * User, cc.kune.domain.Container, cc.kune.domain.Content)
  */
 @Override
 public Content copyContent(
     final User user, final Container container, final Content contentToCopy) {
   final ServerTool tool = tools.get(container.getToolName());
   final Content content = contentManager.copyContent(user, container, contentToCopy);
   tool.onCreateContent(content, container);
   return content;
 }
Beispiel #5
0
  /*
   * (non-Javadoc)
   *
   * @see
   * javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
   * javax.servlet.http.HttpServletResponse)
   */
  @SuppressWarnings("unchecked")
  @Override
  protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
      throws ServletException, IOException {

    final String userHash = req.getParameter(FileConstants.HASH);
    final StateToken token = new StateToken(req.getParameter(FileConstants.TOKEN));

    final Calendar calendar = new Calendar();
    calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(CalScale.GREGORIAN);
    final List<VEvent> events = new ArrayList<VEvent>();

    try {
      final Container cnt = getContainer(userHash, token);
      if (cnt != null && cnt.getTypeId().equals(EventsToolConstants.TYPE_ROOT)) {
        final List<Map<String, String>> listOfProps =
            EventsServerConversionUtil.getAppointmentsUsingCache(cnt);
        for (final Map<String, String> props : listOfProps) {
          try {
            final VEvent vEvent = EventsServerConversionUtil.toVEvent(props);
            events.add(vEvent);
          } catch (final Exception e) {
            LOG.warn("Invalid appointments in " + token, e);
            for (final Entry<String, String> val : props.entrySet()) {
              LOG.warn(String.format("Prop: %s, value: %s", val.getKey(), val.getValue()));
            }
          }
        }
      } else {
        return404(resp);
        return;
      }
      calendar.getComponents().addAll(events);
      resp.setContentType("text/calendar; charset=UTF-8");
      final OutputStream out = resp.getOutputStream();
      final CalendarOutputter outputter = new CalendarOutputter();
      outputter.output(calendar, out);
    } catch (final ContentNotFoundException e) {
      return404(resp);
      return;
    } catch (final ValidationException e) {
      LOG.warn("Invalid calendar conversion in " + token, e);
    }
  }