mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1641 (Create Relationship Service)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@85790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1523,4 +1523,59 @@
|
|||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- Relationship Service -->
|
||||||
|
|
||||||
|
<bean id="relationshipService" class="org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipServiceImpl">
|
||||||
|
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService"/>
|
||||||
|
<property name="dictionaryService" ref="DictionaryService" />
|
||||||
|
<property name="namespacePrefixResolver" ref="namespaceService"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="RelationshipService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
|
<property name="proxyInterfaces">
|
||||||
|
<value>org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService</value>
|
||||||
|
</property>
|
||||||
|
<property name="target">
|
||||||
|
<ref bean="relationshipService"/>
|
||||||
|
</property>
|
||||||
|
<property name="interceptorNames">
|
||||||
|
<list>
|
||||||
|
<idref local="RelationshipService_transaction"/>
|
||||||
|
<idref bean="exceptionTranslator"/>
|
||||||
|
<idref local="RelationshipService_security"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="RelationshipService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||||
|
<property name="transactionManager">
|
||||||
|
<ref bean="transactionManager"/>
|
||||||
|
</property>
|
||||||
|
<property name="transactionAttributes">
|
||||||
|
<props>
|
||||||
|
<prop key="*">${server.transaction.mode.default}</prop>
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="RelationshipService_security" parent="baseSecurity">
|
||||||
|
<property name="objectDefinitionSource">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipDefinitions=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipDefinition=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.createRelationshipDefinition=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.updateReleationshipDefinition=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.removeRelationshipDefinition=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.existsRelationshipDefinition=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipsFrom=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipsTo=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.addRelationship=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.removeRelationship=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.*=RM_DENY
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -64,14 +64,13 @@
|
|||||||
|
|
||||||
<!-- Base bean for custom reference definition web scripts -->
|
<!-- Base bean for custom reference definition web scripts -->
|
||||||
<bean id="rmCustomReferenceDefinitionBase" parent="rmBaseWebscript" abstract="true">
|
<bean id="rmCustomReferenceDefinitionBase" parent="rmBaseWebscript" abstract="true">
|
||||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
<property name="relationshipService" ref="RelationshipService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- REST impl for GET Custom Reference Definitions -->
|
<!-- REST impl for GET Custom Reference Definitions -->
|
||||||
<bean id="webscript.org.alfresco.rma.customrefdefinitions.get"
|
<bean id="webscript.org.alfresco.rma.customrefdefinitions.get"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomReferenceDefinitionsGet"
|
class="org.alfresco.module.org_alfresco_module_rm.script.CustomReferenceDefinitionsGet"
|
||||||
parent="rmCustomReferenceDefinitionBase">
|
parent="rmCustomReferenceDefinitionBase">
|
||||||
<property name="dictionaryService" ref="DictionaryService" />
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- REST impl for PUT Custom Reference Definitions -->
|
<!-- REST impl for PUT Custom Reference Definitions -->
|
||||||
@@ -88,8 +87,7 @@
|
|||||||
<bean id="webscript.org.alfresco.rma.customrefs.get"
|
<bean id="webscript.org.alfresco.rma.customrefs.get"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefsGet"
|
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefsGet"
|
||||||
parent="rmBaseWebscript">
|
parent="rmBaseWebscript">
|
||||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
<property name="relationshipService" ref="RelationshipService" />
|
||||||
<property name="dictionaryService" ref="DictionaryService" />
|
|
||||||
<property name="capabilityService" ref="CapabilityService" />
|
<property name="capabilityService" ref="CapabilityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
@@ -97,7 +95,7 @@
|
|||||||
<bean id="webscript.org.alfresco.rma.customref.post"
|
<bean id="webscript.org.alfresco.rma.customref.post"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefPost"
|
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefPost"
|
||||||
parent="rmBaseWebscript">
|
parent="rmBaseWebscript">
|
||||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
<property name="relationshipService" ref="RelationshipService" />
|
||||||
<property name="ruleService" ref="RuleService" />
|
<property name="ruleService" ref="RuleService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
@@ -105,7 +103,7 @@
|
|||||||
<bean id="webscript.org.alfresco.rma.customref.delete"
|
<bean id="webscript.org.alfresco.rma.customref.delete"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefDelete"
|
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefDelete"
|
||||||
parent="rmBaseWebscript">
|
parent="rmBaseWebscript">
|
||||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
<property name="relationshipService" ref="RelationshipService" />
|
||||||
<property name="ruleService" ref="RuleService" />
|
<property name="ruleService" ref="RuleService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface representing the relationship
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public interface Relationship
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Gets the unique name of the relationship
|
||||||
|
*
|
||||||
|
* @return The unique name of the relationship
|
||||||
|
*/
|
||||||
|
String getUniqueName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the source of the relationship
|
||||||
|
*
|
||||||
|
* @return The source of the relationship
|
||||||
|
*/
|
||||||
|
NodeRef getSource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the target of the relationship
|
||||||
|
*
|
||||||
|
* @return The target of the relationship
|
||||||
|
*/
|
||||||
|
NodeRef getTarget();
|
||||||
|
}
|
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface representing the relationship definition
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public interface RelationshipDefinition
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Gets the unique name of the relationship definition
|
||||||
|
*
|
||||||
|
* @return The unique name of the relationship definition
|
||||||
|
*/
|
||||||
|
String getUniqueName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of the relationship definition
|
||||||
|
*
|
||||||
|
* @return The type of the relationship definition
|
||||||
|
*/
|
||||||
|
RelationshipType getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the display name of the relationship definition
|
||||||
|
*
|
||||||
|
* @return The display name of the relationship definition
|
||||||
|
*/
|
||||||
|
RelationshipDisplayName getDisplayName();
|
||||||
|
}
|
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relationship definition implementation
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public class RelationshipDefinitionImpl implements RelationshipDefinition
|
||||||
|
{
|
||||||
|
/** The unique name of the relationship definition */
|
||||||
|
private String uniqueName;
|
||||||
|
|
||||||
|
/** The type of the relationship definition */
|
||||||
|
private RelationshipType type;
|
||||||
|
|
||||||
|
/** The display name of the relationship definition */
|
||||||
|
private RelationshipDisplayName displayName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating a relationship definition
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship definition
|
||||||
|
* @param type The type of the relationship definition
|
||||||
|
* @param displayName The display name of the relationship definition
|
||||||
|
*/
|
||||||
|
public RelationshipDefinitionImpl(String uniqueName, RelationshipType type, RelationshipDisplayName displayName)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
mandatory("type", type);
|
||||||
|
mandatory("displayName", displayName);
|
||||||
|
|
||||||
|
setUniqueName(uniqueName);
|
||||||
|
setType(type);
|
||||||
|
setDisplayName(displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getUniqueName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getUniqueName()
|
||||||
|
{
|
||||||
|
return this.uniqueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the relationship definition
|
||||||
|
*
|
||||||
|
* @param uniqueName The name of the relationship definition
|
||||||
|
*/
|
||||||
|
private void setUniqueName(String uniqueName)
|
||||||
|
{
|
||||||
|
this.uniqueName = uniqueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RelationshipType getType()
|
||||||
|
{
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type of the relationship definition
|
||||||
|
*
|
||||||
|
* @param type The type of the relationship definition
|
||||||
|
*/
|
||||||
|
private void setType(RelationshipType type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getDisplayName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RelationshipDisplayName getDisplayName()
|
||||||
|
{
|
||||||
|
return this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display name of the relationship definition
|
||||||
|
*
|
||||||
|
* @param displayName The display name of the relationship definition
|
||||||
|
*/
|
||||||
|
private void setDisplayName(RelationshipDisplayName displayName)
|
||||||
|
{
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POJO representing the relationship display name
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public class RelationshipDisplayName
|
||||||
|
{
|
||||||
|
/** The label text for {@link RelationshipType#BIDIRECTIONAL} */
|
||||||
|
private String labelText;
|
||||||
|
|
||||||
|
/** The source text for {@link RelationshipType#PARENTCHILD} */
|
||||||
|
private String sourceText;
|
||||||
|
|
||||||
|
/** The target text for {@link RelationshipType#PARENTCHILD} */
|
||||||
|
private String targetText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating the relationship display name
|
||||||
|
*
|
||||||
|
* @param sourceText The source text of the relationship definition
|
||||||
|
* @param targetText The target text of the relationship definition
|
||||||
|
* @param labelText The label text of the relationship definition
|
||||||
|
*/
|
||||||
|
public RelationshipDisplayName(String sourceText, String targetText, String labelText)
|
||||||
|
{
|
||||||
|
// Parameters might be blank. No check required.
|
||||||
|
|
||||||
|
setSourceText(sourceText);
|
||||||
|
setTargetText(targetText);
|
||||||
|
setLabelText(labelText);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||||
|
*
|
||||||
|
* @return The label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||||
|
*/
|
||||||
|
public String getLabelText()
|
||||||
|
{
|
||||||
|
return this.labelText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||||
|
*
|
||||||
|
* @param labelText The label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||||
|
*/
|
||||||
|
private void setLabelText(String labelText)
|
||||||
|
{
|
||||||
|
this.labelText = labelText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the source text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*
|
||||||
|
* @return The source text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*/
|
||||||
|
public String getSourceText()
|
||||||
|
{
|
||||||
|
return this.sourceText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the source text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*
|
||||||
|
* @param sourceText The source text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*/
|
||||||
|
private void setSourceText(String sourceText)
|
||||||
|
{
|
||||||
|
this.sourceText = sourceText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the target text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*
|
||||||
|
* @return The target text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*/
|
||||||
|
public String getTargetText()
|
||||||
|
{
|
||||||
|
return this.targetText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the target text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*
|
||||||
|
* @param targetText The target text of {@link RelationshipType#PARENTCHILD}
|
||||||
|
*/
|
||||||
|
private void setTargetText(String targetText)
|
||||||
|
{
|
||||||
|
this.targetText = targetText;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relationship implementation
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public class RelationshipImpl implements Relationship
|
||||||
|
{
|
||||||
|
/** The unique name of the relationship */
|
||||||
|
private String uniqueName;
|
||||||
|
|
||||||
|
/** The source of the relationship */
|
||||||
|
private NodeRef source;
|
||||||
|
|
||||||
|
/** The target of the relationship */
|
||||||
|
private NodeRef target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating a relationship
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship
|
||||||
|
* @param source The source of the relationship
|
||||||
|
* @param target The target of the relationship
|
||||||
|
*/
|
||||||
|
public RelationshipImpl(String uniqueName, NodeRef source, NodeRef target)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
mandatory("source", source);
|
||||||
|
mandatory("target", target);
|
||||||
|
|
||||||
|
setUniqueName(uniqueName);
|
||||||
|
setSource(source);
|
||||||
|
setTarget(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getUniqueName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getUniqueName()
|
||||||
|
{
|
||||||
|
return uniqueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the unique name of the relationship
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship
|
||||||
|
*/
|
||||||
|
private void setUniqueName(String uniqueName)
|
||||||
|
{
|
||||||
|
this.uniqueName = uniqueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getSource()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public NodeRef getSource()
|
||||||
|
{
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the source of the relationship
|
||||||
|
*
|
||||||
|
* @param source The source of the relationship
|
||||||
|
*/
|
||||||
|
private void setSource(NodeRef source)
|
||||||
|
{
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getTarget()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public NodeRef getTarget()
|
||||||
|
{
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the target of the relationship
|
||||||
|
*
|
||||||
|
* @param target The target of the relationship
|
||||||
|
*/
|
||||||
|
private void setTarget(NodeRef target)
|
||||||
|
{
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationship service interface
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public interface RelationshipService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Gets all the existing relationship definitions
|
||||||
|
*
|
||||||
|
* @return All existing relationship definitions
|
||||||
|
*/
|
||||||
|
Set<RelationshipDefinition> getRelationshipDefinitions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the relationship definition for the given unique name
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship definition
|
||||||
|
* @return The relationship definition for the given unique name if it exist, <code>null</code> otherwise
|
||||||
|
*/
|
||||||
|
RelationshipDefinition getRelationshipDefinition(String uniqueName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a relationship definition using the display name
|
||||||
|
*
|
||||||
|
* @param displayName The display name of the relationship definition
|
||||||
|
* @return The new relationship definition
|
||||||
|
*/
|
||||||
|
RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing relationship definition
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship definition
|
||||||
|
* @param displayName The display name of the relationship definition
|
||||||
|
* @return The updated relationship definition
|
||||||
|
*/
|
||||||
|
RelationshipDefinition updateReleationshipDefinition(String uniqueName, RelationshipDisplayName displayName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a relationship definition
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship definition
|
||||||
|
* @return <code>true</code> if the relationship definition was removed successfully, <code>false</code> otherwise
|
||||||
|
*/
|
||||||
|
boolean removeRelationshipDefinition(String uniqueName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a relationship exists or not
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship definition
|
||||||
|
* @return <code>true</code> if the relationship definition exists, <code>false</code> otherwise
|
||||||
|
*/
|
||||||
|
boolean existsRelationshipDefinition(String uniqueName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the relationships that come out from the given node reference
|
||||||
|
*
|
||||||
|
* @param nodeRef The node reference
|
||||||
|
* @return All relationships that come out from the given node reference
|
||||||
|
*/
|
||||||
|
Set<Relationship> getRelationshipsFrom(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the relationships that go in to the given node reference
|
||||||
|
*
|
||||||
|
* @param nodeRef The node reference
|
||||||
|
* @return All relationships that go in to the given node reference
|
||||||
|
*/
|
||||||
|
Set<Relationship> getRelationshipsTo(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a relationship from the given node <code>source</code>
|
||||||
|
* to the give node <code>target</code> with the given unique name
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship
|
||||||
|
* @param source The node reference which the relationship come from
|
||||||
|
* @param target The node reference which the relationship go to
|
||||||
|
*/
|
||||||
|
void addRelationship(String uniqueName, NodeRef source, NodeRef target);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the relationship from the given node <code>source</code>
|
||||||
|
* to the given node <code>target</code> with the given unique name
|
||||||
|
*
|
||||||
|
* @param uniqueName The unique name of the relationship
|
||||||
|
* @param source The node reference which the relationship come from
|
||||||
|
* @param target The node reference which the relationship go to
|
||||||
|
*/
|
||||||
|
void removeRelationship(String uniqueName, NodeRef source, NodeRef target);
|
||||||
|
}
|
@@ -0,0 +1,551 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||||
|
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||||
|
import static org.apache.commons.lang.StringUtils.isBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationship service implementation
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public class RelationshipServiceImpl implements RelationshipService
|
||||||
|
{
|
||||||
|
/** Records management admin service */
|
||||||
|
private RecordsManagementAdminService recordsManagementAdminService;
|
||||||
|
|
||||||
|
/** Dictionary service */
|
||||||
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
|
/** Namespace prefix resolver */
|
||||||
|
private NamespacePrefixResolver namespacePrefixResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the records management admin service instance
|
||||||
|
*
|
||||||
|
* @return The records management admin service instance
|
||||||
|
*/
|
||||||
|
protected RecordsManagementAdminService getRecordsManagementAdminService()
|
||||||
|
{
|
||||||
|
return this.recordsManagementAdminService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the records management admin service instance
|
||||||
|
*
|
||||||
|
* @param recordsManagementAdminService The records management admin service instance
|
||||||
|
*/
|
||||||
|
public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService)
|
||||||
|
{
|
||||||
|
this.recordsManagementAdminService = recordsManagementAdminService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the dictionary service instance
|
||||||
|
*
|
||||||
|
* @return The dictionary service instance
|
||||||
|
*/
|
||||||
|
protected DictionaryService getDictionaryService()
|
||||||
|
{
|
||||||
|
return this.dictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the dictionary service instance
|
||||||
|
*
|
||||||
|
* @param dictionaryService The dictionary service instance
|
||||||
|
*/
|
||||||
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
|
{
|
||||||
|
this.dictionaryService = dictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the namespace prefix resolver instance
|
||||||
|
*
|
||||||
|
* @return The namespace prefix resolver instance
|
||||||
|
*/
|
||||||
|
protected NamespacePrefixResolver getNamespacePrefixResolver()
|
||||||
|
{
|
||||||
|
return this.namespacePrefixResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the namespace prefix resolver instance
|
||||||
|
*
|
||||||
|
* @param namespacePrefixResolver The namespace prefix resolver instance
|
||||||
|
*/
|
||||||
|
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
|
||||||
|
{
|
||||||
|
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinitions()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<RelationshipDefinition> getRelationshipDefinitions()
|
||||||
|
{
|
||||||
|
Set<RelationshipDefinition> relationshipDefinitions = new HashSet<RelationshipDefinition>();
|
||||||
|
|
||||||
|
Map<QName, AssociationDefinition> customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||||
|
for (Map.Entry<QName, AssociationDefinition> customReferenceDefinitionEntry : customReferenceDefinitions.entrySet())
|
||||||
|
{
|
||||||
|
AssociationDefinition associationDefinition = customReferenceDefinitionEntry.getValue();
|
||||||
|
RelationshipDefinition relationshipDefinition = createRelationshipDefinition(associationDefinition);
|
||||||
|
if (relationshipDefinition != null)
|
||||||
|
{
|
||||||
|
relationshipDefinitions.add(relationshipDefinition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationshipDefinitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RelationshipDefinition getRelationshipDefinition(String uniqueName)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
|
||||||
|
RelationshipDefinition relationshipDefinition = null;
|
||||||
|
|
||||||
|
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||||
|
if (associationDefinitionQName != null)
|
||||||
|
{
|
||||||
|
AssociationDefinition associationDefinition = getRecordsManagementAdminService().getCustomReferenceDefinitions().get(associationDefinitionQName);
|
||||||
|
relationshipDefinition = createRelationshipDefinition(associationDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationshipDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName)
|
||||||
|
{
|
||||||
|
mandatory("displayName", displayName);
|
||||||
|
|
||||||
|
RelationshipType type = determineRelationshipTypeFromDisplayName(displayName);
|
||||||
|
|
||||||
|
QName relationshipDefinitionQName;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BIDIRECTIONAL:
|
||||||
|
|
||||||
|
String labelText = displayName.getLabelText();
|
||||||
|
relationshipDefinitionQName = getRecordsManagementAdminService().addCustomAssocDefinition(labelText);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARENTCHILD:
|
||||||
|
|
||||||
|
String sourceText = displayName.getSourceText();
|
||||||
|
String targetText = displayName.getTargetText();
|
||||||
|
relationshipDefinitionQName = getRecordsManagementAdminService().addCustomChildAssocDefinition(sourceText, targetText);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unsupported relationship type: '")
|
||||||
|
.append(type.toString())
|
||||||
|
.append("'.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
String uniqueName = relationshipDefinitionQName.getLocalName();
|
||||||
|
|
||||||
|
return new RelationshipDefinitionImpl(uniqueName, type, displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#updateReleationshipDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RelationshipDefinition updateReleationshipDefinition(String uniqueName, RelationshipDisplayName displayName)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
|
||||||
|
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||||
|
if (associationDefinitionQName == null)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("The qualified name for '")
|
||||||
|
.append(uniqueName)
|
||||||
|
.append("' was not found.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<QName, AssociationDefinition> customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||||
|
AssociationDefinition associationDefinition = customReferenceDefinitions.get(associationDefinitionQName);
|
||||||
|
RelationshipType type = getRelationshipType(associationDefinition);
|
||||||
|
QName updatedAssociationDefinitionQName;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BIDIRECTIONAL:
|
||||||
|
|
||||||
|
String labelText = displayName.getLabelText();
|
||||||
|
|
||||||
|
if (isBlank(labelText))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Label text '")
|
||||||
|
.append(labelText)
|
||||||
|
.append(" cannot be blank.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedAssociationDefinitionQName = getRecordsManagementAdminService().updateCustomAssocDefinition(associationDefinitionQName, labelText);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARENTCHILD:
|
||||||
|
|
||||||
|
String sourceText = displayName.getSourceText();
|
||||||
|
String targetText = displayName.getTargetText();
|
||||||
|
|
||||||
|
if (isBlank(sourceText) || isBlank(targetText))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Neither source text '")
|
||||||
|
.append(sourceText)
|
||||||
|
.append("' nor target text '")
|
||||||
|
.append(targetText)
|
||||||
|
.append(" can be blank.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedAssociationDefinitionQName = getRecordsManagementAdminService().updateCustomChildAssocDefinition(associationDefinitionQName, sourceText, targetText);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unsupported relationship type: '")
|
||||||
|
.append(type.toString())
|
||||||
|
.append("'.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||||
|
AssociationDefinition updatedAssociationDefinition = customReferenceDefinitions.get(updatedAssociationDefinitionQName);
|
||||||
|
RelationshipDefinition updatedRelationshipDefinition = createRelationshipDefinition(updatedAssociationDefinition);
|
||||||
|
if (updatedRelationshipDefinition == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("The relationship definition was not updated successfully.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return updatedRelationshipDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationshipDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean removeRelationshipDefinition(String uniqueName)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
|
||||||
|
// FIXME!!! There is no method on the backend for this. Must be implemented.
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#existsRelationshipDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean existsRelationshipDefinition(String uniqueName)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
|
||||||
|
boolean exists = false;
|
||||||
|
|
||||||
|
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||||
|
if (associationDefinitionQName != null)
|
||||||
|
{
|
||||||
|
Map<QName, AssociationDefinition> customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||||
|
exists = customReferenceDefinitions.containsKey(associationDefinitionQName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsFrom(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<Relationship> getRelationshipsFrom(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
mandatory("nodeRef", nodeRef);
|
||||||
|
|
||||||
|
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||||
|
|
||||||
|
List<AssociationRef> customReferencesFrom = getRecordsManagementAdminService().getCustomReferencesFrom(nodeRef);
|
||||||
|
relationships.addAll(generateRelationshipFromAssociationRef(customReferencesFrom));
|
||||||
|
|
||||||
|
List<ChildAssociationRef> customChildReferences = getRecordsManagementAdminService().getCustomChildReferences(nodeRef);
|
||||||
|
relationships.addAll(generateRelationshipFromParentChildAssociationRef(customChildReferences));
|
||||||
|
|
||||||
|
return relationships;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsTo(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<Relationship> getRelationshipsTo(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
mandatory("nodeRef", nodeRef);
|
||||||
|
|
||||||
|
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||||
|
|
||||||
|
List<AssociationRef> customReferencesTo = getRecordsManagementAdminService().getCustomReferencesTo(nodeRef);
|
||||||
|
relationships.addAll(generateRelationshipFromAssociationRef(customReferencesTo));
|
||||||
|
|
||||||
|
List<ChildAssociationRef> customParentReferences = getRecordsManagementAdminService().getCustomParentReferences(nodeRef);
|
||||||
|
relationships.addAll(generateRelationshipFromParentChildAssociationRef(customParentReferences));
|
||||||
|
|
||||||
|
return relationships;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#addRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addRelationship(String uniqueName, NodeRef source, NodeRef target)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
mandatory("source", source);
|
||||||
|
mandatory("target", target);
|
||||||
|
|
||||||
|
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||||
|
getRecordsManagementAdminService().addCustomReference(source, target, associationDefinitionQName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeRelationship(String uniqueName, NodeRef source, NodeRef target)
|
||||||
|
{
|
||||||
|
mandatoryString("uniqueName", uniqueName);
|
||||||
|
mandatory("source", source);
|
||||||
|
mandatory("target", target);
|
||||||
|
|
||||||
|
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||||
|
getRecordsManagementAdminService().removeCustomReference(source, target, associationDefinitionQName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the relationship definition from the association definition
|
||||||
|
*
|
||||||
|
* @param associationDefinition The association definition
|
||||||
|
* @return The relationship definition if <code>associationDefinition</code> exists, <code>null</code> otherwise
|
||||||
|
*/
|
||||||
|
private RelationshipDefinition createRelationshipDefinition(AssociationDefinition associationDefinition)
|
||||||
|
{
|
||||||
|
RelationshipDefinition relationshipDefinition = null;
|
||||||
|
|
||||||
|
if (associationDefinition != null)
|
||||||
|
{
|
||||||
|
String uniqueName = associationDefinition.getName().getLocalName();
|
||||||
|
|
||||||
|
RelationshipType type = getRelationshipType(associationDefinition);
|
||||||
|
|
||||||
|
String title = associationDefinition.getTitle(getDictionaryService());
|
||||||
|
RelationshipDisplayName displayName = getRelationshipDisplayName(type, title);
|
||||||
|
|
||||||
|
relationshipDefinition = new RelationshipDefinitionImpl(uniqueName, type, displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationshipDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the relationship type from the association definition
|
||||||
|
*
|
||||||
|
* @param associationDefinition The association definition
|
||||||
|
* @return The type of the relationship definition
|
||||||
|
*/
|
||||||
|
private RelationshipType getRelationshipType(AssociationDefinition associationDefinition)
|
||||||
|
{
|
||||||
|
RelationshipType type;
|
||||||
|
|
||||||
|
if (associationDefinition instanceof ChildAssociationDefinition)
|
||||||
|
{
|
||||||
|
type = RelationshipType.PARENTCHILD;
|
||||||
|
}
|
||||||
|
else if (associationDefinition instanceof AssociationDefinition)
|
||||||
|
{
|
||||||
|
type = RelationshipType.BIDIRECTIONAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unsupported association definition: '")
|
||||||
|
.append(associationDefinition.getName().getLocalName())
|
||||||
|
.append("'.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the relationship display name of the relationship definition
|
||||||
|
*
|
||||||
|
* @param type The type of the relationship definition
|
||||||
|
* @param title The title of the association definition
|
||||||
|
* @return The relationship display name of the relationship definition
|
||||||
|
*/
|
||||||
|
private RelationshipDisplayName getRelationshipDisplayName(RelationshipType type, String title)
|
||||||
|
{
|
||||||
|
String sourceText = null;
|
||||||
|
String targetText = null;
|
||||||
|
String labelText = null;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BIDIRECTIONAL:
|
||||||
|
|
||||||
|
labelText = title;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARENTCHILD:
|
||||||
|
|
||||||
|
String[] sourceAndTarget = getRecordsManagementAdminService().splitSourceTargetId(title);
|
||||||
|
sourceText = sourceAndTarget[0];
|
||||||
|
targetText = sourceAndTarget[1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unsupported relationship type: '")
|
||||||
|
.append(type.toString())
|
||||||
|
.append("'.");
|
||||||
|
throw new AlfrescoRuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RelationshipDisplayName(sourceText, targetText, labelText);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates relationships from the given association references
|
||||||
|
*
|
||||||
|
* @param associationRefs Association references
|
||||||
|
* @return Relationships generated from the given association references
|
||||||
|
*/
|
||||||
|
private Set<Relationship> generateRelationshipFromAssociationRef(List<AssociationRef> associationRefs)
|
||||||
|
{
|
||||||
|
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||||
|
|
||||||
|
for (AssociationRef associationRef : associationRefs)
|
||||||
|
{
|
||||||
|
String uniqueName = associationRef.getTypeQName().getLocalName();
|
||||||
|
NodeRef from = associationRef.getSourceRef();
|
||||||
|
NodeRef to = associationRef.getTargetRef();
|
||||||
|
relationships.add(new RelationshipImpl(uniqueName, from, to));
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationships;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates relationships from the given child association references
|
||||||
|
*
|
||||||
|
* @param childAssociationRefs Child association references
|
||||||
|
* @return Relationships generated from the given child association references
|
||||||
|
*/
|
||||||
|
private Set<Relationship> generateRelationshipFromParentChildAssociationRef(List<ChildAssociationRef> childAssociationRefs)
|
||||||
|
{
|
||||||
|
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||||
|
|
||||||
|
for (ChildAssociationRef childAssociationRef : childAssociationRefs)
|
||||||
|
{
|
||||||
|
String uniqueName = childAssociationRef.getQName().getLocalName();
|
||||||
|
NodeRef from = childAssociationRef.getParentRef();
|
||||||
|
NodeRef to = childAssociationRef.getChildRef();
|
||||||
|
relationships.add(new RelationshipImpl(uniqueName, from, to));
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationships;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the relationship type from the display name
|
||||||
|
*
|
||||||
|
* @param displayName The display name of the relationship
|
||||||
|
* @return The relationship type from the display name
|
||||||
|
*/
|
||||||
|
private RelationshipType determineRelationshipTypeFromDisplayName(RelationshipDisplayName displayName)
|
||||||
|
{
|
||||||
|
RelationshipType relationshipType;
|
||||||
|
|
||||||
|
String labelText = displayName.getLabelText();
|
||||||
|
String sourceText = displayName.getSourceText();
|
||||||
|
String targetText = displayName.getTargetText();
|
||||||
|
|
||||||
|
String errorMsg = "Relationship type could not be determined from the display name. It is neither biderectional nor parent/child relationship";
|
||||||
|
|
||||||
|
if (isBlank(labelText))
|
||||||
|
{
|
||||||
|
if (isBlank(sourceText) || isBlank(targetText))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(errorMsg);
|
||||||
|
}
|
||||||
|
relationshipType = RelationshipType.PARENTCHILD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isNotBlank(sourceText) || isNotBlank(targetText))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(errorMsg);
|
||||||
|
}
|
||||||
|
relationshipType = RelationshipType.BIDIRECTIONAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationshipType;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum representing the relationship types
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public enum RelationshipType
|
||||||
|
{
|
||||||
|
BIDIRECTIONAL,
|
||||||
|
PARENTCHILD;
|
||||||
|
}
|
@@ -34,7 +34,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for all RM webscript classes.
|
* Abstract base class for all RM webscript classes.
|
||||||
* Includes util methods for processing the webscript request.
|
* Includes utility methods for processing the webscript request.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
* @author Tuna Aksoy
|
* @author Tuna Aksoy
|
||||||
@@ -43,21 +43,34 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
/** Constants */
|
/** Constants */
|
||||||
protected static final String PATH_SEPARATOR = "/";
|
protected static final String PATH_SEPARATOR = "/";
|
||||||
|
protected static final String STORE_TYPE = "store_type";
|
||||||
|
protected static final String STORE_ID = "store_id";
|
||||||
|
protected static final String ID = "id";
|
||||||
protected static final String SUCCESS = "success";
|
protected static final String SUCCESS = "success";
|
||||||
|
|
||||||
/** Disposition service */
|
/** Disposition service */
|
||||||
protected DispositionService dispositionService;
|
private DispositionService dispositionService;
|
||||||
|
|
||||||
/** Namespace service */
|
/** Namespace service */
|
||||||
protected NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
|
|
||||||
/** Node service */
|
/** Node service */
|
||||||
protected NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the disposition service
|
* Gets the disposition service instance
|
||||||
*
|
*
|
||||||
* @param dispositionService The disposition serviceS
|
* @return The disposition service instance
|
||||||
|
*/
|
||||||
|
protected DispositionService getDispositionService()
|
||||||
|
{
|
||||||
|
return this.dispositionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the disposition service instance
|
||||||
|
*
|
||||||
|
* @param dispositionService The disposition service instance
|
||||||
*/
|
*/
|
||||||
public void setDispositionService(DispositionService dispositionService)
|
public void setDispositionService(DispositionService dispositionService)
|
||||||
{
|
{
|
||||||
@@ -65,9 +78,19 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the namespace service
|
* Gets the namespace service instance
|
||||||
*
|
*
|
||||||
* @param namespaceService The namespace service
|
* @return The namespace service instance
|
||||||
|
*/
|
||||||
|
protected NamespaceService getNamespaceService()
|
||||||
|
{
|
||||||
|
return this.namespaceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the namespace service instance
|
||||||
|
*
|
||||||
|
* @param namespaceService The namespace service instance
|
||||||
*/
|
*/
|
||||||
public void setNamespaceService(NamespaceService namespaceService)
|
public void setNamespaceService(NamespaceService namespaceService)
|
||||||
{
|
{
|
||||||
@@ -75,9 +98,19 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the node service
|
* Gets the node service instance
|
||||||
*
|
*
|
||||||
* @param nodeService The node service
|
* @return The node service instance
|
||||||
|
*/
|
||||||
|
protected NodeService getNodeService()
|
||||||
|
{
|
||||||
|
return this.nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the node service instance
|
||||||
|
*
|
||||||
|
* @param nodeService The node service instance
|
||||||
*/
|
*/
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
@@ -97,14 +130,14 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
|||||||
// get the parameters that represent the NodeRef, we know they are present
|
// get the parameters that represent the NodeRef, we know they are present
|
||||||
// otherwise this webscript would not have matched
|
// otherwise this webscript would not have matched
|
||||||
Map<String, String> templateVars = getTemplateVars(req);
|
Map<String, String> templateVars = getTemplateVars(req);
|
||||||
String storeType = templateVars.get("store_type");
|
String storeType = templateVars.get(STORE_TYPE);
|
||||||
String storeId = templateVars.get("store_id");
|
String storeId = templateVars.get(STORE_ID);
|
||||||
String nodeId = templateVars.get("id");
|
String nodeId = templateVars.get(ID);
|
||||||
|
|
||||||
// create the NodeRef and ensure it is valid
|
// create the NodeRef and ensure it is valid
|
||||||
NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId);
|
NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId);
|
||||||
|
|
||||||
if (!nodeService.exists(nodeRef))
|
if (!getNodeService().exists(nodeRef))
|
||||||
{
|
{
|
||||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" +
|
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" +
|
||||||
nodeRef.toString() + "'.");
|
nodeRef.toString() + "'.");
|
||||||
|
@@ -58,7 +58,7 @@ public class BaseCustomPropertyWebScript extends AbstractRmWebScript
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Try and convert the string to a qname
|
// Try and convert the string to a qname
|
||||||
return QName.createQName(elementName, namespaceService);
|
return QName.createQName(elementName, getNamespaceService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -106,7 +106,7 @@ public class CustomPropertyDefinitionDelete extends AbstractRmWebScript
|
|||||||
|
|
||||||
rmAdminService.removeCustomPropertyDefinition(propQName);
|
rmAdminService.removeCustomPropertyDefinition(propQName);
|
||||||
|
|
||||||
result.put("propertyqname", propQName.toPrefixString(namespaceService));
|
result.put("propertyqname", propQName.toPrefixString(getNamespaceService()));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to add RM custom property definitions
|
* Implementation for Java backed webscript to add RM custom property definitions
|
||||||
* to the custom model.
|
* to the custom model.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
*/
|
*/
|
||||||
public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
||||||
@@ -101,22 +101,22 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies custom properties.
|
* Applies custom properties.
|
||||||
* @throws CustomMetadataException
|
* @throws CustomMetadataException
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> createPropertyDefinition(WebScriptRequest req, JSONObject json)
|
protected Map<String, Object> createPropertyDefinition(WebScriptRequest req, JSONObject json)
|
||||||
throws JSONException, CustomMetadataException
|
throws JSONException, CustomMetadataException
|
||||||
{
|
{
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
Map<String, Serializable> params = getParamsFromUrlAndJson(req, json);
|
Map<String, Serializable> params = getParamsFromUrlAndJson(req, json);
|
||||||
|
|
||||||
QName propertyQName = createNewPropertyDefinition(params);
|
QName propertyQName = createNewPropertyDefinition(params);
|
||||||
String localName = propertyQName.getLocalName();
|
String localName = propertyQName.getLocalName();
|
||||||
|
|
||||||
result.put(PROP_ID, localName);
|
result.put(PROP_ID, localName);
|
||||||
|
|
||||||
String urlResult = req.getServicePath() + "/" + propertyQName.getLocalName();
|
String urlResult = req.getServicePath() + "/" + propertyQName.getLocalName();
|
||||||
result.put(URL, urlResult);
|
result.put(URL, urlResult);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,33 +127,33 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
|||||||
Map<String, Serializable> params;
|
Map<String, Serializable> params;
|
||||||
params = new HashMap<String, Serializable>();
|
params = new HashMap<String, Serializable>();
|
||||||
params.put(PARAM_ELEMENT, req.getParameter(PARAM_ELEMENT));
|
params.put(PARAM_ELEMENT, req.getParameter(PARAM_ELEMENT));
|
||||||
|
|
||||||
for (Iterator iter = json.keys(); iter.hasNext(); )
|
for (Iterator iter = json.keys(); iter.hasNext(); )
|
||||||
{
|
{
|
||||||
String nextKeyString = (String)iter.next();
|
String nextKeyString = (String)iter.next();
|
||||||
String nextValueString = json.getString(nextKeyString);
|
String nextValueString = json.getString(nextKeyString);
|
||||||
|
|
||||||
params.put(nextKeyString, nextValueString);
|
params.put(nextKeyString, nextValueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a property definition based on the parameter values provided
|
* Create a property definition based on the parameter values provided
|
||||||
*
|
*
|
||||||
* @param params parameter values
|
* @param params parameter values
|
||||||
* @return {@link QName} qname of the newly created custom property
|
* @return {@link QName} qname of the newly created custom property
|
||||||
* @throws CustomMetadataException
|
* @throws CustomMetadataException
|
||||||
*/
|
*/
|
||||||
protected QName createNewPropertyDefinition(Map<String, Serializable> params) throws CustomMetadataException
|
protected QName createNewPropertyDefinition(Map<String, Serializable> params) throws CustomMetadataException
|
||||||
{
|
{
|
||||||
// Get the customisable type name
|
// Get the customisable type name
|
||||||
String customisableElement = (String)params.get(PARAM_ELEMENT);
|
String customisableElement = (String)params.get(PARAM_ELEMENT);
|
||||||
QName customisableType = mapToTypeQName(customisableElement);
|
QName customisableType = mapToTypeQName(customisableElement);
|
||||||
|
|
||||||
String label = URLDecoder.decode((String)params.get(PARAM_LABEL));
|
String label = URLDecoder.decode((String)params.get(PARAM_LABEL));
|
||||||
|
|
||||||
//According to the wireframes, type here can only be date|text|number
|
//According to the wireframes, type here can only be date|text|number
|
||||||
Serializable serializableParam = params.get(PARAM_DATATYPE);
|
Serializable serializableParam = params.get(PARAM_DATATYPE);
|
||||||
QName type = null;
|
QName type = null;
|
||||||
@@ -161,7 +161,7 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
|||||||
{
|
{
|
||||||
if (serializableParam instanceof String)
|
if (serializableParam instanceof String)
|
||||||
{
|
{
|
||||||
type = QName.createQName((String)serializableParam, namespaceService);
|
type = QName.createQName((String)serializableParam, getNamespaceService());
|
||||||
}
|
}
|
||||||
else if (serializableParam instanceof QName)
|
else if (serializableParam instanceof QName)
|
||||||
{
|
{
|
||||||
@@ -172,41 +172,41 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
|||||||
throw new AlfrescoRuntimeException("Unexpected type of dataType param: "+serializableParam+" (expected String or QName)");
|
throw new AlfrescoRuntimeException("Unexpected type of dataType param: "+serializableParam+" (expected String or QName)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The title is actually generated, so this parameter will be ignored
|
// The title is actually generated, so this parameter will be ignored
|
||||||
// by the RMAdminService
|
// by the RMAdminService
|
||||||
String title = (String)params.get(PARAM_TITLE);
|
String title = (String)params.get(PARAM_TITLE);
|
||||||
String description = (String)params.get(PARAM_DESCRIPTION);
|
String description = (String)params.get(PARAM_DESCRIPTION);
|
||||||
String defaultValue = (String)params.get(PARAM_DEFAULT_VALUE);
|
String defaultValue = (String)params.get(PARAM_DEFAULT_VALUE);
|
||||||
|
|
||||||
boolean mandatory = false;
|
boolean mandatory = false;
|
||||||
serializableParam = params.get(PARAM_MANDATORY);
|
serializableParam = params.get(PARAM_MANDATORY);
|
||||||
if (serializableParam != null)
|
if (serializableParam != null)
|
||||||
{
|
{
|
||||||
mandatory = Boolean.valueOf(serializableParam.toString());
|
mandatory = Boolean.valueOf(serializableParam.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isProtected = false;
|
boolean isProtected = false;
|
||||||
serializableParam = params.get(PARAM_PROTECTED);
|
serializableParam = params.get(PARAM_PROTECTED);
|
||||||
if (serializableParam != null)
|
if (serializableParam != null)
|
||||||
{
|
{
|
||||||
isProtected = Boolean.valueOf(serializableParam.toString());
|
isProtected = Boolean.valueOf(serializableParam.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean multiValued = false;
|
boolean multiValued = false;
|
||||||
serializableParam = params.get(PARAM_MULTI_VALUED);
|
serializableParam = params.get(PARAM_MULTI_VALUED);
|
||||||
if (serializableParam != null)
|
if (serializableParam != null)
|
||||||
{
|
{
|
||||||
multiValued = Boolean.valueOf(serializableParam.toString());
|
multiValued = Boolean.valueOf(serializableParam.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
serializableParam = params.get(PARAM_CONSTRAINT_REF);
|
serializableParam = params.get(PARAM_CONSTRAINT_REF);
|
||||||
QName constraintRef = null;
|
QName constraintRef = null;
|
||||||
if (serializableParam != null)
|
if (serializableParam != null)
|
||||||
{
|
{
|
||||||
if (serializableParam instanceof String)
|
if (serializableParam instanceof String)
|
||||||
{
|
{
|
||||||
constraintRef = QName.createQName((String)serializableParam, namespaceService);
|
constraintRef = QName.createQName((String)serializableParam, getNamespaceService());
|
||||||
}
|
}
|
||||||
else if (serializableParam instanceof QName)
|
else if (serializableParam instanceof QName)
|
||||||
{
|
{
|
||||||
@@ -217,29 +217,29 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
|||||||
throw new AlfrescoRuntimeException("Unexpected type of constraintRef param: "+serializableParam+" (expected String or QName)");
|
throw new AlfrescoRuntimeException("Unexpected type of constraintRef param: "+serializableParam+" (expected String or QName)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if propId is specified, use it.
|
// if propId is specified, use it.
|
||||||
QName proposedQName = null;
|
QName proposedQName = null;
|
||||||
String propId = (String)params.get(PROP_ID);
|
String propId = (String)params.get(PROP_ID);
|
||||||
if (propId != null)
|
if (propId != null)
|
||||||
{
|
{
|
||||||
proposedQName = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_PREFIX, propId, namespaceService);
|
proposedQName = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_PREFIX, propId, getNamespaceService());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rmAdminService.addCustomPropertyDefinition(
|
return rmAdminService.addCustomPropertyDefinition(
|
||||||
proposedQName,
|
proposedQName,
|
||||||
customisableType,
|
customisableType,
|
||||||
label,
|
label,
|
||||||
type,
|
type,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
multiValued,
|
multiValued,
|
||||||
mandatory,
|
mandatory,
|
||||||
isProtected,
|
isProtected,
|
||||||
constraintRef);
|
constraintRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -163,7 +163,7 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
|||||||
}
|
}
|
||||||
if (!exists)
|
if (!exists)
|
||||||
{
|
{
|
||||||
QName constraintRefQName = QName.createQName(constraintRef, namespaceService);
|
QName constraintRefQName = QName.createQName(constraintRef, getNamespaceService());
|
||||||
result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName);
|
result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName);
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
|||||||
{
|
{
|
||||||
if (!updated)
|
if (!updated)
|
||||||
{
|
{
|
||||||
String propIdAsString = rmAdminService.getQNameForClientId(label).toPrefixString(namespaceService);
|
String propIdAsString = rmAdminService.getQNameForClientId(label).toPrefixString(getNamespaceService());
|
||||||
throw new PropertyAlreadyExistsMetadataException(propIdAsString);
|
throw new PropertyAlreadyExistsMetadataException(propIdAsString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,18 +23,17 @@ import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.rule.RuleType;
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to remove RM custom reference instances from a node.
|
* Implementation for Java backed webscript to remove RM custom relationship from a node.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
* @author Tuna Aksoy
|
* @author Tuna Aksoy
|
||||||
@@ -45,28 +44,47 @@ public class CustomRefDelete extends AbstractRmWebScript
|
|||||||
private static final String REF_ID = "refId";
|
private static final String REF_ID = "refId";
|
||||||
private static final String ST = "st";
|
private static final String ST = "st";
|
||||||
private static final String SI = "si";
|
private static final String SI = "si";
|
||||||
private static final String ID = "id";
|
|
||||||
|
|
||||||
/** RM admin service */
|
/** Relationship service */
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
/** Rule service */
|
/** Rule service */
|
||||||
private RuleService ruleService;
|
private RuleService ruleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RM admin service
|
* Gets the relationship service instance
|
||||||
*
|
*
|
||||||
* @param rmAdminService RM admin service
|
* @return The relationship service instance
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
protected RelationshipService getRelationshipService()
|
||||||
{
|
{
|
||||||
this.rmAdminService = rmAdminService;
|
return this.relationshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the rule service
|
* Sets the relationship service instance
|
||||||
*
|
*
|
||||||
* @param ruleService Rule service
|
* @param relationshipService The relationship service instance
|
||||||
|
*/
|
||||||
|
public void setRelationshipService(RelationshipService relationshipService)
|
||||||
|
{
|
||||||
|
this.relationshipService = relationshipService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the rule service instance
|
||||||
|
*
|
||||||
|
* @return The rule service instance
|
||||||
|
*/
|
||||||
|
protected RuleService getRuleService()
|
||||||
|
{
|
||||||
|
return this.ruleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the rule service instance
|
||||||
|
*
|
||||||
|
* @param ruleService The rule service instance
|
||||||
*/
|
*/
|
||||||
public void setRuleService(RuleService ruleService)
|
public void setRuleService(RuleService ruleService)
|
||||||
{
|
{
|
||||||
@@ -74,83 +92,61 @@ public class CustomRefDelete extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
|
* org.springframework.extensions.webscripts.Status,
|
||||||
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ruleService.disableRuleType(RuleType.OUTBOUND);
|
getRuleService().disableRuleType(RuleType.OUTBOUND);
|
||||||
removeCustomReferenceInstance(req);
|
removeCustomRelationship(req);
|
||||||
model.put(SUCCESS, true);
|
model.put(SUCCESS, true);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ruleService.enableRuleType(RuleType.OUTBOUND);
|
getRuleService().enableRuleType(RuleType.OUTBOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes custom reference instance
|
* Removes a custom relationship
|
||||||
*
|
*
|
||||||
* @param req The webscript request
|
* @param req The webscript request
|
||||||
*/
|
*/
|
||||||
private void removeCustomReferenceInstance(WebScriptRequest req)
|
private void removeCustomRelationship(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
NodeRef fromNode = parseRequestForNodeRef(req);
|
String uniqueName = getRequestParameterValue(req, REF_ID);
|
||||||
NodeRef toNodeRef = getToNode(req);
|
NodeRef source = parseRequestForNodeRef(req);
|
||||||
QName associationQName = getAssociationQName(req);
|
NodeRef target = getTargetNode(req);
|
||||||
|
|
||||||
rmAdminService.removeCustomReference(fromNode, toNodeRef, associationQName);
|
getRelationshipService().removeRelationship(uniqueName, source, target);
|
||||||
rmAdminService.removeCustomReference(toNodeRef, fromNode, associationQName);
|
getRelationshipService().removeRelationship(uniqueName, target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the node from which the reference will be removed
|
* Gets the target node
|
||||||
*
|
*
|
||||||
* @param req The webscript request
|
* @param req The webscript request
|
||||||
* @return The node from which the reference will be removed
|
* @return The target node
|
||||||
*/
|
*/
|
||||||
private NodeRef getToNode(WebScriptRequest req)
|
private NodeRef getTargetNode(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
// Get the toNode from the URL query string.
|
|
||||||
String storeType = req.getParameter(ST);
|
String storeType = req.getParameter(ST);
|
||||||
String storeId = req.getParameter(SI);
|
String storeId = req.getParameter(SI);
|
||||||
String nodeId = req.getParameter(ID);
|
String nodeId = req.getParameter(ID);
|
||||||
|
|
||||||
// Create the NodeRef and ensure it is valid
|
NodeRef targetNode = new NodeRef(storeType, storeId, nodeId);
|
||||||
NodeRef toNode = new NodeRef(storeType, storeId, nodeId);
|
if (!getNodeService().exists(targetNode))
|
||||||
if (!nodeService.exists(toNode))
|
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find toNode: '" +
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find the target node: '" +
|
||||||
toNode.toString() + "'.");
|
targetNode.toString() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return toNode;
|
return targetNode;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the QName of the association
|
|
||||||
*
|
|
||||||
* @param req The webscript request
|
|
||||||
* @return QName of the association
|
|
||||||
*/
|
|
||||||
private QName getAssociationQName(WebScriptRequest req)
|
|
||||||
{
|
|
||||||
String clientsRefId = getRequestParameterValue(req, REF_ID);
|
|
||||||
QName qName = rmAdminService.getQNameForClientId(clientsRefId);
|
|
||||||
|
|
||||||
if (qName == null)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
|
||||||
"Unable to find reference type: '" + clientsRefId + "'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return qName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -24,11 +24,10 @@ import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.rule.RuleType;
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
@@ -36,7 +35,7 @@ import org.springframework.extensions.webscripts.WebScriptException;
|
|||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to add RM custom reference instances to a node.
|
* Implementation for Java backed webscript to add RM custom relationship to a node.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
* @author Tuna Aksoy
|
* @author Tuna Aksoy
|
||||||
@@ -47,26 +46,46 @@ public class CustomRefPost extends AbstractRmWebScript
|
|||||||
private static final String TO_NODE = "toNode";
|
private static final String TO_NODE = "toNode";
|
||||||
private static final String REF_ID = "refId";
|
private static final String REF_ID = "refId";
|
||||||
|
|
||||||
/** RM admin service */
|
/** Relationship service */
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
/** Rule service */
|
/** Rule service */
|
||||||
private RuleService ruleService;
|
private RuleService ruleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RM admin service
|
* Gets the relationship service instance
|
||||||
*
|
*
|
||||||
* @param rmAdminService RM admin service
|
* @return The relationship service instance
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
protected RelationshipService getRelationshipService()
|
||||||
{
|
{
|
||||||
this.rmAdminService = rmAdminService;
|
return this.relationshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the rule service
|
* Sets the relationship service instance
|
||||||
*
|
*
|
||||||
* @param ruleService Rule service
|
* @param relationshipService The relationship service instance
|
||||||
|
*/
|
||||||
|
public void setRelationshipService(RelationshipService relationshipService)
|
||||||
|
{
|
||||||
|
this.relationshipService = relationshipService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the rule service instance
|
||||||
|
*
|
||||||
|
* @return The rule service instance
|
||||||
|
*/
|
||||||
|
protected RuleService getRuleService()
|
||||||
|
{
|
||||||
|
return this.ruleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the rule service instance
|
||||||
|
*
|
||||||
|
* @param ruleService The rule service instance
|
||||||
*/
|
*/
|
||||||
public void setRuleService(RuleService ruleService)
|
public void setRuleService(RuleService ruleService)
|
||||||
{
|
{
|
||||||
@@ -74,79 +93,59 @@ public class CustomRefPost extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
|
* org.springframework.extensions.webscripts.Status,
|
||||||
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ruleService.disableRuleType(RuleType.INBOUND);
|
getRuleService().disableRuleType(RuleType.INBOUND);
|
||||||
addCustomReferenceInstance(req);
|
addCustomRelationship(req);
|
||||||
model.put(SUCCESS, true);
|
model.put(SUCCESS, true);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ruleService.enableRuleType(RuleType.INBOUND);
|
getRuleService().enableRuleType(RuleType.INBOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a custom reference instance
|
* Adds a custom relationship
|
||||||
*
|
*
|
||||||
* @param req The webscript request
|
* @param req The webscript request
|
||||||
*/
|
*/
|
||||||
protected void addCustomReferenceInstance(WebScriptRequest req)
|
protected void addCustomRelationship(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
NodeRef fromNode = parseRequestForNodeRef(req);
|
|
||||||
JSONObject json = getRequestContentAsJsonObject(req);
|
JSONObject json = getRequestContentAsJsonObject(req);
|
||||||
NodeRef toNode = getToNode(json);
|
String uniqueName = getStringValueFromJSONObject(json, REF_ID);
|
||||||
QName associationQName = getAssociationQName(json);
|
NodeRef target = getTargetNode(json);
|
||||||
|
NodeRef source = parseRequestForNodeRef(req);
|
||||||
|
|
||||||
rmAdminService.addCustomReference(fromNode, toNode, associationQName);
|
getRelationshipService().addRelationship(uniqueName, source, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the node to which the reference will be added
|
* Gets the target node
|
||||||
*
|
*
|
||||||
* @param json Request content as json object
|
* @param json Request content as json object
|
||||||
* @return The node to which the reference will be added
|
* @return The target node
|
||||||
*/
|
*/
|
||||||
private NodeRef getToNode(JSONObject json)
|
private NodeRef getTargetNode(JSONObject json)
|
||||||
{
|
{
|
||||||
String toNodeString = getStringValueFromJSONObject(json, TO_NODE);
|
String targetNodeString = getStringValueFromJSONObject(json, TO_NODE);
|
||||||
NodeRef toNode = new NodeRef(toNodeString);
|
NodeRef targetNode = new NodeRef(targetNodeString);
|
||||||
|
|
||||||
if (!nodeService.exists(toNode))
|
if (!getNodeService().exists(targetNode))
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find toNode: '" +
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find the target node: '" +
|
||||||
toNode.toString() + "'.");
|
targetNode.toString() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return toNode;
|
return targetNode;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the QName of the association
|
|
||||||
*
|
|
||||||
* @param json Request content as json object
|
|
||||||
* @return QName of the association
|
|
||||||
*/
|
|
||||||
private QName getAssociationQName(JSONObject json)
|
|
||||||
{
|
|
||||||
String clientsRefId = getStringValueFromJSONObject(json, REF_ID);
|
|
||||||
QName qName = rmAdminService.getQNameForClientId(clientsRefId);
|
|
||||||
|
|
||||||
if (qName == null)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
|
||||||
"Unable to find reference type: '" + clientsRefId + "'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return qName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -20,11 +20,9 @@ package org.alfresco.module.org_alfresco_module_rm.script;
|
|||||||
|
|
||||||
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for custom reference definition classes
|
* Base class for custom reference definition classes
|
||||||
@@ -42,62 +40,41 @@ public class CustomReferenceDefinitionBase extends AbstractRmWebScript
|
|||||||
protected static final String TARGET = "target";
|
protected static final String TARGET = "target";
|
||||||
protected static final String CUSTOM_REFS = "customRefs";
|
protected static final String CUSTOM_REFS = "customRefs";
|
||||||
protected static final String URL = "url";
|
protected static final String URL = "url";
|
||||||
protected static final String SUCCESS = "success";
|
|
||||||
|
|
||||||
/** Records Management Admin Service */
|
/** Relationship service */
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the records management admin service
|
* Gets the relationship service instance
|
||||||
*
|
*
|
||||||
* @param rmAdminService The records management admin service
|
* @return The relationship service instance
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
protected RelationshipService getRelationshipService()
|
||||||
{
|
{
|
||||||
this.rmAdminService = rmAdminService;
|
return this.relationshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the records management admin service instance
|
* Sets the relationship service instance
|
||||||
*
|
*
|
||||||
* @return The records management admin service instance
|
* @param relationshipService The relationship service instance
|
||||||
*/
|
*/
|
||||||
protected RecordsManagementAdminService getRmAdminService()
|
public void setRelationshipService(RelationshipService relationshipService)
|
||||||
{
|
{
|
||||||
return this.rmAdminService;
|
this.relationshipService = relationshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the QName for the given custom reference id
|
* Creates the relationship display name from request content
|
||||||
*
|
|
||||||
* @param referenceId The reference id
|
|
||||||
* @return The QName for the given custom reference id
|
|
||||||
*/
|
|
||||||
protected QName getCustomReferenceQName(String referenceId)
|
|
||||||
{
|
|
||||||
QName customReferenceQName = getRmAdminService().getQNameForClientId(referenceId);
|
|
||||||
if (customReferenceQName == null)
|
|
||||||
{
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
msg.append("Unable to find QName for the reference: '");
|
|
||||||
msg.append(referenceId);
|
|
||||||
msg.append("'.");
|
|
||||||
String errorMsg = msg.toString();
|
|
||||||
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, errorMsg);
|
|
||||||
}
|
|
||||||
return customReferenceQName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the custom reference type from the json object
|
|
||||||
*
|
*
|
||||||
* @param requestContent The request content as json object
|
* @param requestContent The request content as json object
|
||||||
* @return Returns the custom reference type which is either parent/child or bidirectional
|
* @return The relationship display name
|
||||||
*/
|
*/
|
||||||
protected CustomReferenceType getCustomReferenceType(JSONObject requestContent)
|
protected RelationshipDisplayName createDisplayName(JSONObject requestContent)
|
||||||
{
|
{
|
||||||
String referenceType = getStringValueFromJSONObject(requestContent, REFERENCE_TYPE);
|
String sourceText = getStringValueFromJSONObject(requestContent, SOURCE, false, false);
|
||||||
return CustomReferenceType.getEnumFromString(referenceType);
|
String targetText = getStringValueFromJSONObject(requestContent, TARGET, false, false);
|
||||||
|
String labelText = getStringValueFromJSONObject(requestContent, LABEL, false, false);
|
||||||
|
return new RelationshipDisplayName(sourceText, targetText, labelText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,16 +19,15 @@
|
|||||||
package org.alfresco.module.org_alfresco_module_rm.script;
|
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||||
|
|
||||||
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
||||||
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,69 +40,40 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
public class CustomReferenceDefinitionPost extends CustomReferenceDefinitionBase
|
public class CustomReferenceDefinitionPost extends CustomReferenceDefinitionBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
|
* org.springframework.extensions.webscripts.Status,
|
||||||
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
||||||
CustomReferenceType customReferenceType = getCustomReferenceType(requestContent);
|
RelationshipDisplayName displayName = createDisplayName(requestContent);
|
||||||
QName customReference = addCustomReference(requestContent, customReferenceType);
|
RelationshipDefinition relationshipDefinition = getRelationshipService().createRelationshipDefinition(displayName);
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
String servicePath = req.getServicePath();
|
String servicePath = req.getServicePath();
|
||||||
Map<String, Object> customReferenceData = getCustomReferenceData(customReferenceType, customReference, servicePath);
|
Map<String, Object> customRelationshipData = createRelationshipDefinitionData(relationshipDefinition, servicePath);
|
||||||
model.putAll(customReferenceData);
|
model.putAll(customRelationshipData);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds custom reference to the model
|
* Creates relationship definition data for the ftl template
|
||||||
*
|
*
|
||||||
* @param requestContent The request content as json object
|
* @param relationshipDefinition The relationship definition
|
||||||
* @param customReferenceType The custom reference type
|
|
||||||
* @return Returns the {@link QName} of the new custom reference
|
|
||||||
*/
|
|
||||||
private QName addCustomReference(JSONObject requestContent, CustomReferenceType customReferenceType)
|
|
||||||
{
|
|
||||||
QName referenceQName;
|
|
||||||
|
|
||||||
if (CustomReferenceType.PARENT_CHILD.equals(customReferenceType))
|
|
||||||
{
|
|
||||||
String source = getStringValueFromJSONObject(requestContent, SOURCE);
|
|
||||||
String target = getStringValueFromJSONObject(requestContent, TARGET);
|
|
||||||
referenceQName = getRmAdminService().addCustomChildAssocDefinition(source, target);
|
|
||||||
}
|
|
||||||
else if (CustomReferenceType.BIDIRECTIONAL.equals(customReferenceType))
|
|
||||||
{
|
|
||||||
String label = getStringValueFromJSONObject(requestContent, LABEL);
|
|
||||||
referenceQName = getRmAdminService().addCustomAssocDefinition(label);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unsupported custom reference type.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return referenceQName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the custom reference data
|
|
||||||
*
|
|
||||||
* @param customReferenceType The custom reference type
|
|
||||||
* @param customReference The qualified name of the custom reference
|
|
||||||
* @param servicePath The service path
|
* @param servicePath The service path
|
||||||
* @return The custom reference data
|
* @return The relationship definition data
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> getCustomReferenceData(CustomReferenceType customReferenceType, QName customReference, String servicePath)
|
private Map<String, Object> createRelationshipDefinitionData(RelationshipDefinition relationshipDefinition, String servicePath)
|
||||||
{
|
{
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> relationshipDefinitionData = new HashMap<String, Object>(4);
|
||||||
String qnameLocalName = customReference.getLocalName();
|
String uniqueName = relationshipDefinition.getUniqueName();
|
||||||
result.put(REFERENCE_TYPE, customReferenceType.toString());
|
relationshipDefinitionData.put(REFERENCE_TYPE, relationshipDefinition.getType().toString());
|
||||||
result.put(REF_ID, qnameLocalName);
|
relationshipDefinitionData.put(REF_ID, uniqueName);
|
||||||
result.put(URL, servicePath + PATH_SEPARATOR + qnameLocalName);
|
relationshipDefinitionData.put(URL, servicePath + PATH_SEPARATOR + uniqueName);
|
||||||
result.put(SUCCESS, Boolean.TRUE);
|
relationshipDefinitionData.put(SUCCESS, Boolean.TRUE);
|
||||||
return result;
|
return relationshipDefinitionData;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -20,16 +20,14 @@ package org.alfresco.module.org_alfresco_module_rm.script;
|
|||||||
|
|
||||||
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
||||||
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||||
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,65 +40,40 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
*/
|
*/
|
||||||
public class CustomReferenceDefinitionPut extends CustomReferenceDefinitionBase
|
public class CustomReferenceDefinitionPut extends CustomReferenceDefinitionBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
|
* org.springframework.extensions.webscripts.Status,
|
||||||
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
|
String uniqueName = getRequestParameterValue(req, REF_ID);
|
||||||
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
||||||
String referenceId = getRequestParameterValue(req, REF_ID);
|
RelationshipDisplayName displayName = createDisplayName(requestContent);
|
||||||
updateCustomReference(requestContent, referenceId);
|
getRelationshipService().updateReleationshipDefinition(uniqueName, displayName);
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
String servicePath = req.getServicePath();
|
String servicePath = req.getServicePath();
|
||||||
Map<String, Object> customReferenceData = getCustomReferenceData(servicePath, referenceId);
|
Map<String, Object> customReferenceData = createRelationshipDefinitionData(servicePath, uniqueName);
|
||||||
model.putAll(customReferenceData);
|
model.putAll(customReferenceData);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the custom reference
|
* Creates relationship definition data for the ftl template
|
||||||
*
|
|
||||||
* @param requestContent The request content as json object
|
|
||||||
* @param referenceId The reference id
|
|
||||||
*/
|
|
||||||
private void updateCustomReference(JSONObject requestContent, String referenceId)
|
|
||||||
{
|
|
||||||
QName referenceQName = getCustomReferenceQName(referenceId);
|
|
||||||
CustomReferenceType customReferenceType = getCustomReferenceType(requestContent);
|
|
||||||
|
|
||||||
if (CustomReferenceType.PARENT_CHILD.equals(customReferenceType))
|
|
||||||
{
|
|
||||||
String source = getStringValueFromJSONObject(requestContent, SOURCE);
|
|
||||||
String target = getStringValueFromJSONObject(requestContent, TARGET);
|
|
||||||
getRmAdminService().updateCustomChildAssocDefinition(referenceQName, source, target);
|
|
||||||
}
|
|
||||||
else if (CustomReferenceType.BIDIRECTIONAL.equals(customReferenceType))
|
|
||||||
{
|
|
||||||
String label = getStringValueFromJSONObject(requestContent, LABEL);
|
|
||||||
getRmAdminService().updateCustomAssocDefinition(referenceQName, label);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unsupported custom reference type.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the custom reference data
|
|
||||||
*
|
*
|
||||||
* @param servicePath The service path
|
* @param servicePath The service path
|
||||||
* @param String The reference id
|
* @param String The relationship unique name
|
||||||
* @return The custom reference data
|
* @return The relationship definition data
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> getCustomReferenceData(String servicePath, String referenceId)
|
private Map<String, Object> createRelationshipDefinitionData(String servicePath, String uniqueName)
|
||||||
{
|
{
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> relationshipDefinitionData = new HashMap<String, Object>(3);
|
||||||
result.put(URL, servicePath);
|
relationshipDefinitionData.put(URL, servicePath);
|
||||||
result.put(REF_ID, referenceId);
|
relationshipDefinitionData.put(REF_ID, uniqueName);
|
||||||
result.put(SUCCESS, Boolean.TRUE);
|
relationshipDefinitionData.put(SUCCESS, Boolean.TRUE);
|
||||||
return result;
|
return relationshipDefinitionData;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -19,18 +19,18 @@
|
|||||||
package org.alfresco.module.org_alfresco_module_rm.script;
|
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||||
|
|
||||||
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
@@ -44,175 +44,93 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
*/
|
*/
|
||||||
public class CustomReferenceDefinitionsGet extends CustomReferenceDefinitionBase
|
public class CustomReferenceDefinitionsGet extends CustomReferenceDefinitionBase
|
||||||
{
|
{
|
||||||
/** Dictionary Service */
|
|
||||||
private DictionaryService dictionaryService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the dictionary service
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
*
|
* org.springframework.extensions.webscripts.Status,
|
||||||
* @param dictionaryService The dictionary service
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
|
||||||
{
|
|
||||||
this.dictionaryService = dictionaryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the dictionary service instance
|
|
||||||
*
|
|
||||||
* @return The dictionary service instance
|
|
||||||
*/
|
|
||||||
protected DictionaryService getDictionaryService()
|
|
||||||
{
|
|
||||||
return this.dictionaryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
String referenceId = getRequestParameterValue(req, REF_ID, false);
|
String uniqueName = getRequestParameterValue(req, REF_ID, false);
|
||||||
Map<QName, AssociationDefinition> customReferenceDefinitions = getCustomReferenceDefinitions(referenceId);
|
Set<RelationshipDefinition> relationshipDefinitions = getRelationshipDefinitons(uniqueName);
|
||||||
List<Map<String, String>> customReferenceData = getCustomReferenceData(customReferenceDefinitions);
|
List<Map<String, String>> relationshipDefinitionData = createRelationshipDefinitionData(relationshipDefinitions);
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
model.put(CUSTOM_REFS, customReferenceData);
|
model.put(CUSTOM_REFS, relationshipDefinitionData);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the custom reference definition(s) for the given reference id
|
* Gets the relationship definition for the unique name. If the unique
|
||||||
|
* name is blank all relationship definitions will be retrieved
|
||||||
*
|
*
|
||||||
* @param referenceId The reference id
|
* @param uniqueName The unique name of the relationship definition
|
||||||
* @return If the reference id is not blank the custom definition for the given reference id will be returned,
|
* @return Relationship definition for the given unique name or all
|
||||||
* otherwise all custom definitions will be returned.
|
* relationship definitions if unique name is blank
|
||||||
*/
|
*/
|
||||||
private Map<QName, AssociationDefinition> getCustomReferenceDefinitions(String referenceId)
|
private Set<RelationshipDefinition> getRelationshipDefinitons(String uniqueName)
|
||||||
{
|
{
|
||||||
Map<QName, AssociationDefinition> customReferenceDefinitions = new HashMap<QName, AssociationDefinition>();
|
Set<RelationshipDefinition> relationshipDefinitions = new HashSet<RelationshipDefinition>();
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(referenceId))
|
if (isBlank(uniqueName))
|
||||||
{
|
{
|
||||||
QName referenceQName = getCustomReferenceQName(referenceId);
|
relationshipDefinitions.addAll(getRelationshipService().getRelationshipDefinitions());
|
||||||
AssociationDefinition associationDefinition = getAssosiationDefinitionForCustomReference(referenceQName);
|
|
||||||
customReferenceDefinitions.put(referenceQName, associationDefinition);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
customReferenceDefinitions.putAll(getRmAdminService().getCustomReferenceDefinitions());
|
RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName);
|
||||||
}
|
if (relationshipDefinition != null)
|
||||||
|
|
||||||
return customReferenceDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the association definition for the given reference QName
|
|
||||||
*
|
|
||||||
* @param referenceQName The reference QName
|
|
||||||
* @return The association definition for the given reference QName
|
|
||||||
*/
|
|
||||||
private AssociationDefinition getAssosiationDefinitionForCustomReference(QName referenceQName)
|
|
||||||
{
|
|
||||||
AssociationDefinition associationDefinition = getRmAdminService().getCustomReferenceDefinitions().get(referenceQName);
|
|
||||||
if (associationDefinition == null)
|
|
||||||
{
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
msg.append("Unable to find association definition for the reference: '");
|
|
||||||
msg.append(referenceQName.getLocalName());
|
|
||||||
msg.append("'.");
|
|
||||||
String errorMsg = msg.toString();
|
|
||||||
|
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, errorMsg);
|
|
||||||
}
|
|
||||||
return associationDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the custom reference type from the association definition
|
|
||||||
*
|
|
||||||
* @param associationDefinition The association definition
|
|
||||||
* @return Returns the custom reference type which is either parent/child or bidirectional
|
|
||||||
*/
|
|
||||||
private CustomReferenceType getCustomReferenceType(AssociationDefinition associationDefinition)
|
|
||||||
{
|
|
||||||
CustomReferenceType referenceType;
|
|
||||||
|
|
||||||
if (associationDefinition instanceof ChildAssociationDefinition)
|
|
||||||
{
|
|
||||||
referenceType = CustomReferenceType.PARENT_CHILD;
|
|
||||||
}
|
|
||||||
else if (associationDefinition instanceof AssociationDefinition)
|
|
||||||
{
|
|
||||||
referenceType = CustomReferenceType.BIDIRECTIONAL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
msg.append("Unsupported association definition: '");
|
|
||||||
msg.append(associationDefinition.getName().getLocalName());
|
|
||||||
msg.append("'.");
|
|
||||||
String errorMsg = msg.toString();
|
|
||||||
|
|
||||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, errorMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return referenceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the custom reference data
|
|
||||||
*
|
|
||||||
* @param customReferenceDefinitions The custom reference definitions
|
|
||||||
* @return Custom reference data
|
|
||||||
*/
|
|
||||||
private List<Map<String, String>> getCustomReferenceData(Map<QName, AssociationDefinition> customReferenceDefinitions)
|
|
||||||
{
|
|
||||||
List<Map<String, String>> customReferences = new ArrayList<Map<String, String>>();
|
|
||||||
|
|
||||||
for (Entry<QName, AssociationDefinition> entry : customReferenceDefinitions.entrySet())
|
|
||||||
{
|
|
||||||
Map<String, String> customReference = new HashMap<String, String>();
|
|
||||||
AssociationDefinition associationDefinition = entry.getValue();
|
|
||||||
CustomReferenceType referenceType = getCustomReferenceType(associationDefinition);
|
|
||||||
String title = getAssociationDefinitionTitle(associationDefinition);
|
|
||||||
|
|
||||||
if (CustomReferenceType.PARENT_CHILD.equals(referenceType))
|
|
||||||
{
|
{
|
||||||
String[] sourceAndTarget = getRmAdminService().splitSourceTargetId(title);
|
relationshipDefinitions.add(relationshipDefinition);
|
||||||
customReference.put(SOURCE, sourceAndTarget[0]);
|
|
||||||
customReference.put(TARGET, sourceAndTarget[1]);
|
|
||||||
}
|
}
|
||||||
else if (CustomReferenceType.BIDIRECTIONAL.equals(referenceType))
|
}
|
||||||
|
|
||||||
|
return relationshipDefinitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates relationship definition data for the ftl template
|
||||||
|
*
|
||||||
|
* @param relationshipDefinitions The relationship definitions
|
||||||
|
* @return The relationship definition data
|
||||||
|
*/
|
||||||
|
private List<Map<String, String>> createRelationshipDefinitionData(Set<RelationshipDefinition> relationshipDefinitions)
|
||||||
|
{
|
||||||
|
List<Map<String, String>> relationshipDefinitionData = new ArrayList<Map<String, String>>();
|
||||||
|
|
||||||
|
for (RelationshipDefinition relationshipDefinition : relationshipDefinitions)
|
||||||
|
{
|
||||||
|
Map<String, String> data = new HashMap<String, String>();
|
||||||
|
|
||||||
|
RelationshipType type = relationshipDefinition.getType();
|
||||||
|
RelationshipDisplayName displayName = relationshipDefinition.getDisplayName();
|
||||||
|
|
||||||
|
if (RelationshipType.BIDIRECTIONAL.equals(type))
|
||||||
{
|
{
|
||||||
customReference.put(LABEL, title);
|
data.put(LABEL, displayName.getLabelText());
|
||||||
|
}
|
||||||
|
else if (RelationshipType.PARENTCHILD.equals(type))
|
||||||
|
{
|
||||||
|
data.put(SOURCE, displayName.getSourceText());
|
||||||
|
data.put(TARGET, displayName.getTargetText());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unsupported relationship type '")
|
||||||
|
.append(type)
|
||||||
|
.append("'.");
|
||||||
|
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
String referenceId = entry.getKey().getLocalName();
|
data.put(REF_ID, relationshipDefinition.getUniqueName());
|
||||||
customReference.put(REF_ID, referenceId);
|
data.put(REFERENCE_TYPE, type.toString().toLowerCase());
|
||||||
customReference.put(REFERENCE_TYPE, referenceType.toString());
|
|
||||||
|
|
||||||
customReferences.add(customReference);
|
relationshipDefinitionData.add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return customReferences;
|
return relationshipDefinitionData;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the association definition title
|
|
||||||
*
|
|
||||||
* @param associationDefinition The association definition
|
|
||||||
* @return The title of the association definition
|
|
||||||
*/
|
|
||||||
private String getAssociationDefinitionTitle(AssociationDefinition associationDefinition)
|
|
||||||
{
|
|
||||||
String title = associationDefinition.getTitle(getDictionaryService());
|
|
||||||
if (StringUtils.isBlank(title))
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "Association definition title is blank.");
|
|
||||||
}
|
|
||||||
return title;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -22,21 +22,22 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability;
|
import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,38 +63,46 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
private static final String NODE_NAME = "nodeName";
|
private static final String NODE_NAME = "nodeName";
|
||||||
private static final String NODE_TITLE = "nodeTitle";
|
private static final String NODE_TITLE = "nodeTitle";
|
||||||
|
|
||||||
/** RM admin service */
|
/** Relationship service */
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
/** Dictionary service */
|
|
||||||
private DictionaryService dictionaryService;
|
|
||||||
|
|
||||||
/** Capability service */
|
/** Capability service */
|
||||||
private CapabilityService capabilityService;
|
private CapabilityService capabilityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RM admin service
|
* Gets the relationship service instance
|
||||||
* @param rmAdminService RM admin service
|
*
|
||||||
|
* @return The relationship service instance
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
protected RelationshipService getRelationshipService()
|
||||||
{
|
{
|
||||||
this.rmAdminService = rmAdminService;
|
return this.relationshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the dictionary service
|
* Sets the relationship service instance
|
||||||
*
|
*
|
||||||
* @param dictionaryService Dictionary service
|
* @param relationshipService The relationship service instance
|
||||||
*/
|
*/
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setRelationshipService(RelationshipService relationshipService)
|
||||||
{
|
{
|
||||||
this.dictionaryService = dictionaryService;
|
this.relationshipService = relationshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the capability service
|
* Gets the capability service instance
|
||||||
*
|
*
|
||||||
* @param capabilityService Capability service
|
* @return The capability service instance
|
||||||
|
*/
|
||||||
|
protected CapabilityService getCapabilityService()
|
||||||
|
{
|
||||||
|
return this.capabilityService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the capability service instance
|
||||||
|
*
|
||||||
|
* @param capabilityService Capability service instance
|
||||||
*/
|
*/
|
||||||
public void setCapabilityService(CapabilityService capabilityService)
|
public void setCapabilityService(CapabilityService capabilityService)
|
||||||
{
|
{
|
||||||
@@ -101,15 +110,17 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
|
* org.springframework.extensions.webscripts.Status,
|
||||||
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, Object> model = new HashMap<String, Object>(4);
|
Map<String, Object> model = new HashMap<String, Object>(4);
|
||||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||||
model.put(NODE_NAME, nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
|
model.put(NODE_NAME, getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||||
model.put(NODE_TITLE, nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE));
|
model.put(NODE_TITLE, getNodeService().getProperty(nodeRef, ContentModel.PROP_TITLE));
|
||||||
model.put(CUSTOM_REFS_FROM, getOutwardReferences(nodeRef));
|
model.put(CUSTOM_REFS_FROM, getOutwardReferences(nodeRef));
|
||||||
model.put(CUSTOM_REFS_TO, getInwardReferenceData(nodeRef));
|
model.put(CUSTOM_REFS_TO, getInwardReferenceData(nodeRef));
|
||||||
return model;
|
return model;
|
||||||
@@ -124,13 +135,8 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
private List<Map<String, String>> getOutwardReferences(NodeRef nodeRef)
|
private List<Map<String, String>> getOutwardReferences(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
List<Map<String, String>> outwardReferenceData = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> outwardReferenceData = new ArrayList<Map<String, String>>();
|
||||||
|
Set<Relationship> relationships = getRelationshipService().getRelationshipsFrom(nodeRef);
|
||||||
List<AssociationRef> assocsFromThisNode = rmAdminService.getCustomReferencesFrom(nodeRef);
|
outwardReferenceData.addAll(getRelationshipData(relationships));
|
||||||
outwardReferenceData.addAll(getBidirectionalReferenceData(assocsFromThisNode));
|
|
||||||
|
|
||||||
List<ChildAssociationRef> childAssocs = rmAdminService.getCustomChildReferences(nodeRef);
|
|
||||||
outwardReferenceData.addAll(getParentChildReferenceData(childAssocs));
|
|
||||||
|
|
||||||
return outwardReferenceData;
|
return outwardReferenceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,91 +149,68 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
private List<Map<String, String>> getInwardReferenceData(NodeRef nodeRef)
|
private List<Map<String, String>> getInwardReferenceData(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
List<Map<String, String>> inwardReferenceData = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> inwardReferenceData = new ArrayList<Map<String, String>>();
|
||||||
|
Set<Relationship> relationships = getRelationshipService().getRelationshipsTo(nodeRef);
|
||||||
List<AssociationRef> assocsToThisNode = rmAdminService.getCustomReferencesTo(nodeRef);
|
inwardReferenceData.addAll(getRelationshipData(relationships));
|
||||||
inwardReferenceData.addAll(getBidirectionalReferenceData(assocsToThisNode));
|
|
||||||
|
|
||||||
List<ChildAssociationRef> parentAssocs = rmAdminService.getCustomParentReferences(nodeRef);
|
|
||||||
inwardReferenceData.addAll(getParentChildReferenceData(parentAssocs));
|
|
||||||
|
|
||||||
return inwardReferenceData;
|
return inwardReferenceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method goes through the associationRefs specified and constructs a Map<String, String>
|
* Creates relationship data for the ftl template
|
||||||
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
|
||||||
* parent/child references.
|
|
||||||
*
|
*
|
||||||
* @param childAssocs Association references
|
* @param relationships The relationships
|
||||||
* @return The reference data
|
* @return The relationship data
|
||||||
*/
|
*/
|
||||||
private List<Map<String, String>> getParentChildReferenceData(List<ChildAssociationRef> childAssocs)
|
private List<Map<String, String>> getRelationshipData(Set<Relationship> relationships)
|
||||||
{
|
{
|
||||||
List<Map<String, String>> referenceData = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> relationshipData = new ArrayList<Map<String, String>>();
|
||||||
|
|
||||||
for (ChildAssociationRef childAssRef : childAssocs)
|
for (Relationship relationship : relationships)
|
||||||
{
|
{
|
||||||
Map<String, String> data = new HashMap<String, String>();
|
String uniqueName = relationship.getUniqueName();
|
||||||
|
RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName);
|
||||||
|
|
||||||
data.put(CHILD_REF, childAssRef.getChildRef().toString());
|
NodeRef source = relationship.getSource();
|
||||||
data.put(PARENT_REF, childAssRef.getParentRef().toString());
|
NodeRef target = relationship.getTarget();
|
||||||
|
|
||||||
QName typeQName = childAssRef.getTypeQName();
|
if (relationshipDefinition != null && hasView(source) && hasView(target))
|
||||||
AssociationDefinition assDef = rmAdminService.getCustomReferenceDefinitions().get(typeQName);
|
|
||||||
|
|
||||||
if (assDef != null &&
|
|
||||||
hasView(childAssRef.getParentRef()) &&
|
|
||||||
hasView(childAssRef.getChildRef()))
|
|
||||||
{
|
{
|
||||||
String compoundTitle = assDef.getTitle(dictionaryService);
|
Map<String, String> data = new HashMap<String, String>();
|
||||||
|
|
||||||
String[] sourceAndTarget = rmAdminService.splitSourceTargetId(compoundTitle);
|
RelationshipType type = relationshipDefinition.getType();
|
||||||
data.put(SOURCE, sourceAndTarget[0]);
|
RelationshipDisplayName displayName = relationshipDefinition.getDisplayName();
|
||||||
data.put(TARGET, sourceAndTarget[1]);
|
|
||||||
data.put(REFERENCE_TYPE, CustomReferenceType.PARENT_CHILD.toString());
|
|
||||||
data.put(REF_ID, typeQName.getLocalName());
|
|
||||||
|
|
||||||
referenceData.add(data);
|
if (RelationshipType.BIDIRECTIONAL.equals(type))
|
||||||
|
{
|
||||||
|
data.put(LABEL, displayName.getLabelText());
|
||||||
|
data.put(SOURCE_REF, source.toString());
|
||||||
|
data.put(TARGET_REF, target.toString());
|
||||||
|
}
|
||||||
|
else if (RelationshipType.PARENTCHILD.equals(type))
|
||||||
|
{
|
||||||
|
data.put(SOURCE, displayName.getSourceText());
|
||||||
|
data.put(TARGET, displayName.getTargetText());
|
||||||
|
data.put(PARENT_REF, source.toString());
|
||||||
|
data.put(CHILD_REF, target.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unsupported relationship type '")
|
||||||
|
.append(type)
|
||||||
|
.append("'.");
|
||||||
|
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
data.put(REFERENCE_TYPE, type.toString().toLowerCase());
|
||||||
|
data.put(REF_ID, uniqueName);
|
||||||
|
|
||||||
|
relationshipData.add(data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return referenceData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method goes through the associationRefs specified and constructs a Map<String, String>
|
|
||||||
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
|
||||||
* bidirectional references.
|
|
||||||
*
|
|
||||||
* @param assocs Association references
|
|
||||||
* @return The reference data
|
|
||||||
*/
|
|
||||||
private List<Map<String, String>> getBidirectionalReferenceData(List<AssociationRef> assocs)
|
|
||||||
{
|
|
||||||
List<Map<String, String>> referenceData = new ArrayList<Map<String, String>>();
|
|
||||||
|
|
||||||
for (AssociationRef assRef : assocs)
|
|
||||||
{
|
|
||||||
Map<String, String> data = new HashMap<String, String>();
|
|
||||||
|
|
||||||
QName typeQName = assRef.getTypeQName();
|
|
||||||
AssociationDefinition assDef = rmAdminService.getCustomReferenceDefinitions().get(typeQName);
|
|
||||||
|
|
||||||
if (assDef != null &&
|
|
||||||
hasView(assRef.getTargetRef()) &&
|
|
||||||
hasView(assRef.getSourceRef()))
|
|
||||||
{
|
|
||||||
data.put(LABEL, assDef.getTitle(dictionaryService));
|
|
||||||
data.put(REF_ID, typeQName.getLocalName());
|
|
||||||
data.put(REFERENCE_TYPE, CustomReferenceType.BIDIRECTIONAL.toString());
|
|
||||||
data.put(SOURCE_REF, assRef.getSourceRef().toString());
|
|
||||||
data.put(TARGET_REF, assRef.getTargetRef().toString());
|
|
||||||
|
|
||||||
referenceData.add(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return referenceData;
|
return relationshipData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,7 +223,7 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Capability viewRecordCapability = capabilityService.getCapability(ViewRecordsCapability.NAME);
|
Capability viewRecordCapability = getCapabilityService().getCapability(ViewRecordsCapability.NAME);
|
||||||
if (AccessStatus.ALLOWED.equals(viewRecordCapability.hasPermission(nodeRef)))
|
if (AccessStatus.ALLOWED.equals(viewRecordCapability.hasPermission(nodeRef)))
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
|
@@ -63,11 +63,11 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
|||||||
DispositionSchedule schedule = null;
|
DispositionSchedule schedule = null;
|
||||||
if (inherited)
|
if (inherited)
|
||||||
{
|
{
|
||||||
schedule = this.dispositionService.getDispositionSchedule(nodeRef);
|
schedule = getDispositionService().getDispositionSchedule(nodeRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
schedule = dispositionService.getAssociatedDispositionSchedule(nodeRef);
|
schedule = getDispositionService().getAssociatedDispositionSchedule(nodeRef);
|
||||||
}
|
}
|
||||||
if (schedule == null)
|
if (schedule == null)
|
||||||
{
|
{
|
||||||
@@ -132,7 +132,7 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
|||||||
|
|
||||||
if (actionDef.getPeriodProperty() != null)
|
if (actionDef.getPeriodProperty() != null)
|
||||||
{
|
{
|
||||||
model.put("periodProperty", actionDef.getPeriodProperty().toPrefixString(this.namespaceService));
|
model.put("periodProperty", actionDef.getPeriodProperty().toPrefixString(getNamespaceService()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionDef.getLocation() != null)
|
if (actionDef.getLocation() != null)
|
||||||
@@ -181,7 +181,7 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
|||||||
scheduleModel.put("nodeRef", schedule.getNodeRef().toString());
|
scheduleModel.put("nodeRef", schedule.getNodeRef().toString());
|
||||||
scheduleModel.put("recordLevelDisposition", schedule.isRecordLevelDisposition());
|
scheduleModel.put("recordLevelDisposition", schedule.isRecordLevelDisposition());
|
||||||
scheduleModel.put("canStepsBeRemoved",
|
scheduleModel.put("canStepsBeRemoved",
|
||||||
!this.dispositionService.hasDisposableItems(schedule));
|
!getDispositionService().hasDisposableItems(schedule));
|
||||||
|
|
||||||
if (schedule.getDispositionAuthority() != null)
|
if (schedule.getDispositionAuthority() != null)
|
||||||
{
|
{
|
||||||
@@ -200,10 +200,10 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
|||||||
for (DispositionActionDefinition actionDef : schedule.getDispositionActionDefinitions())
|
for (DispositionActionDefinition actionDef : schedule.getDispositionActionDefinitions())
|
||||||
{
|
{
|
||||||
NodeRef actionDefNodeRef = actionDef.getNodeRef();
|
NodeRef actionDefNodeRef = actionDef.getNodeRef();
|
||||||
if (nodeService.hasAspect(actionDefNodeRef, RecordsManagementModel.ASPECT_UNPUBLISHED_UPDATE))
|
if (getNodeService().hasAspect(actionDefNodeRef, RecordsManagementModel.ASPECT_UNPUBLISHED_UPDATE))
|
||||||
{
|
{
|
||||||
unpublishedUpdates = true;
|
unpublishedUpdates = true;
|
||||||
publishInProgress = ((Boolean)nodeService.getProperty(actionDefNodeRef, RecordsManagementModel.PROP_PUBLISH_IN_PROGRESS)).booleanValue();
|
publishInProgress = ((Boolean) getNodeService().getProperty(actionDefNodeRef, RecordsManagementModel.PROP_PUBLISH_IN_PROGRESS)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.add(createActionDefModel(actionDef, actionsUrl + "/" + actionDef.getId()));
|
actions.add(createActionDefModel(actionDef, actionsUrl + "/" + actionDef.getId()));
|
||||||
|
@@ -67,7 +67,7 @@ public class DispositionActionDefinitionDelete extends DispositionAbstractBase
|
|||||||
{
|
{
|
||||||
if (dispositionActionDefinition.getIndex() >= index)
|
if (dispositionActionDefinition.getIndex() >= index)
|
||||||
{
|
{
|
||||||
dispositionService.removeDispositionActionDefinition(schedule, dispositionActionDefinition);
|
getDispositionService().removeDispositionActionDefinition(schedule, dispositionActionDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,7 @@ public class DispositionActionDefinitionPost extends DispositionAbstractBase
|
|||||||
|
|
||||||
if (json.has("periodProperty"))
|
if (json.has("periodProperty"))
|
||||||
{
|
{
|
||||||
QName periodProperty = QName.createQName(json.getString("periodProperty"), this.namespaceService);
|
QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService());
|
||||||
props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty);
|
props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +154,6 @@ public class DispositionActionDefinitionPost extends DispositionAbstractBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add the action definition to the schedule
|
// add the action definition to the schedule
|
||||||
return this.dispositionService.addDispositionActionDefinition(schedule, props);
|
return getDispositionService().addDispositionActionDefinition(schedule, props);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -41,7 +41,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to update an existing dispositon
|
* Implementation for Java backed webscript to update an existing dispositon
|
||||||
* action definition.
|
* action definition.
|
||||||
*
|
*
|
||||||
* @author Gavin Cornwell
|
* @author Gavin Cornwell
|
||||||
*/
|
*/
|
||||||
public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
||||||
@@ -84,7 +84,7 @@ public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a dispositionActionDefinition node in the repo.
|
* Updates a dispositionActionDefinition node in the repo.
|
||||||
*
|
*
|
||||||
* @param actionDef The action definition to update
|
* @param actionDef The action definition to update
|
||||||
* @param json The JSON to use to create the action definition
|
* @param json The JSON to use to create the action definition
|
||||||
* @param schedule The DispositionSchedule the action definition belongs to
|
* @param schedule The DispositionSchedule the action definition belongs to
|
||||||
@@ -113,7 +113,7 @@ public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
|||||||
|
|
||||||
if (json.has("periodProperty"))
|
if (json.has("periodProperty"))
|
||||||
{
|
{
|
||||||
QName periodProperty = QName.createQName(json.getString("periodProperty"), this.namespaceService);
|
QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService());
|
||||||
props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty);
|
props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +153,6 @@ public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the action definition
|
// update the action definition
|
||||||
return this.dispositionService.updateDispositionActionDefinition(actionDef, props);
|
return getDispositionService().updateDispositionActionDefinition(actionDef, props);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -36,23 +36,23 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to return full details
|
* Implementation for Java backed webscript to return full details
|
||||||
* about a disposition lifecycle (next disposition action).
|
* about a disposition lifecycle (next disposition action).
|
||||||
*
|
*
|
||||||
* @author Gavin Cornwell
|
* @author Gavin Cornwell
|
||||||
*/
|
*/
|
||||||
public class DispositionLifecycleGet extends DispositionAbstractBase
|
public class DispositionLifecycleGet extends DispositionAbstractBase
|
||||||
{
|
{
|
||||||
PersonService personService;
|
PersonService personService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the PersonService instance
|
* Sets the PersonService instance
|
||||||
*
|
*
|
||||||
* @param personService The PersonService instance
|
* @param personService The PersonService instance
|
||||||
*/
|
*/
|
||||||
public void setPersonService(PersonService personService)
|
public void setPersonService(PersonService personService)
|
||||||
{
|
{
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||||
*/
|
*/
|
||||||
@@ -61,9 +61,9 @@ public class DispositionLifecycleGet extends DispositionAbstractBase
|
|||||||
{
|
{
|
||||||
// parse the request to retrieve the next action
|
// parse the request to retrieve the next action
|
||||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||||
|
|
||||||
// make sure the node passed in has a next action attached
|
// make sure the node passed in has a next action attached
|
||||||
DispositionAction nextAction = this.dispositionService.getNextDispositionAction(nodeRef);
|
DispositionAction nextAction = getDispositionService().getNextDispositionAction(nodeRef);
|
||||||
if (nextAction == null)
|
if (nextAction == null)
|
||||||
{
|
{
|
||||||
Map<String, Object> nextActionModel = new HashMap<String, Object>(2);
|
Map<String, Object> nextActionModel = new HashMap<String, Object>(2);
|
||||||
@@ -81,84 +81,84 @@ public class DispositionLifecycleGet extends DispositionAbstractBase
|
|||||||
nextActionModel.put("url", serviceUrl);
|
nextActionModel.put("url", serviceUrl);
|
||||||
nextActionModel.put("name", nextAction.getName());
|
nextActionModel.put("name", nextAction.getName());
|
||||||
nextActionModel.put("label", nextAction.getLabel());
|
nextActionModel.put("label", nextAction.getLabel());
|
||||||
nextActionModel.put("eventsEligible", this.dispositionService.isNextDispositionActionEligible(nodeRef));
|
nextActionModel.put("eventsEligible", getDispositionService().isNextDispositionActionEligible(nodeRef));
|
||||||
|
|
||||||
if (nextAction.getAsOfDate() != null)
|
if (nextAction.getAsOfDate() != null)
|
||||||
{
|
{
|
||||||
nextActionModel.put("asOf", ISO8601DateFormat.format(nextAction.getAsOfDate()));
|
nextActionModel.put("asOf", ISO8601DateFormat.format(nextAction.getAsOfDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextAction.getStartedAt() != null)
|
if (nextAction.getStartedAt() != null)
|
||||||
{
|
{
|
||||||
nextActionModel.put("startedAt", ISO8601DateFormat.format(nextAction.getStartedAt()));
|
nextActionModel.put("startedAt", ISO8601DateFormat.format(nextAction.getStartedAt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String startedBy = nextAction.getStartedBy();
|
String startedBy = nextAction.getStartedBy();
|
||||||
if (startedBy != null)
|
if (startedBy != null)
|
||||||
{
|
{
|
||||||
nextActionModel.put("startedBy", startedBy);
|
nextActionModel.put("startedBy", startedBy);
|
||||||
addUsersRealName(nextActionModel, startedBy, "startedBy");
|
addUsersRealName(nextActionModel, startedBy, "startedBy");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextAction.getCompletedAt() != null)
|
if (nextAction.getCompletedAt() != null)
|
||||||
{
|
{
|
||||||
nextActionModel.put("completedAt", ISO8601DateFormat.format(nextAction.getCompletedAt()));
|
nextActionModel.put("completedAt", ISO8601DateFormat.format(nextAction.getCompletedAt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String completedBy = nextAction.getCompletedBy();
|
String completedBy = nextAction.getCompletedBy();
|
||||||
if (completedBy != null)
|
if (completedBy != null)
|
||||||
{
|
{
|
||||||
nextActionModel.put("completedBy", completedBy);
|
nextActionModel.put("completedBy", completedBy);
|
||||||
addUsersRealName(nextActionModel, completedBy, "completedBy");
|
addUsersRealName(nextActionModel, completedBy, "completedBy");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> events = new ArrayList<Map<String, Object>>();
|
List<Map<String, Object>> events = new ArrayList<Map<String, Object>>();
|
||||||
for (EventCompletionDetails event : nextAction.getEventCompletionDetails())
|
for (EventCompletionDetails event : nextAction.getEventCompletionDetails())
|
||||||
{
|
{
|
||||||
events.add(createEventModel(event));
|
events.add(createEventModel(event));
|
||||||
}
|
}
|
||||||
nextActionModel.put("events", events);
|
nextActionModel.put("events", events);
|
||||||
|
|
||||||
// create model object with just the schedule data
|
// create model object with just the schedule data
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
model.put("nextaction", nextActionModel);
|
model.put("nextaction", nextActionModel);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to create a model to represent the given event execution.
|
* Helper to create a model to represent the given event execution.
|
||||||
*
|
*
|
||||||
* @param event The event to create a model for
|
* @param event The event to create a model for
|
||||||
* @return Map representing the model
|
* @return Map representing the model
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> createEventModel(EventCompletionDetails event)
|
protected Map<String, Object> createEventModel(EventCompletionDetails event)
|
||||||
{
|
{
|
||||||
Map<String, Object> model = new HashMap<String, Object>(8);
|
Map<String, Object> model = new HashMap<String, Object>(8);
|
||||||
|
|
||||||
model.put("name", event.getEventName());
|
model.put("name", event.getEventName());
|
||||||
model.put("label", event.getEventLabel());
|
model.put("label", event.getEventLabel());
|
||||||
model.put("automatic", event.isEventExecutionAutomatic());
|
model.put("automatic", event.isEventExecutionAutomatic());
|
||||||
model.put("complete", event.isEventComplete());
|
model.put("complete", event.isEventComplete());
|
||||||
|
|
||||||
String completedBy = event.getEventCompletedBy();
|
String completedBy = event.getEventCompletedBy();
|
||||||
if (completedBy != null)
|
if (completedBy != null)
|
||||||
{
|
{
|
||||||
model.put("completedBy", completedBy);
|
model.put("completedBy", completedBy);
|
||||||
addUsersRealName(model, completedBy, "completedBy");
|
addUsersRealName(model, completedBy, "completedBy");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEventCompletedAt() != null)
|
if (event.getEventCompletedAt() != null)
|
||||||
{
|
{
|
||||||
model.put("completedAt", ISO8601DateFormat.format(event.getEventCompletedAt()));
|
model.put("completedAt", ISO8601DateFormat.format(event.getEventCompletedAt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given username's first and last name to the given model.
|
* Adds the given username's first and last name to the given model.
|
||||||
*
|
*
|
||||||
* @param model The model to add the first and last name to
|
* @param model The model to add the first and last name to
|
||||||
* @param userName The username of the user to lookup
|
* @param userName The username of the user to lookup
|
||||||
* @param propertyPrefix The prefix of the property name to use when adding to the model
|
* @param propertyPrefix The prefix of the property name to use when adding to the model
|
||||||
@@ -168,13 +168,13 @@ public class DispositionLifecycleGet extends DispositionAbstractBase
|
|||||||
NodeRef user = this.personService.getPerson(userName);
|
NodeRef user = this.personService.getPerson(userName);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
String firstName = (String)this.nodeService.getProperty(user, ContentModel.PROP_FIRSTNAME);
|
String firstName = (String) getNodeService().getProperty(user, ContentModel.PROP_FIRSTNAME);
|
||||||
if (firstName != null)
|
if (firstName != null)
|
||||||
{
|
{
|
||||||
model.put(propertyPrefix + "FirstName", firstName);
|
model.put(propertyPrefix + "FirstName", firstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
String lastName = (String)this.nodeService.getProperty(user, ContentModel.PROP_LASTNAME);
|
String lastName = (String) getNodeService().getProperty(user, ContentModel.PROP_LASTNAME);
|
||||||
if (lastName != null)
|
if (lastName != null)
|
||||||
{
|
{
|
||||||
model.put(propertyPrefix + "LastName", lastName);
|
model.put(propertyPrefix + "LastName", lastName);
|
||||||
|
@@ -85,7 +85,7 @@ public class RecordedVersionConfigGet extends AbstractRmWebScript implements Rec
|
|||||||
private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef)
|
private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
boolean isVersionPolicySelected = false;
|
boolean isVersionPolicySelected = false;
|
||||||
String policy = (String) nodeService.getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY);
|
String policy = (String) getNodeService().getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY);
|
||||||
if (StringUtils.isNotBlank(policy))
|
if (StringUtils.isNotBlank(policy))
|
||||||
{
|
{
|
||||||
if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy))
|
if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy))
|
||||||
|
@@ -52,7 +52,7 @@ public class RecordedVersionConfigPost extends AbstractRmWebScript implements Re
|
|||||||
{
|
{
|
||||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||||
RecordableVersionPolicy recordableVersionPolicy = getRecordableVersionPolicy(req);
|
RecordableVersionPolicy recordableVersionPolicy = getRecordableVersionPolicy(req);
|
||||||
nodeService.setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy);
|
getNodeService().setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy);
|
||||||
return new HashMap<String, Object>(1);
|
return new HashMap<String, Object>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -227,7 +227,7 @@ public final class WebScriptUtils
|
|||||||
checkMandatoryJsonParam(jsonObject, key);
|
checkMandatoryJsonParam(jsonObject, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
String value;
|
String value = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -239,7 +239,10 @@ public final class WebScriptUtils
|
|||||||
}
|
}
|
||||||
catch (JSONException error)
|
catch (JSONException error)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the key '" + key + "'.", error);
|
if (checkValue)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the key '" + key + "'.", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
Reference in New Issue
Block a user