/** * Creates the CMIS property definition for an OpenCms resource property definition.<p> * * @param cmsDef the OpenCms property definition * * @return the CMIS property definition */ PropertyDefinition<?> createOpenCmsPropertyDefinition(CmsPropertyDefinition cmsDef) { return createPropDef( PROPERTY_PREFIX + cmsDef.getName(), cmsDef.getName(), cmsDef.getName(), PropertyType.STRING, Cardinality.SINGLE, Updatability.READWRITE, false, false); }
/** * Gets a list of names of OpenCms property definitions.<p> * * @return the list of OpenCms property names */ public List<String> getCmsPropertyNames() { refresh(); List<String> result = new ArrayList<String>(); for (CmsPropertyDefinition propDef : m_cmsPropertyDefinitions) { result.add(propDef.getName()); } return result; }
/** * Gets the names of all available properties.<p> * * @param cms the CMS context * * @return the list of all property names * * @throws CmsException if something goes wrong */ private List<String> getPropertyNames(CmsObject cms) throws CmsException { List<CmsPropertyDefinition> propDefs = cms.readAllPropertyDefinitions(); List<String> result = new ArrayList<String>(); for (CmsPropertyDefinition propDef : propDefs) { result.add(propDef.getName()); } return result; }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#getDefinedProperties() */ public ArrayList<String> getDefinedProperties() throws CmsRpcException { CmsObject cms = getCmsObject(); try { List<CmsPropertyDefinition> definitions = cms.readAllPropertyDefinitions(); ArrayList<String> result = new ArrayList<String>(); for (CmsPropertyDefinition def : definitions) { result.add(def.getName()); } return result; } catch (Exception e) { error(e); return null; } }
/** * Creates the HTML String for the active properties overview of the current resource.<p> * * @return the HTML output String for active properties of the resource */ public String buildActivePropertiesList() { StringBuffer retValue = new StringBuffer(256); List propertyDef = new ArrayList(); try { // get all property definitions propertyDef = getCms().readAllPropertyDefinitions(); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage()); } } Iterator j = propertyDef.iterator(); int i = 0; while (j.hasNext()) { CmsPropertyDefinition curProperty = (CmsPropertyDefinition)j.next(); retValue.append(CmsEncoder.escapeXml(curProperty.getName())); if ((i + 1) < propertyDef.size()) { retValue.append("<br>"); } i++; } return retValue.toString(); }
/** * Creates the HTML String for the active properties overview of the current resource.<p> * * @return the HTML output String for active properties of the resource */ public String buildActivePropertiesList() { StringBuffer retValue = new StringBuffer(256); List<CmsPropertyDefinition> propertyDef = new ArrayList<CmsPropertyDefinition>(); try { // get all property definitions propertyDef = getCms().readAllPropertyDefinitions(); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage()); } } Iterator<CmsPropertyDefinition> j = propertyDef.iterator(); int i = 0; while (j.hasNext()) { CmsPropertyDefinition curProperty = j.next(); retValue.append(CmsEncoder.escapeXml(curProperty.getName())); if ((i + 1) < propertyDef.size()) { retValue.append("<br>"); } i++; } return retValue.toString(); }
/** * Reads all available properties in the system and returns a config string for a select widget. * <p> * * @return a select widget configuration String for available properties in the system. */ private String getPropertySelectWidgetConfiguration() { String result = ""; CmsObject cms = getCms(); try { List<CmsPropertyDefinition> props = cms.readAllPropertyDefinitions(); StringBuffer buffer = new StringBuffer(); Iterator<CmsPropertyDefinition> it = props.iterator(); CmsPropertyDefinition prop; while (it.hasNext()) { prop = it.next(); buffer.append(prop.getName()); if (it.hasNext()) { buffer.append('|'); } } result = buffer.toString(); } catch (CmsException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_PROPERTYVIEWER_READALLPROPS_0), e); } } return result; }
/** * Adds the CMIS property definitions corresponding to the OpenCms property definitions to a CMIS type definition.<p> * * @param type the type to which the property definitions should be added */ private void addCmsPropertyDefinitions(AbstractTypeDefinition type) { for (CmsPropertyDefinition propDef : m_cmsPropertyDefinitions) { type.addPropertyDefinition(createOpenCmsPropertyDefinition(propDef)); type.addPropertyDefinition( createPropDef( INHERITED_PREFIX + propDef.getName(), propDef.getName(), propDef.getName(), PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false)); } type.addPropertyDefinition( createPropDef( PROPERTY_RESOURCE_TYPE, "Resource type", "Resource type", PropertyType.STRING, Cardinality.SINGLE, Updatability.ONCREATE, false, true)); }
Messages.get().container(Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName()));
Messages.get().container(Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName()));
throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName()));
/** * Returns the count of properties for a property definition.<p> * * @param dbc the current database context * @param propertyDefinition the property definition to test * @param projectId the ID of the current project * * @return the amount of properties for a property definition * @throws CmsDataAccessException if something goes wrong */ protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition propertyDefinition, CmsUUID projectId) throws CmsDataAccessException { int count = 0; try { // create statement Query q = m_sqlManager.createQuery(dbc, projectId, C_PROPERTIES_READALL_COUNT); q.setParameter(1, propertyDefinition.getId().toString()); try { count = CmsDataTypeUtil.numberToInt((Number)q.getSingleResult()); } catch (NoResultException e) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName())); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return count; }
/** * Returns the amount of properties for a propertydefinition.<p> * * @param dbc the current database context * @param metadef the propertydefinition to test * @param projectId the ID of the current project * * @return the amount of properties for a propertydefinition * @throws CmsDataAccessException if something goes wrong */ protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition metadef, CmsUUID projectId) throws CmsDataAccessException { int returnValue; try { // create statement Query q = m_sqlManager.createQuery(dbc, projectId, C_PROPERTIES_READALL_COUNT); q.setParameter(1, metadef.getId().toString()); try { returnValue = CmsDataTypeUtil.numberToInt((Number)q.getSingleResult()); } catch (NoResultException e) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName())); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return returnValue; }
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition Query q = m_sqlManager.createQuery(dbc, C_PROPERTYDEF_DELETE_HISTORY); q.setParameter(1, metadef.getId().toString()); @SuppressWarnings("unchecked") List<CmsDAOHistoryPropertyDef> res = q.getResultList(); for (CmsDAOHistoryPropertyDef hpd : res) { m_sqlManager.remove(dbc, hpd); } } catch (PersistenceException e) { throw new CmsDataAccessException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, Messages.ERR_JPA_PERSITENCE_1), e); } }
Messages.get().container(Messages.ERR_DELETE_USED_PROPERTY_1, metadef.getName()));
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTYDEF_DELETE_HISTORY"); stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } }
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTYDEF_DELETE_HISTORY"); stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException(Messages.get().container( Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } }
Messages.get().container(Messages.ERR_DELETE_USED_PROPERTY_1, metadef.getName()));
metadef.getName()));