示例#1
0
 /**
  * Remove aspect from document or folder
  *
  * @param userName login username
  * @param password login password
  * @param siteName site name
  * @param contentName file or folder name
  * @param aspectToRemove aspect to be removed
  * @throws Exception if error
  */
 public void removeAspect(
     final String userName,
     final String password,
     final String siteName,
     final String contentName,
     DocumentAspect aspectToRemove)
     throws Exception {
   try {
     String contentNodeRef = getNodeRef(userName, password, siteName, contentName);
     Session session = getCMISSession(userName, password);
     CmisObject contentObj = session.getObject(contentNodeRef);
     List<SecondaryType> secondaryTypesList = contentObj.getSecondaryTypes();
     List<String> secondaryTypes = new ArrayList<String>();
     for (SecondaryType secondaryType : secondaryTypesList) {
       secondaryTypes.add(secondaryType.getId());
     }
     secondaryTypes.remove(aspectToRemove.getProperty());
     Map<String, Object> properties = new HashMap<String, Object>();
     {
       properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
     }
     contentObj.updateProperties(properties);
   } catch (CmisInvalidArgumentException ia) {
     throw new CmisRuntimeException("Invalid content " + contentName, ia);
   }
 }
  /** Performs the update. */
  private boolean doUpdate() {
    try {
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      Map<String, Object> properties = new HashMap<String, Object>();
      for (PropertyInputPanel propertyPanel : propertyPanels) {
        if (propertyPanel.includeInUpdate()) {
          properties.put(propertyPanel.getId(), propertyPanel.getValue());
        }
      }

      if (properties.isEmpty()) {
        return false;
      }

      ObjectId newId = object.updateProperties(properties, false);

      if ((newId != null) && newId.getId().equals(model.getCurrentObject().getId())) {
        try {
          model.reloadObject();
          model.reloadFolder();
        } catch (Exception ex) {
          ClientHelper.showError(null, ex);
        }
      }

      return true;
    } catch (Exception ex) {
      ClientHelper.showError(this, ex);
      return false;
    } finally {
      setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
  }