示例#1
0
 /**
  * {@inheritDoc}
  *
  * @see org.prowim.dms.alfresco.ContentService#deleteContent(java.lang.String)
  */
 @Interceptors(AuthenticationInterceptor.class)
 public void deleteContent(String uuid) throws DMSException {
   Validate.notNull(uuid);
   this.getContentService();
   final Reference reference = new Reference(DMSStoreRegistry.STORE_REF, uuid, null);
   final Predicate predicate = new Predicate(new Reference[] {reference}, null, null);
   final CMLDelete delete = new CMLDelete(predicate);
   final CML cml = new CML();
   cml.setDelete(new CMLDelete[] {delete});
   try {
     WebServiceFactory.getRepositoryService().update(cml);
   } catch (RepositoryFault e) {
     String message = "Could not delete 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());
   }
 }
示例#2
0
  /**
   * {@inheritDoc}
   *
   * @see org.prowim.dms.alfresco.ContentService#createNewVersion(java.lang.String,
   *     java.lang.String, java.lang.String)
   */
  @Interceptors(AuthenticationInterceptor.class)
  public VersionResult createNewVersion(String name, String username, String uuid)
      throws OntologyErrorException, DMSException {
    // get the user
    String userID = organizationEntity.getUser(username).getID();

    AuthoringServiceSoapBindingStub authoringService = WebServiceFactory.getAuthoringService();
    final Reference reference = new Reference(DMSStoreRegistry.STORE_REF, uuid, null);
    final Predicate predicate = new Predicate(new Reference[] {reference}, null, null);
    NamedValue[] comments =
        new NamedValue[] {
          Utils.createNamedValue("description", "User description"),
          Utils.createNamedValue("versionType", "MINOR"),
          Utils.createNamedValue(DMSConstants.Content.AUTHOR_PROP, userID)
        };
    VersionResult vr;
    try {
      vr = authoringService.createVersion(predicate, comments, true);
      String descriptionNew = "This is a sample description for " + name;
      Predicate pred = new Predicate(vr.getNodes(), null, null);

      NamedValue[] titledProps = new NamedValue[2];
      titledProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name);
      titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, descriptionNew);

      CMLUpdate update = new CMLUpdate(titledProps, pred, null);
      CML cml = new CML();
      cml.setUpdate(new CMLUpdate[] {update});

      WebServiceFactory.getRepositoryService().update(cml);

      return vr;
    } catch (AuthoringFault e) {
      LOG.error(
          "Could not create new version in DMS for user " + username + " and UUID " + uuid, e);
    } catch (RemoteException e) {
      LOG.error(
          "Could not create new version in DMS for user " + username + " and UUID " + uuid, e);
    }

    return null;
  }
示例#3
0
  /**
   * Helper method to make apply the versionable aspect to a given reference
   *
   * <p>
   *
   * @param reference the reference
   * @throws Exception can occurs.
   */
  private void makeVersionable(Reference reference) throws RemoteException {
    Validate.notNull(reference);
    /** 1. the add aspect query object. */
    NamedValue[] comments =
        new NamedValue[] {
          Utils.createNamedValue("versionType", "MINOR"),
          Utils.createNamedValue("autoVersion", "false")
        };
    // MAJOR
    Predicate predicate = new Predicate(new Reference[] {reference}, null, null);
    CMLAddAspect addAspect =
        new CMLAddAspect(
            Constants.ASPECT_VERSIONABLE, comments, predicate, null); // ASPECT_VERSIONABLE

    /** 2. Create the content management language query. */
    CML cml = new CML();
    cml.setAddAspect(new CMLAddAspect[] {addAspect});

    /** 3. Execute the query, which will add the versionable aspect to the node is question. */
    this.getRepositoryService().update(cml);
  }