Пример #1
0
  /**
   * {@inheritDoc}
   *
   * @throws DMSException
   * @throws OntologyErrorException
   * @see org.prowim.dms.alfresco.ContentService#uploadDocument(org.prowim.datamodel.dms.Document,
   *     String)
   */
  @Override
  @Interceptors(AuthenticationInterceptor.class)
  public boolean uploadDocument(Document document, String userName)
      throws DMSException, OntologyErrorException {
    Validate.notNull(document);

    ContentServiceSoapBindingStub contentService = getContentService();
    ContentFormat contentFormat =
        new ContentFormat(document.getContentType(), DMSConstants.ENCODING);
    DMSFault dmsFault;

    try {
      if (findFolderOrContent(document.getName()) == null) {
        Reference contentReference =
            this.createReference(document.getName(), organizationEntity.getUser(userName).getID());

        contentService.write(
            contentReference, Constants.PROP_CONTENT, document.getContent(), contentFormat);
        makeVersionable(contentReference);
        return true;
      } else return false;
    } catch (ContentFault e) {
      String message = "Could not create content: ";
      LOG.error(message, e);
      dmsFault = new DMSFault();
      dmsFault.setMessage(message);
      throw new DMSException(message, dmsFault, e.getCause());
    } catch (RemoteException e) {
      String message = "Could not create connection: ";
      LOG.error(message, e);
      dmsFault = new DMSFault();
      dmsFault.setMessage(message);
      throw new DMSException(message, dmsFault, e.getCause());
    }
  }
Пример #2
0
  /**
   * {@inheritDoc}
   *
   * @see org.prowim.dms.alfresco.ContentService#updateDocument(org.prowim.datamodel.dms.Document,
   *     java.lang.String)
   */
  @Override
  @Interceptors(AuthenticationInterceptor.class)
  public void updateDocument(Document document, String userName) throws DMSException {
    Validate.notNull(document);
    Validate.notNull(userName);

    ContentFormat contentFormat =
        new ContentFormat(document.getContentType(), DMSConstants.ENCODING);
    try {
      String uuid = findFolderOrContent(document.getName());
      DocumentIdentification documentIdentification = new DocumentIdentification(uuid, null);
      Content contentRef =
          getContentService()
              .write(
                  this.getReference(
                      documentIdentification.getPath(),
                      documentIdentification.getUuid(),
                      DMSStoreRegistry.STORE_REF),
                  Constants.PROP_CONTENT,
                  document.getContent(),
                  contentFormat);

      createNewVersion(document.getName(), userName, contentRef.getNode().getUuid());
    } catch (ContentFault e) {
      String message = "Could not update content: ";
      LOG.error(message, e);
      DMSFault dmsFault = new DMSFault();
      dmsFault.setMessage(message);
      throw new DMSException(message, dmsFault, e.getCause());
    } catch (RemoteException e) {
      String message = "Could not create connection: ";
      LOG.error(message, e);
      DMSFault dmsFault = new DMSFault();
      dmsFault.setMessage(message);
      throw new DMSException(message, dmsFault, e.getCause());
    } catch (OntologyErrorException e) {
      // TODO $Author: khodaei $ Auto-generated catch block
      LOG.error("Your log-message: ", e);
    }
  }