diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties index 974ad73783..ca78b1ce13 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties @@ -58,20 +58,6 @@ rm.record.contributors.group.enabled=false # record contributors group, default value 'RECORD_CONTRIBUTORS' rm.record.contributors.group.name=RECORD_CONTRIBUTORS -# -# Classified records -# -# The location of the classification reasons configuration file (relative to the classpath). -rm.classification.reasonsFile=/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json -# The location of the exemption categories configuration file (relative to the classpath). -rm.classification.exemptionCategoriesFile=/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json - -# -# Caveats -# -# The location of the caveats configuration file (relative to the classpath). -rm.caveat.configFile=/alfresco/module/org_alfresco_module_rm/caveat/rm-caveats.json - # # Content cleansing # diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/caveat-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/caveat-context.xml deleted file mode 100644 index ddae414f88..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/caveat-context.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatSchemeService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatSchemeService.existsCaveatGroup=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatSchemeService.getCaveatGroup=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatSchemeService.getCaveatGroups=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatSchemeService.*=ACL_DENY - - - - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/caveat/rm-caveats.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/caveat/rm-caveats.json deleted file mode 100644 index db9d2069fd..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/caveat/rm-caveats.json +++ /dev/null @@ -1,69 +0,0 @@ -[ - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.label", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "model" : - { - "property" : "clf:currentClassification" - }, - "marks" : - [ - { - "id" : "TS", - "displayLabel" : "rm.caveat.classification.mark.ts.label" - }, - { - "id" : "S", - "displayLabel" : "rm.caveat.classification.mark.s.label" - }, - { - "id" : "C", - "displayLabel" : "rm.caveat.classification.mark.c.label" - } - ] - }, - { - "id" : "nationality", - "displayLabel" : "rm.caveat.nationality.label", - "description" : "rm.caveat.nationality.description", - "type" : "USER_REQUIRES_ANY", - "marks" : - [ - { - "id" : "GBR", - "displayLabel" : "rm.caveat.nationality.mark.gbr.label" - }, - { - "id" : "CAN", - "displayLabel" : "rm.caveat.nationality.mark.can.label" - }, - { - "id" : "AUS", - "displayLabel" : "rm.caveat.nationality.mark.aus.label" - } - ] - }, - { - "id" : "training", - "displayLabel" : "rm.caveat.training.label", - "description" : "rm.caveat.training.description", - "type" : "USER_REQUIRES_ALL", - "marks" : - [ - { - "id" : "SA", - "displayLabel" : "rm.caveat.training.mark.securityAwareness.label" - }, - { - "id" : "DPT", - "displayLabel" : "rm.caveat.training.mark.dataProtectionTraining.label" - }, - { - "id" : "IFP", - "displayLabel" : "rm.caveat.training.mark.interprettingFinancialPredictions.label" - } - ] - } -] \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json deleted file mode 100644 index feece10abd..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "id" : "1.4(a)", - "displayLabel" : "rm.classification-reason.14a" - }, - { - "id" : "1.4(b)", - "displayLabel" : "rm.classification-reason.14b" - }, - { - "id" : "1.4(c)", - "displayLabel" : "rm.classification-reason.14c" - }, - { - "id" : "1.4(d)", - "displayLabel" : "rm.classification-reason.14d" - }, - { - "id" : "1.4(e)", - "displayLabel" : "rm.classification-reason.14e" - }, - { - "id" : "1.4(f)", - "displayLabel" : "rm.classification-reason.14f" - }, - { - "id" : "1.4(g)", - "displayLabel" : "rm.classification-reason.14g" - } -] diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json deleted file mode 100644 index 1be3f54b5c..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "id" : "1", - "displayLabel" : "rm.exemption-category.1" - }, - { - "id" : "2", - "displayLabel" : "rm.exemption-category.2" - }, - { - "id" : "3", - "displayLabel" : "rm.exemption-category.3" - }, - { - "id" : "4", - "displayLabel" : "rm.exemption-category.4" - }, - { - "id" : "5", - "displayLabel" : "rm.exemption-category.5" - }, - { - "id" : "6", - "displayLabel" : "rm.exemption-category.6" - }, - { - "id" : "7", - "displayLabel" : "rm.exemption-category.7" - }, - { - "id" : "8", - "displayLabel" : "rm.exemption-category.8" - }, - { - "id" : "9", - "displayLabel" : "rm.exemption-category.9" - } -] diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml deleted file mode 100644 index 5750b8b125..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - - - - - - alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml - - - - - alfresco/module/org_alfresco_module_rm/messages/classified-content-model - - - - - - - - - - alfresco.module.org_alfresco_module_rm.messages.classified-content - alfresco.module.org_alfresco_module_rm.messages.classified-content-notForTranslating - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getClassificationLevels=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getAllClassificationLevels=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getClassificationReasons=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getClassificationLevelById=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getClassificationReasonById=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getUnclassifiedClassificationLevel=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getExemptionCategories=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getReclassification=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getReclassificationValues=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.getExemptionCategoryById=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.*=ACL_DENY - - - - - - - - - - - - - - - - - - - - - clf:classified - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.getUserSecurityClearance=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.getUsersSecurityClearance=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.isCurrentUserClearedForClassification=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.setUserSecurityClearance=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.getClearanceLevels=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.hasCurrentUserClearance=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.hasUserClearance=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService.*=ACL_DENY - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.getCurrentClassification=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.classifyContent=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.hasClearance=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.editClassifiedContent=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService.*=ACL_DENY - - - - - - - - - - - - - - - - - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/content-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/content-context.xml index b2abf97fca..f019c27a3e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/content-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/content-context.xml @@ -13,27 +13,24 @@ - - - - - - + + + - + - + - + - + - + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml index 45629a6076..123ff3f912 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml @@ -26,15 +26,6 @@ - - - - - - - - - @@ -95,23 +86,23 @@ - + - + - + - + - + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model.properties deleted file mode 100644 index ac4086ae5c..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Classified Content Model -clf_classifiedcontent.property.cm_initialClassification.title=Initial Classification -clf_classifiedcontent.property.cm_initialClassification_description=The initial classification -clf_classifiedcontent.property.cm_currentClassification_title=Current Classification -clf_classifiedcontent.property.cm_currentClassification_description=The current classification. Set to the same as initial classification -clf_classifiedcontent.property.cm_classificationAgency_title=Classification Agency -clf_classifiedcontent.property.cm_classificationAgency_description=The classification agency -clf_classifiedcontent.property.cm_classifiedBy_title=Classified By -clf_classifiedcontent.property.cm_classifiedBy_description=Name of whoever has applied the classification -clf_classifiedcontent.property.cm_classificationReasons_title=Classification Reasons -clf_classifiedcontent.property.cm_classificationReasons_description=Holds the ids of classification reasons -clf_classifiedcontent.property.cm_downgradeDate_title=Downgrade Date -clf_classifiedcontent.property.cm_downgradeDate_description=The date when the classification may be downgraded -clf_classifiedcontent.property.cm_downgradeEvent_title=Downgrade Event -clf_classifiedcontent.property.cm_downgradeEvent_description=An event for which the classification may be downgraded -clf_classifiedcontent.property.cm_downgradeInstructions_title=Downgrade Instructions -clf_classifiedcontent.property.cm_downgradeInstructions_description=Instructions to be followed when considering whether to downgrade the classification -clf_classifiedcontent.property.cm_declassificationDate_title=Declassification Date -clf_classifiedcontent.property.cm_declassificationDate_description=The date when this may be declassified -clf_classifiedcontent.property.cm_declassificationEvent_title=Declassification Event -clf_classifiedcontent.property.cm_declassificationEvent_description=The event when this may be declassified -clf_classifiedcontent.property.cm_declassificationExemptions_title=Declassification Exemptions -clf_classifiedcontent.property.cm_declassificationExemptions_description=Exemptions that may preclude this from being declassified -clf_classifiedcontent.property.cm_lastReclassificationAction_title=Last Reclassification Action -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Text identifying the type of the previous reclassification on this node -clf_classifiedcontent.property.cm_lastReclassifyBy_title=Last user to reclassify this node -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Free form text identifier for the user or entity who most recently reclassified this node -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Last reclassification date -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Date for when this node was last reclassified -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Last reclassification reason -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Text giving the reason for the last reclassification diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_de.properties deleted file mode 100644 index c6f5a3c4ed..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_de.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Klassifiziertes Content-Modell -clf_classifiedcontent.property.cm_initialClassification.title=Urspr\u00fcngliche Klassifizierung -clf_classifiedcontent.property.cm_initialClassification_description=Die urspr\u00fcngliche Klassifizierung. -clf_classifiedcontent.property.cm_currentClassification_title=Momentane Klassifizierung -clf_classifiedcontent.property.cm_currentClassification_description=Die momentane Klassifizierung. Auf urspr\u00fcngliche Klassifizierung setzen -clf_classifiedcontent.property.cm_classificationAgency_title=Klassifizierungsbeh\u00f6rde -clf_classifiedcontent.property.cm_classificationAgency_description=Die Klassifizierungsbeh\u00f6rde. -clf_classifiedcontent.property.cm_classifiedBy_title=Klassifiziert von -clf_classifiedcontent.property.cm_classifiedBy_description=Name der Person, die die Klassifizierung eingerichtet hat -clf_classifiedcontent.property.cm_classificationReasons_title=Gr\u00fcnde f\u00fcr Klassifizierung -clf_classifiedcontent.property.cm_classificationReasons_description=Enth\u00e4lt die IDs der Klassifizierungsgr\u00fcnde -clf_classifiedcontent.property.cm_downgradeDate_title=Herunterstufungsdatum -clf_classifiedcontent.property.cm_downgradeDate_description=Datum, an dem die Klassifzierung heruntergestuft werden kann -clf_classifiedcontent.property.cm_downgradeEvent_title=Herunterstufungsereignis -clf_classifiedcontent.property.cm_downgradeEvent_description=Ein Ereignis, f\u00fcr das die Klassifizierung heruntergestuft werden kann -clf_classifiedcontent.property.cm_downgradeInstructions_title=Herunterstufungsanweisungen -clf_classifiedcontent.property.cm_downgradeInstructions_description=Anweisungen, die zu befolgen sind, wenn eine Herunterstufung der Klassifizierung in Betracht gezogen wird -clf_classifiedcontent.property.cm_declassificationDate_title=Deklassifizierungsdatum -clf_classifiedcontent.property.cm_declassificationDate_description=Das Datum, an dem die Klassifizierung aufgehoben werden kann -clf_classifiedcontent.property.cm_declassificationEvent_title=Deklassifizierungsereignis -clf_classifiedcontent.property.cm_declassificationEvent_description=Ein Ereignis, f\u00fcr das die Klassifizierung aufgehoben werden kann -clf_classifiedcontent.property.cm_declassificationExemptions_title=Deklassifizierungsausnahmen -clf_classifiedcontent.property.cm_declassificationExemptions_description=Ausnahmen, die eine Deklassifizierung verhindern k\u00f6nnen -clf_classifiedcontent.property.cm_lastReclassificationAction_title=Letzte Reklassifizierungsaktion -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Text, der die Art der vorherigen Reklassifizierung dieses Knoten beschreibt -clf_classifiedcontent.property.cm_lastReclassifyBy_title=Letzter Benutzer, der diesen Knoten reklassifiziert hat -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Freier Text, der den Benutzer angibt, der diesen Knoten zuletzt reklassifiziert hat -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Letztes Reklassifizierungsdatum -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Datum der letzten Reklassifizierung dieses Knoten -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Grund f\u00fcr letzte Reklassifizierung -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Text, der den Grund f\u00fcr die letzte Reklassifizierung angibt \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_es.properties deleted file mode 100644 index 44249877be..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_es.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Modelo de contenido clasificado -clf_classifiedcontent.property.cm_initialClassification.title=Clasificaci\u00f3n inicial -clf_classifiedcontent.property.cm_initialClassification_description=La clasificaci\u00f3n inicial -clf_classifiedcontent.property.cm_currentClassification_title=Clasificaci\u00f3n actual -clf_classifiedcontent.property.cm_currentClassification_description=La clasificaci\u00f3n actual. Configurado al igual que la clasificaci\u00f3n inicial -clf_classifiedcontent.property.cm_classificationAgency_title=Agencia de clasificaci\u00f3n -clf_classifiedcontent.property.cm_classificationAgency_description=La agencia de clasificaci\u00f3n -clf_classifiedcontent.property.cm_classifiedBy_title=Clasificado por -clf_classifiedcontent.property.cm_classifiedBy_description=Nombre de quien haya aplicado la clasificaci\u00f3n -clf_classifiedcontent.property.cm_classificationReasons_title=Razones de clasificaci\u00f3n -clf_classifiedcontent.property.cm_classificationReasons_description=Mantiene las Id\ -clf_classifiedcontent.property.cm_downgradeDate_title=Fecha de degradaci\u00f3n -clf_classifiedcontent.property.cm_downgradeDate_description=La fecha en la que la clasificaci\u00f3n puede degradarse -clf_classifiedcontent.property.cm_downgradeEvent_title=Evento de degradaci\u00f3n -clf_classifiedcontent.property.cm_downgradeEvent_description=Un evento para el que la clasificaci\u00f3n puede degradarse -clf_classifiedcontent.property.cm_downgradeInstructions_title=Instrucciones de degradaci\u00f3n -clf_classifiedcontent.property.cm_downgradeInstructions_description=Instrucciones que deben seguirse si se est\u00e1 considerando degradar la clasificaci\u00f3n -clf_classifiedcontent.property.cm_declassificationDate_title=Fecha de desclasificaci\u00f3n -clf_classifiedcontent.property.cm_declassificationDate_description=La fecha en la que esto puede desclasificarse -clf_classifiedcontent.property.cm_declassificationEvent_title=Evento de desclasificaci\u00f3n -clf_classifiedcontent.property.cm_declassificationEvent_description=El evento cuando esto puede desclasificarse -clf_classifiedcontent.property.cm_declassificationExemptions_title=Exenciones de desclasificaci\u00f3n -clf_classifiedcontent.property.cm_declassificationExemptions_description=Exenciones que pueden impedir que esto se desclasifique -clf_classifiedcontent.property.cm_lastReclassificationAction_title=\u00daltima acci\u00f3n de reclasificaci\u00f3n -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Texto que identifica el tipo de reclasificaci\u00f3n previa en este nodo -clf_classifiedcontent.property.cm_lastReclassifyBy_title=\u00daltimo usuario en reclasificar este nodo -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Identificador de texto de forma libre para el usuario o entidad que reclasific\u00f3 este nodo m\u00e1s recientemente -clf_classifiedcontent.property.cm_lastReclassifyAt_title=\u00daltima fecha de reclasificaci\u00f3n -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Fecha en la que este nodo se reclasific\u00f3 por \u00faltima vez -clf_classifiedcontent.property.cm_lastReclassifyReason_title=\u00daltima raz\u00f3n de reclasificaci\u00f3n -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Texto con la raz\u00f3n de la \u00faltima reclasificaci\u00f3n \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_fr.properties deleted file mode 100644 index 29937e2934..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_fr.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Mod\u00e8le de contenu class\u00e9 -clf_classifiedcontent.property.cm_initialClassification.title=Classement initial -clf_classifiedcontent.property.cm_initialClassification_description=Le classement initial -clf_classifiedcontent.property.cm_currentClassification_title=Classement actuel -clf_classifiedcontent.property.cm_currentClassification_description=Le classement actuel. D\u00e9finir de la m\u00eame mani\u00e8re que le classement initial -clf_classifiedcontent.property.cm_classificationAgency_title=Agence de classement -clf_classifiedcontent.property.cm_classificationAgency_description=L'agence de classement -clf_classifiedcontent.property.cm_classifiedBy_title=Class\u00e9 par -clf_classifiedcontent.property.cm_classifiedBy_description=Nom de la personne qui a appliqu\u00e9 la classification -clf_classifiedcontent.property.cm_classificationReasons_title=Motifs du classement -clf_classifiedcontent.property.cm_classificationReasons_description=Contient les identifiants des motifs du classement -clf_classifiedcontent.property.cm_downgradeDate_title=Date de r\u00e9trogradation -clf_classifiedcontent.property.cm_downgradeDate_description=Date \u00e0 laquelle la classification peut \u00eatre r\u00e9trograd\u00e9e -clf_classifiedcontent.property.cm_downgradeEvent_title=Ev\u00e9nement de r\u00e9trogradation -clf_classifiedcontent.property.cm_downgradeEvent_description=Ev\u00e9nement \u00e0 la suite duquel la classification peut \u00eatre r\u00e9trograd\u00e9e -clf_classifiedcontent.property.cm_downgradeInstructions_title=Instructions de r\u00e9trogradation -clf_classifiedcontent.property.cm_downgradeInstructions_description=Instructions \u00e0 suivre lorsque la r\u00e9trogradation de la classification est envisag\u00e9e -clf_classifiedcontent.property.cm_declassificationDate_title=Date de d\u00e9classification -clf_classifiedcontent.property.cm_declassificationDate_description=Date \u00e0 laquelle le contenu peut \u00eatre d\u00e9classifi\u00e9 -clf_classifiedcontent.property.cm_declassificationEvent_title=Ev\u00e9nement de d\u00e9classification -clf_classifiedcontent.property.cm_declassificationEvent_description=Ev\u00e9nement \u00e0 la suite duquel le contenu peut \u00eatre d\u00e9classifi\u00e9 -clf_classifiedcontent.property.cm_declassificationExemptions_title=Exemptions de d\u00e9classification -clf_classifiedcontent.property.cm_declassificationExemptions_description=Exemptions susceptibles d'exclure la d\u00e9classification du contenu -clf_classifiedcontent.property.cm_lastReclassificationAction_title=Derni\u00e8re action de reclassification -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Texte qui identifie le type de la reclassification pr\u00e9c\u00e9dente sur ce n\u0153ud -clf_classifiedcontent.property.cm_lastReclassifyBy_title=Dernier utilisateur ayant reclassifi\u00e9 ce n\u0153ud -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Texte libre identifiant l'utilisateur ou entit\u00e9 ayant reclassifi\u00e9 ce n\u0153ud en dernier -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Date de la derni\u00e8re reclassification -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Date de la derni\u00e8re reclassification du n\u0153ud -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Motif de la derni\u00e8re reclassification -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Texte indiquant le motif de la derni\u00e8re reclassification \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_it.properties deleted file mode 100644 index 2061e5bce0..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_it.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Modello di contenuto classificato -clf_classifiedcontent.property.cm_initialClassification.title=Classificazione iniziale -clf_classifiedcontent.property.cm_initialClassification_description=La classificazione iniziale -clf_classifiedcontent.property.cm_currentClassification_title=Classificazione attuale -clf_classifiedcontent.property.cm_currentClassification_description=La classificazione attuale Impostare sullo stesso valore di Classificazione iniziale -clf_classifiedcontent.property.cm_classificationAgency_title=Agenzia di classificazione -clf_classifiedcontent.property.cm_classificationAgency_description=L'agenzia responsabile della classificazione -clf_classifiedcontent.property.cm_classifiedBy_title=Classificato da -clf_classifiedcontent.property.cm_classifiedBy_description=Il nome dell'utente che ha applicato la classificazione -clf_classifiedcontent.property.cm_classificationReasons_title=Motivi di classificazione -clf_classifiedcontent.property.cm_classificationReasons_description=Include gli ID dei motivi di classificazione -clf_classifiedcontent.property.cm_downgradeDate_title=Data di downgrade -clf_classifiedcontent.property.cm_downgradeDate_description=La data in cui potrebbe essere eseguito il downgrade della classificazione -clf_classifiedcontent.property.cm_downgradeEvent_title=Evento di downgrade -clf_classifiedcontent.property.cm_downgradeEvent_description=Un evento che potrebbe comportare il downgrade della classificazione -clf_classifiedcontent.property.cm_downgradeInstructions_title=Istruzioni di downgrade -clf_classifiedcontent.property.cm_downgradeInstructions_description=Le istruzioni da seguire quando si considera se eseguire o meno il downgrade della classificazione -clf_classifiedcontent.property.cm_declassificationDate_title=Data di declassificazione -clf_classifiedcontent.property.cm_declassificationDate_description=La data in cui potrebbe essere eseguita la declassificazione -clf_classifiedcontent.property.cm_declassificationEvent_title=Evento di declassificazione -clf_classifiedcontent.property.cm_declassificationEvent_description=L'evento in occasione del quale potrebbe essere eseguita la declassificazione -clf_classifiedcontent.property.cm_declassificationExemptions_title=Esenzioni declassificazione -clf_classifiedcontent.property.cm_declassificationExemptions_description=Le esenzioni che potrebbero impedire la declassificazione dei contenuti -clf_classifiedcontent.property.cm_lastReclassificationAction_title=Azione ultima riclassificazione -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Testo che identifica l'ultimo tipo di riclassificazione eseguita su questo nodo -clf_classifiedcontent.property.cm_lastReclassifyBy_title=Ultimo utente che ha riclassificato il nodo -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Identificatore, in formato libero, dell'utente o dell'entit\u00e0 che ha riclassificato pi\u00f9 di recente questo nodo -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Data ultima riclassificazione -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Data in cui il nodo \u00e8 stato riclassificato l'ultima volta -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Motivo ultima riclassificazione -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Testo che spiega il motivo dell'ultima riclassificazione \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_ja.properties deleted file mode 100644 index 1dfe87ae26..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_ja.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=\u5206\u985e\u3055\u308c\u305f\u30b3\u30f3\u30c6\u30f3\u30c4\u30e2\u30c7\u30eb -clf_classifiedcontent.property.cm_initialClassification.title=\u6700\u521d\u306e\u5206\u985e -clf_classifiedcontent.property.cm_initialClassification_description=\u6700\u521d\u306e\u5206\u985e -clf_classifiedcontent.property.cm_currentClassification_title=\u73fe\u5728\u306e\u5206\u985e -clf_classifiedcontent.property.cm_currentClassification_description=\u73fe\u5728\u306e\u5206\u985e\u3002 \u6700\u521d\u306e\u5206\u985e\u3068\u540c\u3058\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059 -clf_classifiedcontent.property.cm_classificationAgency_title=\u5206\u985e\u6a5f\u95a2 -clf_classifiedcontent.property.cm_classificationAgency_description=\u5206\u985e\u6a5f\u95a2 -clf_classifiedcontent.property.cm_classifiedBy_title=\u5206\u985e\u62c5\u5f53\u8005 -clf_classifiedcontent.property.cm_classifiedBy_description=\u5206\u985e\u3092\u9069\u7528\u3057\u305f\u62c5\u5f53\u8005\u306e\u540d\u524d -clf_classifiedcontent.property.cm_classificationReasons_title=\u5206\u985e\u7406\u7531 -clf_classifiedcontent.property.cm_classificationReasons_description=\u5206\u985e\u7406\u7531\u306e ID -clf_classifiedcontent.property.cm_downgradeDate_title=\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u65e5 -clf_classifiedcontent.property.cm_downgradeDate_description=\u5206\u985e\u3092\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u3059\u308b\u65e5 -clf_classifiedcontent.property.cm_downgradeEvent_title=\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u30a4\u30d9\u30f3\u30c8 -clf_classifiedcontent.property.cm_downgradeEvent_description=\u5206\u985e\u3092\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u3059\u308b\u305f\u3081\u306e\u30a4\u30d9\u30f3\u30c8 -clf_classifiedcontent.property.cm_downgradeInstructions_title=\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u624b\u9806 -clf_classifiedcontent.property.cm_downgradeInstructions_description=\u5206\u985e\u3092\u30c0\u30a6\u30f3\u30b0\u30ec\u30fc\u30c9\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3059\u308b\u3068\u304d\u306e\u624b\u9806 -clf_classifiedcontent.property.cm_declassificationDate_title=\u5206\u985e\u89e3\u9664\u65e5 -clf_classifiedcontent.property.cm_declassificationDate_description=\u3053\u306e\u30ce\u30fc\u30c9\u306e\u5206\u985e\u3092\u89e3\u9664\u3059\u308b\u65e5 -clf_classifiedcontent.property.cm_declassificationEvent_title=\u5206\u985e\u89e3\u9664\u30a4\u30d9\u30f3\u30c8 -clf_classifiedcontent.property.cm_declassificationEvent_description=\u3053\u306e\u30ce\u30fc\u30c9\u306e\u5206\u985e\u3092\u89e3\u9664\u3059\u308b\u3068\u304d\u306e\u30a4\u30d9\u30f3\u30c8 -clf_classifiedcontent.property.cm_declassificationExemptions_title=\u5206\u985e\u89e3\u9664\u306e\u5bfe\u8c61\u5916 -clf_classifiedcontent.property.cm_declassificationExemptions_description=\u5206\u985e\u89e3\u9664\u306e\u5bfe\u8c61\u5916\u3068\u3059\u308b\u30d7\u30ed\u30d1\u30c6\u30a3 -clf_classifiedcontent.property.cm_lastReclassificationAction_title=\u524d\u56de\u306e\u518d\u5206\u985e\u30a2\u30af\u30b7\u30e7\u30f3 -clf_classifiedcontent.property.cm_lastReclassificationAction_description=\u3053\u306e\u30ce\u30fc\u30c9\u3067\u524d\u56de\u884c\u308f\u308c\u305f\u518d\u5206\u985e\u306e\u7a2e\u985e\u3092\u793a\u3059\u30c6\u30ad\u30b9\u30c8 -clf_classifiedcontent.property.cm_lastReclassifyBy_title=\u3053\u306e\u30ce\u30fc\u30c9\u3092\u524d\u56de\u518d\u5206\u985e\u3057\u305f\u30e6\u30fc\u30b6\u30fc -clf_classifiedcontent.property.cm_lastReclassifyBy_description=\u3053\u306e\u30ce\u30fc\u30c9\u3092\u524d\u56de\u518d\u5206\u985e\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u307e\u305f\u306f\u56e3\u4f53\u3092\u793a\u3059\u81ea\u7531\u5f62\u5f0f\u306e\u30c6\u30ad\u30b9\u30c8 -clf_classifiedcontent.property.cm_lastReclassifyAt_title=\u524d\u56de\u306e\u518d\u5206\u985e\u65e5 -clf_classifiedcontent.property.cm_lastReclassifyAt_description=\u3053\u306e\u30ce\u30fc\u30c9\u306e\u524d\u56de\u306e\u518d\u5206\u985e\u65e5 -clf_classifiedcontent.property.cm_lastReclassifyReason_title=\u524d\u56de\u306e\u518d\u5206\u985e\u7406\u7531 -clf_classifiedcontent.property.cm_lastReclassifyReason_description=\u524d\u56de\u306e\u518d\u5206\u985e\u306e\u7406\u7531\u3092\u8aac\u660e\u3059\u308b\u30c6\u30ad\u30b9\u30c8 \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_nb.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_nb.properties deleted file mode 100644 index 4c21101dd8..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_nb.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Klassifisert innholdsmodell -clf_classifiedcontent.property.cm_initialClassification.title=Utgangsklassifisering -clf_classifiedcontent.property.cm_initialClassification_description=Utgangsklassifiseringen -clf_classifiedcontent.property.cm_currentClassification_title=N\u00e5v\u00e6rende klassifisering -clf_classifiedcontent.property.cm_currentClassification_description=Den n\u00e5v\u00e6rende klassifiseringen Satt til samme som utgangsklassifiseringen -clf_classifiedcontent.property.cm_classificationAgency_title=Klassifiseringsorgan -clf_classifiedcontent.property.cm_classificationAgency_description=Klassifiseringsorganet -clf_classifiedcontent.property.cm_classifiedBy_title=Klassifisert av -clf_classifiedcontent.property.cm_classifiedBy_description=Navnet p\u00e5 personen som brukte klassifiseringen -clf_classifiedcontent.property.cm_classificationReasons_title=Klassifiseringsgrunner -clf_classifiedcontent.property.cm_classificationReasons_description=Holder ID-ene til klassifiseringsgrunnene -clf_classifiedcontent.property.cm_downgradeDate_title=Nedgraderingsdato -clf_classifiedcontent.property.cm_downgradeDate_description=Datoen n\u00e5r klassifiseringen kan nedgraderes -clf_classifiedcontent.property.cm_downgradeEvent_title=Nedgraderingshendelse -clf_classifiedcontent.property.cm_downgradeEvent_description=En hendelse der klassifiseringen kan nedgraderes -clf_classifiedcontent.property.cm_downgradeInstructions_title=Nedgraderingsinstruksjoner -clf_classifiedcontent.property.cm_downgradeInstructions_description=Instruksjoner som skal f\u00f8lge n\u00e5r nedgradering av klassifiseringen skal vurderes -clf_classifiedcontent.property.cm_declassificationDate_title=Deklassifiseringsdato -clf_classifiedcontent.property.cm_declassificationDate_description=Dato n\u00e5r dette kan deklassifiseres -clf_classifiedcontent.property.cm_declassificationEvent_title=Deklassifiseringshendelse -clf_classifiedcontent.property.cm_declassificationEvent_description=Dato n\u00e5r denne hendelsen kan deklassifiseres -clf_classifiedcontent.property.cm_declassificationExemptions_title=Deklassifiseringsunntak -clf_classifiedcontent.property.cm_declassificationExemptions_description=Uttak som kan utelukke dette fra \u00e5 deklassifiseres -clf_classifiedcontent.property.cm_lastReclassificationAction_title=Siste reklassifiseringshandling -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Tekst som identifiserer typen til den forrige reklassifiseringen p\u00e5 denne noden. -clf_classifiedcontent.property.cm_lastReclassifyBy_title=Siste bruker som reklassifiserte denne noden -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Tekstidentifikator med fri form til brukeren eller enheten som var den siste til \u00e5 reklassifisere denne noden. -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Siste reklassifiseringsdato -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Dato n\u00e5r denne noden sist ble reklassifisert -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Siste reklassifiseringsgrunn -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Tekst som gir grunnen til den siste reklassifisering \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_nl.properties deleted file mode 100644 index 15dcedc994..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_nl.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Model geclassificeerde content -clf_classifiedcontent.property.cm_initialClassification.title=Aanvankelijke classificatie -clf_classifiedcontent.property.cm_initialClassification_description=De aanvankelijke classificatie -clf_classifiedcontent.property.cm_currentClassification_title=Huidige classificatie -clf_classifiedcontent.property.cm_currentClassification_description=De huidige classificatie. Instellen op dezelfde waarde als die voor de aanvankelijke classificatie -clf_classifiedcontent.property.cm_classificationAgency_title=Classificatiebureau -clf_classifiedcontent.property.cm_classificationAgency_description=Het classificatiebureau -clf_classifiedcontent.property.cm_classifiedBy_title=Geclassificeerd door -clf_classifiedcontent.property.cm_classifiedBy_description=De naam van de persoon die de classificatie heeft toegepast -clf_classifiedcontent.property.cm_classificationReasons_title=Classificatieredenen -clf_classifiedcontent.property.cm_classificationReasons_description=Bevat de id\ -clf_classifiedcontent.property.cm_downgradeDate_title=Downgradedatum -clf_classifiedcontent.property.cm_downgradeDate_description=De datum waarop de classificatie kan worden gedowngraded -clf_classifiedcontent.property.cm_downgradeEvent_title=Downgradegebeurtenis -clf_classifiedcontent.property.cm_downgradeEvent_description=Een gebeurtenis waarvoor de classificatie kan worden gedowngraded -clf_classifiedcontent.property.cm_downgradeInstructions_title=Downgrade-instructies -clf_classifiedcontent.property.cm_downgradeInstructions_description=Instructies die moeten worden gevolgd bij de overweging of de classificatie moet worden gedowngraded -clf_classifiedcontent.property.cm_declassificationDate_title=Classificatieopheffingsdatum -clf_classifiedcontent.property.cm_declassificationDate_description=De datum waarop de classificatie kan worden opgeheven -clf_classifiedcontent.property.cm_declassificationEvent_title=Classificatieopheffingsgebeurtenis -clf_classifiedcontent.property.cm_declassificationEvent_description=De gebeurtenis waarbij de classificatie kan worden opgeheven -clf_classifiedcontent.property.cm_declassificationExemptions_title=Clasificatieopheffingsuitzonderingen -clf_classifiedcontent.property.cm_declassificationExemptions_description=Uitzonderingen die de classificatieopheffing kunnen uitsluiten -clf_classifiedcontent.property.cm_lastReclassificationAction_title=Laatste herclassificatie-actie -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Tekst die het type vorige herclassificatie voor deze node aangeeft -clf_classifiedcontent.property.cm_lastReclassifyBy_title=Laatste gebruiker die deze node heeft geherclassificeerd -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Vrije-tekst-identificatie voor de gebruiker of entiteit die deze node het laatst heeft geherclassificeerd -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Datum laatste herclassificatie -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Datum waarop deze node het laatst is geherclassificeerd -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Reden laatste herclassificatie -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Tekst met de reden voor de laatste herclassificatie \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_pt_BR.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_pt_BR.properties deleted file mode 100644 index 3bd719e546..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_pt_BR.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=Modelo de conte\u00fado classificado -clf_classifiedcontent.property.cm_initialClassification.title=Classifica\u00e7\u00e3o inicial -clf_classifiedcontent.property.cm_initialClassification_description=A classifica\u00e7\u00e3o inicial -clf_classifiedcontent.property.cm_currentClassification_title=Classifica\u00e7\u00e3o atual -clf_classifiedcontent.property.cm_currentClassification_description=A classifica\u00e7\u00e3o atual Definir no mesmo como classifica\u00e7\u00e3o inicial -clf_classifiedcontent.property.cm_classificationAgency_title=\u00d3rg\u00e3o de classifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_classificationAgency_description=O \u00f3rg\u00e3o de classifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_classifiedBy_title=Classificado por -clf_classifiedcontent.property.cm_classifiedBy_description=Nome de quem aplicou a classifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_classificationReasons_title=Motivos da classifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_classificationReasons_description=Tem as IDs dos motivos da classifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_downgradeDate_title=Data de rebaixamento -clf_classifiedcontent.property.cm_downgradeDate_description=A data em que a classifica\u00e7\u00e3o foi rebaixada (possivelmente) -clf_classifiedcontent.property.cm_downgradeEvent_title=Evento de rebaixamento -clf_classifiedcontent.property.cm_downgradeEvent_description=Um evento para o qual a classifica\u00e7\u00e3o foi rebaixada (possivelmente) -clf_classifiedcontent.property.cm_downgradeInstructions_title=Instru\u00e7\u00f5es de rebaixamento -clf_classifiedcontent.property.cm_downgradeInstructions_description=Instru\u00e7\u00f5es a serem seguidas quando o rebaixamento da classifica\u00e7\u00e3o for considerado -clf_classifiedcontent.property.cm_declassificationDate_title=Data de desclassifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_declassificationDate_description=A data em que isso pode ser desclassificado -clf_classifiedcontent.property.cm_declassificationEvent_title=Evento de desclassifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_declassificationEvent_description=O evento em que isso pode ser desclassificado -clf_classifiedcontent.property.cm_declassificationExemptions_title=Isen\u00e7\u00f5es de desclassifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_declassificationExemptions_description=Isen\u00e7\u00f5es que podem impedir este de ser desclassificado -clf_classifiedcontent.property.cm_lastReclassificationAction_title=A\u00e7\u00e3o da \u00faltima reclassifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_lastReclassificationAction_description=Texto que identifica o tipo de reclassifica\u00e7\u00e3o anterior neste n\u00f3 -clf_classifiedcontent.property.cm_lastReclassifyBy_title=\u00daltima usu\u00e1rio que reclassificou esse n\u00f3 -clf_classifiedcontent.property.cm_lastReclassifyBy_description=Identificador de texto de forma livre para o usu\u00e1rio ou entidade que mais recentemente reclassificou este n\u00f3 -clf_classifiedcontent.property.cm_lastReclassifyAt_title=Data da \u00faltima reclassifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_lastReclassifyAt_description=Data para quando esse n\u00f3 foi reclassificado pela \u00faltima vez -clf_classifiedcontent.property.cm_lastReclassifyReason_title=Raz\u00e3o da \u00faltima reclassifica\u00e7\u00e3o -clf_classifiedcontent.property.cm_lastReclassifyReason_description=Texto dando a raz\u00e3o para a \u00faltima reclassifica\u00e7\u00e3o \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_ru.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_ru.properties deleted file mode 100644 index 428a10aeb3..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_ru.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=\u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e -clf_classifiedcontent.property.cm_initialClassification.title=\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 -clf_classifiedcontent.property.cm_initialClassification_description=\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 -clf_classifiedcontent.property.cm_currentClassification_title=\u0422\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 -clf_classifiedcontent.property.cm_currentClassification_description=\u0422\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u041a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 -clf_classifiedcontent.property.cm_classificationAgency_title=\u0410\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_classificationAgency_description=\u0410\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_classifiedBy_title=\u0417\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0435\u043d\u043e (\u043a\u0435\u043c) -clf_classifiedcontent.property.cm_classifiedBy_description=\u0418\u043c\u044f \u043b\u0438\u0446\u0430, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432\u0448\u0435\u0433\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 -clf_classifiedcontent.property.cm_classificationReasons_title=\u041f\u0440\u0438\u0447\u0438\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 -clf_classifiedcontent.property.cm_classificationReasons_description=\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u0438\u0447\u0438\u043d \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 -clf_classifiedcontent.property.cm_downgradeDate_title=\u0414\u0430\u0442\u0430 \u043e\u0442\u043a\u0430\u0442\u0430 \u043a \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 -clf_classifiedcontent.property.cm_downgradeDate_description=\u0414\u0430\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0430\u0442\u0430 \u043a \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 -clf_classifiedcontent.property.cm_downgradeEvent_title=\u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442\u043a\u0430\u0442\u0430 \u043a \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 -clf_classifiedcontent.property.cm_downgradeEvent_description=\u0421\u043e\u0431\u044b\u0442\u0438\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0442\u043a\u0430\u0442 \u043a \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_downgradeInstructions_title=\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u043e\u0442\u043a\u0430\u0442\u0443 \u043a \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 -clf_classifiedcontent.property.cm_downgradeInstructions_description=\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0442\u043a\u0430\u0442\u0435 \u043a \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_declassificationDate_title=\u0414\u0430\u0442\u0430 \u043e\u0442\u043c\u0435\u043d\u044b \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_declassificationDate_description=\u0414\u0430\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u043e\u0442\u043c\u0435\u043d\u044b \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 -clf_classifiedcontent.property.cm_declassificationEvent_title=\u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442\u043c\u0435\u043d\u044b \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_declassificationEvent_description=\u0421\u043e\u0431\u044b\u0442\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u0442\u043c\u0435\u043d\u0443 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 -clf_classifiedcontent.property.cm_declassificationExemptions_title=\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_declassificationExemptions_description=\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043c\u0435\u043d\u0443 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 -clf_classifiedcontent.property.cm_lastReclassificationAction_title=\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c\u0443 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044e -clf_classifiedcontent.property.cm_lastReclassificationAction_description=\u0422\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 -clf_classifiedcontent.property.cm_lastReclassifyBy_title=\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432\u0448\u0438\u0439 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 -clf_classifiedcontent.property.cm_lastReclassifyBy_description=\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u043b\u0438\u0446\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432\u0448\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c. (\u0422\u0435\u043a\u0441\u0442 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435.) -clf_classifiedcontent.property.cm_lastReclassifyAt_title=\u0414\u0430\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_lastReclassifyAt_description=\u0414\u0430\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 -clf_classifiedcontent.property.cm_lastReclassifyReason_title=\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f -clf_classifiedcontent.property.cm_lastReclassifyReason_description=\u0422\u0435\u043a\u0441\u0442, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u044f \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_zh_CN.properties deleted file mode 100644 index 49c8baae7a..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-model_zh_CN.properties +++ /dev/null @@ -1,31 +0,0 @@ -clf_classifiedcontent.description=\u5df2\u5206\u7c7b\u5185\u5bb9\u6a21\u578b -clf_classifiedcontent.property.cm_initialClassification.title=\u521d\u59cb\u5206\u7c7b -clf_classifiedcontent.property.cm_initialClassification_description=\u521d\u59cb\u5206\u7c7b -clf_classifiedcontent.property.cm_currentClassification_title=\u5f53\u524d\u5206\u7c7b -clf_classifiedcontent.property.cm_currentClassification_description=\u5f53\u524d\u5206\u7c7b \u8bbe\u7f6e\u4e3a\u4e0e\u521d\u59cb\u5206\u7c7b\u76f8\u540c -clf_classifiedcontent.property.cm_classificationAgency_title=\u5206\u7c7b\u4ee3\u7406 -clf_classifiedcontent.property.cm_classificationAgency_description=\u5206\u7c7b\u4ee3\u7406 -clf_classifiedcontent.property.cm_classifiedBy_title=\u5206\u7c7b\u8005 -clf_classifiedcontent.property.cm_classifiedBy_description=\u5df2\u5e94\u7528\u5206\u7c7b\u7684\u4eba\u5458\u7684\u59d3\u540d -clf_classifiedcontent.property.cm_classificationReasons_title=\u5206\u7c7b\u539f\u56e0 -clf_classifiedcontent.property.cm_classificationReasons_description=\u4fdd\u5b58\u5206\u7c7b\u539f\u56e0\u7684 ID -clf_classifiedcontent.property.cm_downgradeDate_title=\u964d\u7ea7\u65e5\u671f -clf_classifiedcontent.property.cm_downgradeDate_description=\u53ef\u5bf9\u5206\u7c7b\u8fdb\u884c\u964d\u7ea7\u7684\u65e5\u671f -clf_classifiedcontent.property.cm_downgradeEvent_title=\u964d\u7ea7\u4e8b\u4ef6 -clf_classifiedcontent.property.cm_downgradeEvent_description=\u53ef\u4ee5\u964d\u7ea7\u5206\u7c7b\u7684\u4e8b\u4ef6 -clf_classifiedcontent.property.cm_downgradeInstructions_title=\u964d\u7ea7\u8bf4\u660e -clf_classifiedcontent.property.cm_downgradeInstructions_description=\u8003\u8651\u662f\u5426\u8981\u5bf9\u5206\u7c7b\u964d\u7ea7\u65f6\u9700\u8981\u9075\u5b88\u7684\u8bf4\u660e -clf_classifiedcontent.property.cm_declassificationDate_title=\u53d6\u6d88\u5206\u7c7b\u65e5\u671f -clf_classifiedcontent.property.cm_declassificationDate_description=\u53ef\u4ee5\u5bf9\u6b64\u5185\u5bb9\u53d6\u6d88\u5206\u7c7b\u7684\u65e5\u671f -clf_classifiedcontent.property.cm_declassificationEvent_title=\u53d6\u6d88\u5206\u7c7b\u4e8b\u4ef6 -clf_classifiedcontent.property.cm_declassificationEvent_description=\u53ef\u4ee5\u53d6\u6d88\u5bf9\u6b64\u5185\u5bb9\u5206\u7c7b\u7684\u4e8b\u4ef6 -clf_classifiedcontent.property.cm_declassificationExemptions_title=\u53d6\u6d88\u5206\u7c7b\u4f8b\u5916 -clf_classifiedcontent.property.cm_declassificationExemptions_description=\u53ef\u80fd\u59a8\u788d\u5bf9\u6b64\u5185\u5bb9\u53d6\u6d88\u5206\u7c7b\u7684\u4f8b\u5916 -clf_classifiedcontent.property.cm_lastReclassificationAction_title=\u4e0a\u6b21\u91cd\u65b0\u5206\u7c7b\u64cd\u4f5c -clf_classifiedcontent.property.cm_lastReclassificationAction_description=\u6807\u8bc6\u6b64\u8282\u70b9\u4e0a\u7684\u4e0a\u6b21\u91cd\u65b0\u5206\u7c7b\u7c7b\u578b\u7684\u6587\u672c -clf_classifiedcontent.property.cm_lastReclassifyBy_title=\u91cd\u65b0\u5206\u7c7b\u6b64\u8282\u70b9\u7684\u4e0a\u4e00\u4e2a\u7528\u6237 -clf_classifiedcontent.property.cm_lastReclassifyBy_description=\u9002\u7528\u4e8e\u6700\u8fd1\u91cd\u65b0\u5206\u7c7b\u6b64\u8282\u70b9\u7684\u7528\u6237\u6216\u5b9e\u4f53\u7684\u81ea\u5b9a\u4e49\u7a97\u4f53\u6587\u672c\u6807\u8bc6\u7b26 -clf_classifiedcontent.property.cm_lastReclassifyAt_title=\u4e0a\u6b21\u91cd\u65b0\u5206\u7c7b\u65e5\u671f -clf_classifiedcontent.property.cm_lastReclassifyAt_description=\u4e0a\u6b21\u91cd\u65b0\u5206\u7c7b\u6b64\u8282\u70b9\u7684\u65e5\u671f -clf_classifiedcontent.property.cm_lastReclassifyReason_title=\u4e0a\u6b21\u91cd\u65b0\u5206\u7c7b\u7684\u539f\u56e0 -clf_classifiedcontent.property.cm_lastReclassifyReason_description=\u63d0\u4f9b\u4e0a\u6b21\u91cd\u65b0\u5206\u7c7b\u539f\u56e0\u7684\u6587\u672c \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-notForTranslating.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-notForTranslating.properties deleted file mode 100644 index 0fe0e01543..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content-notForTranslating.properties +++ /dev/null @@ -1,10 +0,0 @@ -## Default exemption categories -rm.exemption-category.1=Information that is currently and properly classified. -rm.exemption-category.2=Information that pertains solely to the internal rules and practices of the agency that, if released, would allow circumvention of an agency rule, policy, or statute, thereby impeding the agency in the conduct of its mission. -rm.exemption-category.3=Information specifically exempted by a statute establishing particular criteria for withholding. The language of the statute must clearly state that the information will not be disclosed. -rm.exemption-category.4=Information such as trade secrets and commercial or financial information obtained from a company on a privileged or confidential basis that, if released, would result in competitive harm to the company, impair the Government's ability to obtain like information in the future, or impair the Government's interest in compliance with program effectiveness. -rm.exemption-category.5=Inter- or intra-agency memorandums or letters containing information considered privileged in civil litigation. The most common privilege is the deliberative process privilege, which concerns documents that are part of the decision-making process and contain subjective evaluations, opinions, and recommendations. Other common privileges are the attorney-client and attorney work product privileges. -rm.exemption-category.6=Information, the release of which would reasonably be expected to constitute a clearly unwarranted invasion of the personal privacy of individuals. -rm.exemption-category.7=Records or information compiled for law enforcement purposes that: (a) Could reasonably be expected to interfere with law enforcement proceedings. (b) Would deprive a person of a right to a fair trial or impartial adjudication. (c) Could reasonably be expected to constitute an unwarranted invasion of the personal privacy of others. (d) Disclose the identity of a confidential source. (e) Disclose investigative techniques and procedures. (f) Could reasonably be expected to endanger the life or physical safety of any individual. -rm.exemption-category.8=Certain records of agencies responsible for supervision of financial institutions. -rm.exemption-category.9=Geological and geophysical information (including maps) concerning wells. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content.properties deleted file mode 100644 index e82a6a61b0..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Top Secret -rm.caveat.classification.mark.s.label=Secret -rm.caveat.classification.mark.c.label=Confidential -rm.classification.unclassified=Unclassified - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=No Clearance - -## Default classification reasons -rm.classification-reason.14a=Military plans, weapons systems or operations. -rm.classification-reason.14b=Foreign government information. -rm.classification-reason.14c=Intelligence activities (including special activities), intelligence sources or methods or cryptology. -rm.classification-reason.14d=Foreign relations or foreign activities for the U.S., including confidential sources. -rm.classification-reason.14e=Scientific, technological or economic matters relating to the nation security which includes defense against transnational terrorism. -rm.classification-reason.14f=U.S. Government programs for safeguarding nuclear materials or facilities. -rm.classification-reason.14g=Vulnerabilities or capabilities of systems, installations, infrastructures, projects, plans or protection services relating to the national security, which includes defense against transnational terrorism. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_de.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_de.properties deleted file mode 100644 index 7e0c3e4572..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_de.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Streng geheim -rm.caveat.classification.mark.s.label=Geheim -rm.caveat.classification.mark.c.label=Vertraulich -rm.classification.unclassified=Nicht klassifiziert - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Keine Freigabe - -## Default classification reasons -rm.classification-reason.14a=Milit\u00e4rische Pl\u00e4ne, Waffensysteme oder Einsatzinformationen. -rm.classification-reason.14b=Daten ausl\u00e4ndischer Beh\u00f6rden. -rm.classification-reason.14c=Geheimdienstvorg\u00e4nge (auch Spezialeins\u00e4tze), Informationsquellen, Methoden oder Kryptologie. -rm.classification-reason.14d=Auslandsbeziehungen oder Auslandseins\u00e4tze f\u00fcr die USA, einschlie\u00dflich vertrauliche Quellen. -rm.classification-reason.14e=Wissenschaftliche, technologische oder wirtschaftliche Themen mit Bezug zur nationalen Sicherheit einschlie\u00dflich Verteidigung gegen internationalen Terrorismus. -rm.classification-reason.14f=US-Regierungsprogramme zum Schutz von Nuklearmaterial und -anlagen. -rm.classification-reason.14g=Schwachstellen oder M\u00f6glichkeiten von Systemen, Installationen, Infrastrukturen, Projekten, Pl\u00e4nen oder Schutzsystemen mit Bezug zur nationalen Sicherheit einschlie\u00dflich Verteidigung gegen internationalen Terrorismus. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_es.properties deleted file mode 100644 index 17a8843a02..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_es.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Alto secreto -rm.caveat.classification.mark.s.label=Secreto -rm.caveat.classification.mark.c.label=Confidencial -rm.classification.unclassified=Sin clasificar - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Sin permiso - -## Default classification reasons -rm.classification-reason.14a=Planes militares, operaciones o sistemas armament\u00edsticos. -rm.classification-reason.14b=Informaci\u00f3n de gobiernos extranjeros. -rm.classification-reason.14c=Actividades de inteligencia (incluidas actividades especiales), m\u00e9todos o cifrado o fuentes de inteligencia. -rm.classification-reason.14d=Relaciones extranjeras o actividades extranjeras para los EE\u00a0UU, incluidas fuentes confidenciales. -rm.classification-reason.14e=Asuntos cient\u00edficos, tecnol\u00f3gicos o econ\u00f3micos relacionados con la seguridad nacional, que incluye la defensa frente al terrorismo transnacional. -rm.classification-reason.14f=Programas del Gobierno de los EE\u00a0UU para proteger los materiales o instalaciones nucleares. -rm.classification-reason.14g=Vulnerabilidades o capacidades de los sistemas, instalaciones, infraestructuras, proyectos, planes o servicios de protecci\u00f3n relacionados con la seguridad nacional, que incluye la defensa frente al terrorismo transnacional. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_fr.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_fr.properties deleted file mode 100644 index 244404a5ef..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_fr.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Top secret -rm.caveat.classification.mark.s.label=Secret -rm.caveat.classification.mark.c.label=Confidentiel -rm.classification.unclassified=Non class\u00e9 - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Pas d'autorisation - -## Default classification reasons -rm.classification-reason.14a=Plans militaires, syst\u00e8mes d'armement ou op\u00e9rations. -rm.classification-reason.14b=Informations de gouvernements \u00e9trangers. -rm.classification-reason.14c=Activit\u00e9s de renseignement (activit\u00e9s sp\u00e9ciales notamment), sources de renseignement ou m\u00e9thodes ou cryptologie. -rm.classification-reason.14d=Relations ou activit\u00e9s \u00e9trang\u00e8res pour les \u00c9tats-Unis, notamment les sources confidentielles. -rm.classification-reason.14e=Questions \u00e0 caract\u00e8re scientifique, technologique ou \u00e9conomique li\u00e9es \u00e0 la s\u00e9curit\u00e9 nationale, comprenant la d\u00e9fense contre le terrorisme transnational. -rm.classification-reason.14f=Programmes du gouvernement am\u00e9ricain pour la protection des mat\u00e9riaux ou infrastructures nucl\u00e9aires. -rm.classification-reason.14g=Vuln\u00e9rabilit\u00e9s ou capacit\u00e9s des syst\u00e8mes, installations, infrastructures, projets, plans ou services de protection li\u00e9s \u00e0 la s\u00e9curit\u00e9 nationale, comprenant la d\u00e9fense contre le terrorisme transnational. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_it.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_it.properties deleted file mode 100644 index 7abef1a005..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_it.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Segretissimo -rm.caveat.classification.mark.s.label=Segreto -rm.caveat.classification.mark.c.label=Riservato -rm.classification.unclassified=Non classificato - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Nessun nulla osta - -## Default classification reasons -rm.classification-reason.14a=Piani militari, sistemi o operazioni di armamento. -rm.classification-reason.14b=Informazioni su governi stranieri. -rm.classification-reason.14c=Attivit\u00e0 di intelligence (comprese attivit\u00e0 speciali), fonti di intelligence o metodi di crittografia. -rm.classification-reason.14d=Relazioni con l'estero o attivit\u00e0 estere per gli Stati Uniti, ivi incluse fonti riservate. -rm.classification-reason.14e=Questioni scientifiche, tecnologiche o economiche relative alla sicurezza nazionale, compresa la difesa contro il terrorismo transnazionale. -rm.classification-reason.14f=Programmi del governo statunitense per la sicurezza dei materiali o impianti nucleari. -rm.classification-reason.14g=Vulnerabilit\u00e0 o capacit\u00e0 di sistemi, impianti, infrastrutture, progetti, piani o servizi di protezione riguardanti la sicurezza nazionale, compresa la difesa contro il terrorismo transnazionale. \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_ja.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_ja.properties deleted file mode 100644 index fd04fc0041..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_ja.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=\u6700\u9ad8\u6a5f\u5bc6 -rm.caveat.classification.mark.s.label=\u95a2\u4fc2\u8005\u5916\u79d8 -rm.caveat.classification.mark.c.label=\u6a5f\u5bc6 -rm.classification.unclassified=\u672a\u5206\u985e - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=\u30af\u30ea\u30a2\u30e9\u30f3\u30b9\u306a\u3057 - -## Default classification reasons -rm.classification-reason.14a=\u8ecd\u4e8b\u8a08\u753b\u3001\u5175\u5668\u30b7\u30b9\u30c6\u30e0\u3001\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3002 -rm.classification-reason.14b=\u5916\u56fd\u653f\u5e9c\u306e\u60c5\u5831\u3002 -rm.classification-reason.14c=\u8adc\u5831\u6d3b\u52d5 (\u7279\u52d9\u3092\u542b\u3080)\u3001\u60c5\u5831\u6e90\u307e\u305f\u306f\u53ce\u96c6\u65b9\u6cd5\u3001\u6697\u53f7\u5b66\u3002 -rm.classification-reason.14d=\u7c73\u56fd\u306e\u5916\u4ea4\u307e\u305f\u306f\u5916\u4ea4\u6d3b\u52d5 (\u6a5f\u5bc6\u60c5\u5831\u306e\u5165\u624b\u3092\u542b\u3080)\u3002 -rm.classification-reason.14e=\u56fd\u5bb6\u306e\u5b89\u5168\u306b\u95a2\u308f\u308b\u79d1\u5b66\u3001\u6280\u8853\u3001\u7d4c\u6e08\u7684\u306a\u4e8b\u9805 (\u56fd\u969b\u30c6\u30ed\u306b\u5bfe\u3059\u308b\u9632\u885b\u3092\u542b\u3080)\u3002 -rm.classification-reason.14f=\u6838\u7269\u8cea\u3084\u6838\u65bd\u8a2d\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306e\u7c73\u56fd\u653f\u5e9c\u30d7\u30ed\u30b0\u30e9\u30e0\u3002 -rm.classification-reason.14g=\u56fd\u5bb6\u306e\u5b89\u5168\u306b\u95a2\u308f\u308b\u30b7\u30b9\u30c6\u30e0\u306e\u8106\u5f31\u6027\u307e\u306f\u305f\u6a5f\u80fd\u3001\u914d\u5099\u3001\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b5\u30fc\u30d3\u30b9 (\u56fd\u969b\u30c6\u30ed\u306b\u5bfe\u3059\u308b\u9632\u885b\u3092\u542b\u3080)\u3002 diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_nb.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_nb.properties deleted file mode 100644 index 2d41cd59a4..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_nb.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Topp hemmelig -rm.caveat.classification.mark.s.label=Hemmelig -rm.caveat.classification.mark.c.label=Konfidensiell -rm.classification.unclassified=Uklassifisert - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Ingen klarering - -## Default classification reasons -rm.classification-reason.14a=Milit\u00e6re planer, v\u00e5pensystemer eller operasjoner. -rm.classification-reason.14b=Informasjon om utenlandske myndigheter. -rm.classification-reason.14c=Etterretningsaktiviteter (inkludert spesielle aktiviteter), etterretningskilder eller -metoder eller -kryptologi. -rm.classification-reason.14d=Utenrikspolitikk eller utenlandske aktiviteter for USA inkluder konfidensielle kilder. -rm.classification-reason.14e=Vitenskapelige, teknologiske og \u00f8konomiske saker i forbindelse landets sikkerhet som inkluderer forsvar mot transnasjonal terrorisme. -rm.classification-reason.14f=Offentlige amerikanske programmer for \u00e5 sikre atommaterialer eller -anlegg. -rm.classification-reason.14g=S\u00e5rbarheter eller kapasiteter til systemer, installasjoner, infrastrukturer, prosjekter, planer eller sikringstjenester i forbindelse med nasjonal sikkerhet, som inkluderer forsvar mot transnasjonal terrorisme. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_nl.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_nl.properties deleted file mode 100644 index e945942035..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_nl.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Topgeheim -rm.caveat.classification.mark.s.label=Geheim -rm.caveat.classification.mark.c.label=Vertrouwelijk -rm.classification.unclassified=Niet-geclassificeerd - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Geen machtiging - -## Default classification reasons -rm.classification-reason.14a=Militaire plannen, wapensystemen of operaties. -rm.classification-reason.14b=Informatie buitenlandse overheden. -rm.classification-reason.14c=Inlichtingenactiviteiten (met inbegrip van speciale activiteiten), inlichtingenbronnen of -methodes of cryptologie. -rm.classification-reason.14d=Buitenlandse betrekkingen of buitenlandse activiteiten voor de V.S., met inbegrip van vertrouwelijke bronnen. -rm.classification-reason.14e=Wetenschappelijke, technologische of economische kwesties met betrekking tot de nationale veiligheid, met inbegrip van verdediging tegen grensoverschrijdend terrorisme. -rm.classification-reason.14f=Programma's van de Amerikaanse overheid inzake de bescherming van nucleair materiaal of nucleaire faciliteiten. -rm.classification-reason.14g=Kwetsbaarheden of mogelijkheden van systemen, installaties, infrastructuur, projecten, plannen of beschermingsdiensten met betrekking tot de nationale veiligheid, met inbegrip van verdediging tegen grensoverschrijdend terrorisme. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_pt_BR.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_pt_BR.properties deleted file mode 100644 index 94c35b093e..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_pt_BR.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=Absoluto sigilo -rm.caveat.classification.mark.s.label=Sigilo -rm.caveat.classification.mark.c.label=Confidencial -rm.classification.unclassified=N\u00e3o classificado - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=Sem libera\u00e7\u00e3o - -## Default classification reasons -rm.classification-reason.14a=Planos militares, sistemas de armas ou opera\u00e7\u00f5es. -rm.classification-reason.14b=Informa\u00e7\u00f5es de governos estrangeiros. -rm.classification-reason.14c=Atividades de intelig\u00eancia (incluindo atividades especiais), fontes ou m\u00e9todos de intelig\u00eancia ou criptologia. -rm.classification-reason.14d=Rela\u00e7\u00f5es exteriores ou atividades estrangeiras para os EUA, incluindo fontes confidenciais. -rm.classification-reason.14e=Quest\u00f5es cient\u00edficas, tecnol\u00f3gicas ou econ\u00f4micas, referentes \u00e0 seguran\u00e7a nacional, que inclui defesa contra o terrorismo internacional. -rm.classification-reason.14f=Os clientes dos Estados Unidos Programas de governo para proteger materiais ou instala\u00e7\u00f5es nucleares. -rm.classification-reason.14g=Vulnerabilidades ou capacidades de sistemas, instala\u00e7\u00f5es, infraestruturas, projetos, planos ou servi\u00e7os de prote\u00e7\u00e3o referentes \u00e0 seguran\u00e7a nacional, incluindo defesa contra o terrorismo internacional. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_ru.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_ru.properties deleted file mode 100644 index 279353b08d..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_ru.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=\u0421\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e -rm.caveat.classification.mark.s.label=\u0421\u0435\u043a\u0440\u0435\u0442\u043d\u043e -rm.caveat.classification.mark.c.label=\u041a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e -rm.classification.unclassified=\u041d\u0435 \u0437\u0430\u0441\u0435\u043a\u0440\u0435\u0447\u0435\u043d\u043e - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=\u041d\u0435\u0442 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 - -## Default classification reasons -rm.classification-reason.14a=\u0412\u043e\u0435\u043d\u043d\u044b\u0435 \u043f\u043b\u0430\u043d\u044b, \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. -rm.classification-reason.14b=\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430. -rm.classification-reason.14c=\u0420\u0430\u0437\u0432\u0435\u0434\u044b\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0441\u043e\u0431\u0443\u044e \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c), \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0440\u0430\u0437\u0432\u0435\u0434\u044b\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043b\u0438\u0431\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043b\u0438 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f. -rm.classification-reason.14d=\u041c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u043c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u043e\u0439 \u0430\u0440\u0435\u043d\u0435 \u0434\u043b\u044f \u0421\u0428\u0410, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438. -rm.classification-reason.14e=\u041d\u0430\u0443\u0447\u043d\u044b\u0435, \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438\u043b\u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u043c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u0440\u0440\u043e\u0440\u0438\u0437\u043c\u0430. -rm.classification-reason.14f=\u0421\u0428\u0410 \u041f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. -rm.classification-reason.14g=\u0423\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438\u043b\u0438 \u0441\u043b\u0443\u0436\u0431\u044b \u0437\u0430\u0449\u0438\u0442\u044b, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0435\u0441\u044f \u043a \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u043c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u0440\u0440\u043e\u0440\u0438\u0437\u043c\u0430. diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_zh_CN.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_zh_CN.properties deleted file mode 100644 index c54fb3122f..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/classified-content_zh_CN.properties +++ /dev/null @@ -1,17 +0,0 @@ -## Default classification levels -rm.caveat.classification.mark.ts.label=\u6700\u9ad8\u673a\u5bc6 -rm.caveat.classification.mark.s.label=\u79d8\u5bc6 -rm.caveat.classification.mark.c.label=\u673a\u5bc6 -rm.classification.unclassified=\u672a\u5206\u7c7b - -## Most classifications are also security clearance levels, but the clearance corresponding to unclassified is "No Clearance" -rm.classification.noClearance=\u65e0\u95f4\u9699 - -## Default classification reasons -rm.classification-reason.14a=\u519b\u4e8b\u8ba1\u5212\u3001\u6b66\u5668\u7cfb\u7edf\u6216\u64cd\u4f5c\u3002 -rm.classification-reason.14b=\u5916\u56fd\u653f\u5e9c\u4fe1\u606f\u3002 -rm.classification-reason.14c=\u60c5\u62a5\u6d3b\u52a8\uff08\u5305\u62ec\u7279\u6b8a\u6d3b\u52a8\uff09\u3001\u60c5\u62a5\u6765\u6e90\u6216\u65b9\u6cd5\u6216\u5bc6\u7801\u5b66\u3002 -rm.classification-reason.14d=\u7f8e\u56fd\u5916\u4ea4\u5173\u7cfb\u6216\u5916\u4ea4\u6d3b\u52a8\uff0c\u5305\u62ec\u673a\u5bc6\u6765\u6e90\u3002 -rm.classification-reason.14e=\u56fd\u5bb6\u5b89\u5168\uff08\u5305\u62ec\u9632\u5fa1\u56fd\u9645\u6050\u6016\u4e3b\u4e49\uff09\u76f8\u5173\u7684\u79d1\u5b66\u3001\u6280\u672f\u6216\u7ecf\u6d4e\u4e8b\u52a1\u3002 -rm.classification-reason.14f=\u7f8e\u56fd \u4fdd\u62a4\u6838\u6750\u6599\u6216\u6838\u8bbe\u65bd\u7684\u653f\u5e9c\u8ba1\u5212\u3002 -rm.classification-reason.14g=\u56fd\u5bb6\u5b89\u5168\uff08\u5305\u62ec\u9632\u5fa1\u56fd\u9645\u6050\u6016\u4e3b\u4e49\uff09\u76f8\u5173\u7684\u7cfb\u7edf\u3001\u88c5\u5907\u3001\u57fa\u7840\u8bbe\u65bd\u3001\u9879\u76ee\u3001\u8ba1\u5212\u6216\u4fdd\u62a4\u670d\u52a1\u65b9\u9762\u7684\u5f31\u70b9\u6216\u80fd\u529b\u3002 diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/metadata-referral-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/metadata-referral-context.xml deleted file mode 100644 index 11cadeabbb..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/metadata-referral-context.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService.attachReferrer=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService.detachReferrer=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService.getAttachedReferralsFrom=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService.getAttachedReferralFrom=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService.*=ACL_DENY - - - - - - - - - - - - - - - - - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.default} - - - - - - - - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.isReferringMetadata=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.getReferentNode=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.getReferredProperties=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.getReferredProperty=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.hasReferredAspect=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.getAttachedReferrals=ACL_ALLOW - org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService.*=ACL_DENY - - - - - - - - - - - - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml deleted file mode 100644 index 8cefb0d377..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - Classified Content Model - Roy Wetherall - 1.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - Initial Classification - The initial classification - d:text - true - true - - - - - - Current Classification - The current classification. Set to the same as initial classification - d:text - true - true - - - - - - Classification Agency - The classification agency - d:text - false - - - - Classified By - Name of whoever has applied the classification - d:text - true - - - Classification Reasons - Holds the ids of classification reasons - d:text - true - - - - - - Downgrade Date - The date when the classification may be downgraded - d:date - false - - - Downgrade Event - An event for which the classification may be downgraded - d:text - false - - - Downgrade Instructions - Instructions to be followed when considering whether to downgrade the classification - d:text - false - - - Declassification Date - The date when this may be declassified - d:date - false - - - Declassification Event - The event when this may be declassified - d:text - false - - - Declassification Exemptions - Exemptions that may preclude this from being declassified - d:text - true - - - - - - Last Reclassification Action - Text identifying the type of the previous reclassification on this node - d:text - - - - - - Last user to reclassify this node - Free form text identifier for the user or entity who most recently reclassified this node - d:text - false - - - Last reclassification date - Date for when this node was last reclassified - d:date - false - - - Last reclassification reason - Text giving the reason for the last reclassification - d:text - false - - - - - - - - - Security Clearance - The security clearance for this user - d:text - true - true - false - NoClearance - - - - - - - - - - - - - true - true - - - cm:content - true - true - - - - - - \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml index f23a41dbdf..b0317256f9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml @@ -11,12 +11,6 @@ - - - - - - @@ -33,7 +27,6 @@ - @@ -57,15 +50,6 @@ - - - - - - - - @@ -235,7 +219,6 @@ - - - - - - - - - - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml index 44066f1b61..5ae2a94653 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml @@ -32,7 +32,6 @@ - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml deleted file mode 100644 index 1b7997aafb..0000000000 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml index d3684d3d68..a33e9d5673 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml @@ -17,8 +17,6 @@ - - @@ -926,28 +924,4 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index f6c284a2f4..58628e9921 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -650,61 +650,4 @@ parent="rmBaseWebscript"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classificationlevels.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classificationlevels.get.desc.xml deleted file mode 100644 index a049a6ecbc..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classificationlevels.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Records Management Classification Levels - Gets the list of classification levels. - /api/classification/levels - - user - required - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classificationlevels.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classificationlevels.get.json.ftl deleted file mode 100644 index fa6de09277..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classificationlevels.get.json.ftl +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": - { - "items": - [ - <#list levels as level> - { - "id": "${level.id?json_string}", - "displayLabel": "${level.displayLabel?json_string}" - }<#if level_has_next>, - - ] - } -} diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml deleted file mode 100644 index 0241462ac2..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml +++ /dev/null @@ -1,51 +0,0 @@ - - Classifies a content - - Classification level id, classified by, classification reasons are mandatory fields.
- Downgrade instructions becomes a mandotory field if a downgrade date and/or downgrade event is provided.
-
- The body of the post should be in the form, e.g.
- {
- "classificationLevelId": "aLevelId",
- "classifiedBy": "some person or entity",
- "classificationAgency": "anAgency",
- "classificationReasons": [
- {
- "displayLabel": "reason1DisplayLabel",
- "fullReason": "reason1Id: reason1DisplayLabel",
- "id": "reason1Id",
- "label": "reason1Id: reason1DisplayLabel",
- "value": "reason1Id"
- },
- {
- "displayLabel": "reason2DisplayLabel",
- "fullReason": "reason2Id: reason2DisplayLabel",
- "id": "reason2Id",
- "label": "reason2Id: reason2DisplayLabel",
- "value": "reason2Id"
- }
- ],
- "downgradeDate": "YYYY-MM-DD",
- "downgradeEvent": "aDowngradeEvent",
- "downgradeInstructions": "aDowngradeInstruction",
- "declassificationDate": "YYYY-MM-DD",
- "declassificationEvent": "adeclassificationEvent",
- "declassificationExemptions: [
- {
- "displayLabel": "anExemptionDisplayLabel",
- "fullCategory": "anExemptionId: anExemptionDisplayLabel",
- "id": "anExemptionId",
- "label": "anExemptionId: anExemptionDisplayLabel",
- "value": "anExemptionId"
- }
- ]
- }
- ]]> -
- /api/node/{store_type}/{store_id}/{id}/classify - argument - user - required - internal -
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.json.ftl deleted file mode 100644 index beda2de343..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.json.ftl +++ /dev/null @@ -1,5 +0,0 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.put.desc.xml deleted file mode 100644 index 45af3f5ff5..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.put.desc.xml +++ /dev/null @@ -1,53 +0,0 @@ - - Edits a classified content - - Classification level id, classified by, classification reasons are mandatory fields.
- Downgrade instructions becomes a mandotory field if a downgrade date and/or downgrade event is provided.
-
- The body of the put should be in the form, e.g.
- {
- "classificationLevelId": "aLevelId",
- "classifiedBy": "some person or entity",
- "classificationAgency": "anAgency",
- "classificationReasons": [
- {
- "displayLabel": "reason1DisplayLabel",
- "fullReason": "reason1Id: reason1DisplayLabel",
- "id": "reason1Id",
- "label": "reason1Id: reason1DisplayLabel",
- "value": "reason1Id"
- },
- {
- "displayLabel": "reason2DisplayLabel",
- "fullReason": "reason2Id: reason2DisplayLabel",
- "id": "reason2Id",
- "label": "reason2Id: reason2DisplayLabel",
- "value": "reason2Id"
- }
- ],
- "downgradeDate": "YYYY-MM-DD",
- "downgradeEvent": "aDowngradeEvent",
- "downgradeInstructions": "aDowngradeInstruction",
- "declassificationDate": "YYYY-MM-DD",
- "declassificationEvent": "adeclassificationEvent",
- "declassificationExemptions: [
- {
- "displayLabel": "anExemptionDisplayLabel",
- "fullCategory": "anExemptionId: anExemptionDisplayLabel",
- "id": "anExemptionId",
- "label": "anExemptionId: anExemptionDisplayLabel",
- "value": "anExemptionId"
- }
- ],
- "lastReclassifyBy": "aUsername",
- "lastReclassifyReason": "aReasonForReclassification"
- }
- ]]> -
- /api/node/{store_type}/{store_id}/{id}/classify - argument - user - required - internal -
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.put.json.ftl deleted file mode 100644 index beda2de343..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.put.json.ftl +++ /dev/null @@ -1,5 +0,0 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "success": ${success?string} -} - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/clearancelevels.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/clearancelevels.get.desc.xml deleted file mode 100644 index cb5eff3dbb..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/clearancelevels.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Records Management Clearance Levels - Gets the list of clearance levels. - /api/clearance/levels - - user - required - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/clearancelevels.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/clearancelevels.get.json.ftl deleted file mode 100644 index 5a66d44be9..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/clearancelevels.get.json.ftl +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": - { - "items": - [ - <#list levels as level> - { - "id": "${level.highestClassificationLevel.id?json_string}", - "displayLabel": "${level.displayLabel?json_string}" - }<#if level_has_next>, - - ] - } -} diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/exemptioncategories.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/exemptioncategories.get.desc.xml deleted file mode 100644 index 18a9683922..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/exemptioncategories.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Records Management Exemption Categories - Gets the list of exemption categories. - /api/classification/exemptioncategories - - user - required - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/exemptioncategories.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/exemptioncategories.get.json.ftl deleted file mode 100644 index 9d55e2cfed..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/exemptioncategories.get.json.ftl +++ /dev/null @@ -1,15 +0,0 @@ -{ - "data": - { - "items": - [ - <#list exemptionCategories as exemptionCategory> - { - "id": "${exemptionCategory.id?json_string}", - "displayLabel": "${exemptionCategory.displayLabel?json_string}", - "fullCategory": "${exemptionCategory.id?json_string}: ${exemptionCategory.displayLabel?json_string}" - }<#if exemptionCategory_has_next>, - - ] - } -} diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.desc.xml deleted file mode 100644 index 60797f9d1f..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Records Management Classification Reasons - Gets the list of classification reasons. - /api/classification/reasons - - user - required - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.json.ftl deleted file mode 100644 index f580ce38ae..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.json.ftl +++ /dev/null @@ -1,15 +0,0 @@ -{ - "data": - { - "items": - [ - <#list reasons as reason> - { - "id": "${reason.id?json_string}", - "displayLabel": "${reason.displayLabel?json_string}", - "fullReason": "${reason.id?json_string}: ${reason.displayLabel?json_string}" - }<#if reason_has_next>, - - ] - } -} diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.get.desc.xml deleted file mode 100644 index 8202e19df4..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Users security clearance - REST API to GET users security clearance - /api/classification/clearance?nameFilter={nameFilter?}&startIndex={startIndex?}&pageSize={pageSize?}&sortField={sortField?}&sortAscending={sortAscending?} - argument - admin - required - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.get.json.ftl deleted file mode 100644 index d6cc14b3a4..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.get.json.ftl +++ /dev/null @@ -1,13 +0,0 @@ -<#import "/org/alfresco/repository/generic-paged-results.lib.ftl" as gen/> -<#import "usersecurityclearance.lib.ftl" as usersecurityclearance /> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": - { - <@gen.pagedResults data=data ; item> - <@usersecurityclearance.usersecurityclearanceJSON item=item /> - - } -} - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.lib.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.lib.ftl deleted file mode 100644 index ea61f30eed..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.lib.ftl +++ /dev/null @@ -1,16 +0,0 @@ -<#macro usersecurityclearanceJSON item> - <#local cl=item.clearanceLevel> - <#local pi=item.personInfo> - { - <#escape x as jsonUtils.encodeJSONString(x)> - "classificationId": "${cl.highestClassificationLevel.id}", - "clearanceLabel": "${cl.displayLabel}", - "userName": <#if pi.userName??>"${pi.userName}"<#else>null, - "firstName": <#if pi.firstName??>"${pi.firstName}"<#else>null, - "lastName": <#if pi.lastName??>"${pi.lastName}"<#else>null, - "fullName": <#if pi.firstName?? && pi.lastName??>"${pi.firstName} ${pi.lastName}"<#else>"${pi.userName}", - "completeName": <#if pi.firstName?? && pi.lastName?? && pi.userName??>"${pi.firstName} ${pi.lastName} (${pi.userName})"<#else>"${pi.userName}", - "isEditable": <#if people.isAdmin(people.getPerson(pi.userName))>false<#else>true - - } - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.put.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.put.desc.xml deleted file mode 100644 index 60dc018fb4..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.put.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - Users security clearance - REST API to set users security clearance - /api/classification/clearance?username={username}&clearanceId={clearanceId} - argument - admin - required - \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.put.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.put.json.ftl deleted file mode 100644 index 9be5042510..0000000000 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/usersecurityclearance.put.json.ftl +++ /dev/null @@ -1,7 +0,0 @@ -<#import "usersecurityclearance.lib.ftl" as usersecurityclearance /> - -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "data": <@usersecurityclearance.usersecurityclearanceJSON item=item /> -} - \ No newline at end of file diff --git a/rm-server/pom.xml b/rm-server/pom.xml index e8a2195917..fd5726cd7b 100644 --- a/rm-server/pom.xml +++ b/rm-server/pom.xml @@ -192,9 +192,9 @@ - + - + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java index 5dad9139df..89b7cab1a8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponent.java @@ -43,8 +43,6 @@ public class BootstrapImporterModuleComponent extends ImporterModuleComponent /** record contributors group bootstrap component */ private RecordContributorsGroupBootstrapComponent recordContributorsGroupBootstrapComponent; - /** Clearance for admin bootstrap component. */ - private ClearanceForAdminBootstrapComponent clearanceForAdminBootstrapComponent; /** * @param nodeService node service @@ -70,15 +68,6 @@ public class BootstrapImporterModuleComponent extends ImporterModuleComponent this.recordContributorsGroupBootstrapComponent = recordContributorsGroupBootstrapComponent; } - /** - * @param clearanceForAdminBootstrapComponent The bootstrap component that give the admin user the maximum - * clearance. - */ - public void setClearanceForAdminBootstrapComponent(ClearanceForAdminBootstrapComponent clearanceForAdminBootstrapComponent) - { - this.clearanceForAdminBootstrapComponent = clearanceForAdminBootstrapComponent; - } - /** * Need to check whether this module has already been executed. * @@ -94,7 +83,6 @@ public class BootstrapImporterModuleComponent extends ImporterModuleComponent // Bootstrap creation of initial data. recordContributorsGroupBootstrapComponent.createRecordContributorsGroup(); - clearanceForAdminBootstrapComponent.createClearanceForAdmin(); // init module schema number modulePatchExecuter.initSchemaVersion(); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ClearanceForAdminBootstrapComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ClearanceForAdminBootstrapComponent.java deleted file mode 100644 index 73436db459..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ClearanceForAdminBootstrapComponent.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import java.io.Serializable; - -import org.alfresco.module.org_alfresco_module_rm.patch.v24.RMv24ClearanceForAdmin; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.PersonService; - -/** - * Provide the highest clearance to the admin user. This needs to be run once (either bootstrapped into a - * fresh system, or as part of an upgrade in {@link RMv24ClearanceForAdmin}) per installation. - * - * @author tpage - */ -public class ClearanceForAdminBootstrapComponent implements ClassifiedContentModel -{ - private AuthenticationUtil authenticationUtil; - private NodeService nodeService; - private PersonService personService; - private ClassificationServiceBootstrap classificationServiceBootstrap; - - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) { this.authenticationUtil = authenticationUtil; } - public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } - public void setPersonService(PersonService personService) { this.personService = personService; } - public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap) { this.classificationServiceBootstrap = classificationServiceBootstrap; } - - /** - * Give the admin user the maximum clearance. - */ - public void createClearanceForAdmin() - { - // Ensure the classification levels are loaded before this patch runs. (Nb. This will result in the - // classification service bootstrap method being called twice on the start-up that includes this call). - classificationServiceBootstrap.onBootstrap(null); - - Serializable mostSecureLevel = classificationServiceBootstrap.getClassificationLevelManager() - .getMostSecureLevel().getId(); - String adminUserName = authenticationUtil.getAdminUserName(); - NodeRef admin = personService.getPerson(adminUserName, false); - nodeService.setProperty(admin, PROP_CLEARANCE_LEVEL, mostSecureLevel); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/CaveatConstants.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/CaveatConstants.java deleted file mode 100644 index ef3f2a12b6..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/CaveatConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import java.io.Serializable; - -/** - * Constants for use by the caveats feature. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatConstants -{ - /** This utility class should not be instantiated. */ - private CaveatConstants() {} - - /** Key for accessing the persisted caveat groups and marks in the attribute service. */ - public static final Serializable[] CAVEAT_ATTRIBUTE_KEY = new String[] { "org.alfresco", "module.org_alfresco_module_rm", "caveat.groups" }; - /** The default prefix of caveat-related properties. */ - public static final String DEFAULT_CAVEAT_PREFIX = "rm.caveat."; -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/CaveatException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/CaveatException.java deleted file mode 100644 index 5d37c2592c..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/CaveatException.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat; - -import org.alfresco.error.AlfrescoRuntimeException; - -/** - * Generic class for any runtime exception to do with caveats. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatException extends AlfrescoRuntimeException -{ - /** serial version uid */ - private static final long serialVersionUID = -1678248996340040195L; - - public CaveatException(String msgId) - { - super(msgId); - } - - public CaveatException(String msgId, Throwable cause) - { - super(msgId, cause); - } - - /** The supplied caveat group id was not found in the configured list. */ - public static class CaveatGroupNotFound extends CaveatException - { - /** serial version uid */ - private static final long serialVersionUID = -3547790332616121911L; - - public CaveatGroupNotFound(String caveatGroupId) - { - super("Could not find caveat group with id " + caveatGroupId); - } - } - - /** The supplied caveat mark id was not found in the configured list. */ - public static class CaveatMarkNotFound extends CaveatException - { - /** serial version uid */ - private static final long serialVersionUID = -7605943340899129129L; - - public CaveatMarkNotFound(String caveatMarkId) - { - super("Could not find caveat mark with id " + caveatMarkId); - } - } - - /** The caveat configuration file contains errors. */ - public static class MalformedConfiguration extends CaveatException - { - /** serial version uid */ - private static final long serialVersionUID = -4486048933410071424L; - - public MalformedConfiguration(String message) - { - super(message); - } - - public MalformedConfiguration(String message, Throwable cause) - { - super(message, cause); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOCache.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOCache.java deleted file mode 100644 index 3f362d3a76..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOCache.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.dao; - -import com.google.common.collect.ImmutableMap; - -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.CaveatGroupNotFound; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroup; -import org.alfresco.service.namespace.QName; - -import java.util.Map; - -/** - * A cache that ensures the underlying caveat DAO is only executed once per query. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatDAOCache implements CaveatDAOInterface -{ - /** The wrapped caveat DAO. */ - private CaveatDAOInterface caveatDAO; - /** A cache of the system caveat groups. */ - private ImmutableMap caveatGroups; - - /** - * {@inheritDoc} The first call to this method will be cached and returned for every successive call. - */ - @Override - public ImmutableMap getCaveatGroups() - { - ensureCachePopulated(); - return caveatGroups; - } - - /** - * {@inheritDoc} The first call to this method will populate the cache for future calls. - */ - @Override - public CaveatGroup getGroupById(String groupId) throws CaveatGroupNotFound - { - ensureCachePopulated(); - CaveatGroup caveatGroup = caveatGroups.get(groupId); - if (caveatGroup == null) - { - throw new CaveatGroupNotFound(groupId); - } - return caveatGroup; - } - - @Override public QName getCaveatGroupProperty(String caveatGroupId) - { - ensureCachePopulated(); - - return getGroupById(caveatGroupId).getModelProperty(); - } - - @Override public CaveatGroup getCaveatGroupFromProperty(QName propertyName) - { - ensureCachePopulated(); - - CaveatGroup matchingGroup = null; - for (Map.Entry entry : caveatGroups.entrySet()) - { - final CaveatGroup potentialMatch = entry.getValue(); - if (propertyName.equals(getCaveatGroupProperty(potentialMatch.getId()))) - { - matchingGroup = potentialMatch; - break; - } - } - if (matchingGroup == null) - { - throw new CaveatGroupNotFound("No group found for property '" + propertyName + "'"); - } - else - { - return matchingGroup; - } - } - - /** The first call to this method will populate the cache, subsequent calls will do nothing. */ - private void ensureCachePopulated() - { - if (caveatGroups == null) - { - caveatGroups = caveatDAO.getCaveatGroups(); - } - } - - /** - * Set the caveat DAO to be wrapped. - * - * @param caveatDAO The caveat DAO to be wrapped. - */ - public void setCaveatDAO(CaveatDAOInterface caveatDAO) - { - this.caveatDAO = caveatDAO; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSON.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSON.java deleted file mode 100644 index 546309510a..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSON.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.dao; - -import static org.alfresco.service.namespace.QName.createQName; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.CaveatGroupNotFound; -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.MalformedConfiguration; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroup; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroupType; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatMark; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.io.IOUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * An object that provides access to the configured caveat groups and marks, which it retrieves from JSON files. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatDAOFromJSON implements CaveatDAOInterface -{ - /** JSON key for the group id. */ - private static final String GROUP_ID_JSON_KEY = "id"; - /** JSON key for the group display label key. */ - private static final String GROUP_DISPLAY_LABEL_JSON_KEY = "displayLabel"; - /** JSON key for the group description key. */ - private static final String DESCRIPTION_JSON_KEY = "description"; - /** JSON key for the group type. */ - private static final String TYPE_JSON_KEY = "type"; - /** JSON key for the model object. */ - private static final String MODEL_JSON_KEY = "model"; - /** JSON key for the property field. */ - private static final String PROPERTY_JSON_KEY = "property"; - /** JSON key for the caveat marks array. */ - private static final String MARKS_JSON_KEY = "marks"; - /** JSON key for the mark id. */ - private static final String MARK_ID_JSON_KEY = "id"; - /** JSON key for the mark display label key. */ - private static final String MARK_DISPLAY_LABEL_JSON_KEY = "displayLabel"; - /** Logging utility for the class. */ - private static final Logger LOGGER = LoggerFactory.getLogger(CaveatDAOFromJSON.class); - - /** The location of the configuration file relative to the classpath. */ - private String configLocation; - - private DictionaryService dictionaryService; - private NamespaceService namespaceService; - - /** Set the location of the configuration file relative to the classpath. */ - public void setConfigLocation(String configLocation) - { - this.configLocation = configLocation; - } - - public void setNamespaceService(NamespaceService service) - { - this.namespaceService = service; - } - public void setDictionaryService(DictionaryService service) - { - this.dictionaryService = service; - } - - /** - * {@inheritDoc} - * - * @throws MalformedConfiguration If the configuration file cannot be interpreted. - */ - @Override - public ImmutableMap getCaveatGroups() - { - Builder builder = ImmutableMap.builder(); - try (final InputStream in = this.getClass().getResourceAsStream(configLocation)) - { - if (in != null) - { - final String jsonString = IOUtils.toString(in); - final JSONArray jsonArray = new JSONArray(new JSONTokener(jsonString)); - - for (int i = 0; i < jsonArray.length(); i++) - { - final JSONObject nextObj = jsonArray.getJSONObject(i); - CaveatGroup caveatGroup = createGroup(nextObj); - String caveatGroupId = caveatGroup.getId(); - builder.put(caveatGroupId, caveatGroup); - } - } - else - { - LOGGER.warn("Could not find caveat configuration file: " + configLocation); - } - } - catch (IOException | JSONException | IllegalArgumentException e) - { - throw new MalformedConfiguration("Could not read caveat configuration: " + configLocation, e); - } - - ImmutableMap map; - try - { - map = builder.build(); - } - catch (IllegalArgumentException e) - { - throw new MalformedConfiguration("Configuration contains two caveat groups with the same id.", e); - } - return map; - } - - /** - * {@inheritDoc} - *

- * This method loads all caveat groups just to return a single group. - */ - @Override - public CaveatGroup getGroupById(String groupId) - { - CaveatGroup caveatGroup = getCaveatGroups().get(groupId); - if (caveatGroup == null) - { - throw new CaveatGroupNotFound(groupId); - } - return caveatGroup; - } - - @Override public QName getCaveatGroupProperty(String caveatGroupId) - { - return getGroupById(caveatGroupId).getModelProperty(); - } - - @Override public CaveatGroup getCaveatGroupFromProperty(QName propertyName) - { - // FIXME Do we need any validation to ensure that multiple caveat groups don't reuse the same property? - for (Map.Entry entry : getCaveatGroups().entrySet()) - { - if (propertyName.equals(entry.getValue().getModelProperty())) - { - return entry.getValue(); - } - } - throw new CaveatGroupNotFound("Caveat Group not found for property '" + propertyName + "'"); - } - - /** - * Create a caveat group from the supplied JSON. - * - * @param jsonGroup The JSON object corresponding to a single group and its marks. - * @return The created group. - * @throws JSONException If there is an issue reading the JSON. - */ - protected CaveatGroup createGroup(JSONObject jsonGroup) throws JSONException - { - String id = jsonGroup.getString(GROUP_ID_JSON_KEY); - String displayLabelKey = jsonGroup.getString(GROUP_DISPLAY_LABEL_JSON_KEY); - String descriptionKey = jsonGroup.getString(DESCRIPTION_JSON_KEY); - String modelProperty = null; - if (jsonGroup.has(MODEL_JSON_KEY)) - { - JSONObject modelObj = jsonGroup.getJSONObject(MODEL_JSON_KEY); - if (modelObj.has(PROPERTY_JSON_KEY)) - { - modelProperty = modelObj.getString(PROPERTY_JSON_KEY); - } - } - String caveatGroupTypeString = jsonGroup.getString(TYPE_JSON_KEY); - CaveatGroupType caveatGroupType; - try - { - caveatGroupType = CaveatGroupType.valueOf(caveatGroupTypeString); - } - catch (IllegalArgumentException e) - { - throw new MalformedConfiguration("Unrecognised caveat group type " + caveatGroupTypeString, e); - } - - // Create a list of the configured caveat marks. - List caveatMarks = new ArrayList<>(); - Set markIds = new HashSet<>(); - JSONArray jsonMarks = jsonGroup.getJSONArray(MARKS_JSON_KEY); - for (int i = 0; i < jsonMarks.length(); i++) - { - JSONObject jsonMark = jsonMarks.getJSONObject(i); - CaveatMark caveatMark = createMark(jsonMark); - caveatMarks.add(caveatMark); - if (!markIds.contains(caveatMark.getId())) - { - markIds.add(caveatMark.getId()); - } - else - { - throw new MalformedConfiguration("Duplicate caveat mark id " + caveatMark.getId() + " within a group."); - } - } - - // Instantiate the group (and associate the marks with the group). - CaveatGroup caveatGroup = new CaveatGroup(id, displayLabelKey, descriptionKey, - validatedPropertyName(modelProperty), - caveatGroupType, caveatMarks); - - return caveatGroup; - } - - /** - * Validates that the provided qname string is a valid model property. - * @param qnameString the short form qname string e.g. {@code cm:content} or {@code null}. - * @return the valid {@link QName} or {@code null} if the qnameString was {@code null}. - * @throws MalformedConfiguration if the provided qnameString was not {@code null} and was not a valid property name. - */ - private QName validatedPropertyName(String qnameString) - { - if (qnameString == null) - { - return null; - } - else - { - final QName qname = createQName(qnameString, namespaceService); - final boolean isProperty = dictionaryService.getProperty(qname) != null; - - if (isProperty) - { - return qname; - } - else - { - throw new MalformedConfiguration("Property name not recognised: '" + qnameString + "'"); - } - } - } - - /** - * Create a caveat mark from the supplied JSON. This does not set the group id of the caveat mark. - * - * @param jsonMark The JSON object corresponding to a single mark. - * @return The created mark. - * @throws JSONException If there is an issue reading the JSON. - */ - private CaveatMark createMark(JSONObject jsonMark) throws JSONException - { - String id = jsonMark.getString(MARK_ID_JSON_KEY); - String displayLabelKey = jsonMark.getString(MARK_DISPLAY_LABEL_JSON_KEY); - return new CaveatMark(id, displayLabelKey); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSONBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSONBootstrap.java deleted file mode 100644 index 9fcb73331b..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSONBootstrap.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.caveat.dao; - -import static org.alfresco.module.org_alfresco_module_rm.caveat.CaveatConstants.CAVEAT_ATTRIBUTE_KEY; - -import java.io.Serializable; -import java.util.Map; - -import com.google.common.collect.ImmutableMap; -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.MalformedConfiguration; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroup; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.alfresco.service.transaction.TransactionService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * This class is responsible for ensuring all caveat data is loaded from the JSON configuration on start-up. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatDAOFromJSONBootstrap extends AbstractLifecycleBean -{ - /** Logging utility for the class. */ - private static final Logger LOGGER = LoggerFactory.getLogger(CaveatDAOFromJSONBootstrap.class); - - private final AuthenticationUtil authenticationUtil; - private final TransactionService transactionService; - private AttributeService attributeService; - private CaveatDAOInterface caveatDAO; - - private boolean isInitialised = false; - - public CaveatDAOFromJSONBootstrap(AuthenticationUtil authUtil, - TransactionService txService, - AttributeService attributeService, - CaveatDAOInterface caveatDAO) - { - this.authenticationUtil = authUtil; - this.transactionService = txService; - this.attributeService = attributeService; - this.caveatDAO = caveatDAO; - } - - /** Set the object from which configuration options will be read. */ - public void setClassificationServiceDAO(CaveatDAOInterface caveatDAO) { this.caveatDAO = caveatDAO; } - public void setAttributeService(AttributeService attributeService) { this.attributeService = attributeService; } - - public boolean isInitialised() - { - return isInitialised; - } - - @Override public void onBootstrap(ApplicationEvent event) - { - authenticationUtil.runAsSystem(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Void execute() - { - initialiseConfiguredCaveatGroups(CAVEAT_ATTRIBUTE_KEY); - isInitialised = true; - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(callback); - return null; - } - }); - } - - /** - * Gets the caveat configuration persisted in the system. - * - * @return the persisted caveat groups if they have been persisted, else {@code null}. - */ - private ImmutableMap getPersistedCaveatGroups(final Serializable[] key) - { - return authenticationUtil.runAsSystem(new RunAsWork>() - { - @Override - @SuppressWarnings("unchecked") - public ImmutableMap doWork() throws Exception - { - // TODO: Although an ImmutableMap is stored, after restarting the server, a HashMap is returned. - // Investigate why this is, and whether we can avoid creating a new copy of the map here. - Map persistedMap = (Map) attributeService.getAttribute(key); - if (persistedMap == null) - { - return null; - } - return ImmutableMap.copyOf(persistedMap); - } - }); - } - - /** Return true if the map is null or empty. */ - private boolean isEmpty(Map caveatGroups) - { - return (caveatGroups == null || caveatGroups.isEmpty()); - } - - /** Helper method for debug-logging sensitive caveat group information. */ - private String loggableStatusOf(Map caveatGroups) - { - if (caveatGroups == null) { return "null"; } - else if (caveatGroups.isEmpty()) { return "empty"; } - else { return "non-empty"; } - } - - /** - * Get the configured caveat groups and marks from the JSON file. - * - * @param key The attribute service key for the caveat scheme. - */ - protected void initialiseConfiguredCaveatGroups(Serializable[] key) - { - final ImmutableMap persistedGroups = getPersistedCaveatGroups(key); - final ImmutableMap classpathGroups = caveatDAO.getCaveatGroups(); - - // Note! We cannot log the entities or even the size of these lists for security reasons. - LOGGER.debug("Persisted CaveatGroup: {}", loggableStatusOf(persistedGroups)); - LOGGER.debug("Classpath CaveatGroup: {}", loggableStatusOf(classpathGroups)); - - if (isEmpty(classpathGroups)) - { - throw new MalformedConfiguration("CaveatGroup configuration is missing."); - } - if (!classpathGroups.equals(persistedGroups)) - { - if (!isEmpty(persistedGroups)) - { - LOGGER.warn("CaveatGroup configuration changed. This may result in unpredictable results if the caveat scheme is already in use."); - } - attributeService.setAttribute(classpathGroups, key); - } - } - - @Override protected void onShutdown(ApplicationEvent event) - { - // Intentionally empty. - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOInterface.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOInterface.java deleted file mode 100644 index fa0eaea65a..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOInterface.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.dao; - -import com.google.common.collect.ImmutableMap; -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.CaveatGroupNotFound; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroup; -import org.alfresco.service.namespace.QName; - -/** - * An object responsible for providing access to the configured caveat groups and marks. - * - * @author Tom Page - * @since 2.4.a - */ -public interface CaveatDAOInterface -{ - /** - * Gets a map of all the available caveat groups keyed by id. - */ - ImmutableMap getCaveatGroups(); - - /** - * Gets the caveat group for a given id. - * - * @param groupId The group id to look up. - * @return The caveat group. - * @throws CaveatGroupNotFound if the caveat group is not found. - */ - CaveatGroup getGroupById(String groupId) throws CaveatGroupNotFound; - - /** - * Gets the property that relates to a {@link CaveatGroup}. - * - * @param caveatGroupId - * @return - * @throws CaveatGroupNotFound if a matching {@link CaveatGroup} could not be found. - */ - QName getCaveatGroupProperty(String caveatGroupId); - - /** - * Gets the {@link CaveatGroup} that relates to a property. - * - * @return the matching {@link CaveatGroup} if there is one. - * @throws CaveatGroupNotFound if there was no matching group. - */ - CaveatGroup getCaveatGroupFromProperty(QName propertyName); -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroup.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroup.java deleted file mode 100644 index eb20d2c34c..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroup.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.scheme; - -import static org.alfresco.module.org_alfresco_module_rm.caveat.CaveatConstants.DEFAULT_CAVEAT_PREFIX; - -import java.io.Serializable; -import java.util.List; - -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.CaveatMarkNotFound; -import org.alfresco.module.org_alfresco_module_rm.util.CoreServicesExtras; -import org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck; -import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * A group of related caveat marks and metadata describing how they are related. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatGroup implements Serializable -{ - /** Generated serial version id. */ - private static final long serialVersionUID = -8909291192015016370L; - /** The unique id of the caveat group. */ - private final String id; - /** The key to retrieve the I18n'ed display label for the caveat group. */ - private final String displayLabelKey; - /** The key to retrieve the I18n'ed description of the caveat group. */ - private final String descriptionKey; - /** The model property in which this caveat group will store marks on objects. */ - private final QName modelProperty; - /** The relationship between marks in the group. */ - private final CaveatGroupType caveatGroupType; - /** The marks that are contained in this group, ordered according to the list supplied in the constructor. */ - private final ImmutableMap caveatMarks; - - /** - * Constructor for the caveat group. - *

- * This sets the group id of all the caveat marks that are supplied. It uses the - * default keys for the display label and description. - * - * @param id The unique id of the caveat group. - * @param caveatGroupType The relationship between marks in the group. - * @param caveatMarks The marks that are contained in this group. - */ - public CaveatGroup(String id, QName modelProperty, CaveatGroupType caveatGroupType, List caveatMarks) - { - this(id, null, null, modelProperty, caveatGroupType, caveatMarks); - } - - /** - * Constructor for the caveat group. - *

- * This sets the group id of all the caveat marks that are supplied. - * - * @param id The unique id of the caveat group. - * @param displayLabelKey The key to retrieve the I18n'ed display label for the caveat group. If null then use the - * default label key. - * @param descriptionKey The key to retrieve the I18n'ed description of the caveat group. If null then use the - * default description key. - * @param caveatGroupType The relationship between marks in the group. - * @param caveatMarks The marks that are contained in this group. - */ - public CaveatGroup(String id, String displayLabelKey, String descriptionKey, - QName modelProperty, CaveatGroupType caveatGroupType, - List caveatMarks) - { - RMParameterCheck.checkNotBlank("id", id); - ParameterCheck.mandatory("caveatGroupType", caveatGroupType); - ParameterCheck.mandatoryCollection("caveatMarks", caveatMarks); - - if (StringUtils.isBlank(displayLabelKey)) - { - displayLabelKey = DEFAULT_CAVEAT_PREFIX + id + ".label"; - } - if (StringUtils.isBlank(descriptionKey)) - { - descriptionKey = DEFAULT_CAVEAT_PREFIX + id + ".description"; - } - - this.id = id; - this.displayLabelKey = displayLabelKey; - this.descriptionKey = descriptionKey; - this.modelProperty = modelProperty; - this.caveatGroupType = caveatGroupType; - for (CaveatMark caveatMark : caveatMarks) - { - caveatMark.setGroupId(id); - } - this.caveatMarks = immutableMapOf(caveatMarks); - } - - /** - * Create an immutable map from the supplied caveat marks. - * - * @param caveatMarks A list of the marks. - * @return An map from group id to caveat group, with keys in the same order as the list. - */ - private ImmutableMap immutableMapOf(List caveatMarks) - { - Builder builder = ImmutableMap.builder(); - for (CaveatMark caveatMark : caveatMarks) - { - builder.put(caveatMark.getId(), caveatMark); - } - return builder.build(); - } - - /** - * Gets the unique id of the caveat group. - */ - public String getId() - { - return id; - } - - /** - * Gets the I18n'ed display label for the caveat group. - */ - public String getDisplayLabel() - { - return CoreServicesExtras.getI18NMessageOrKey(displayLabelKey); - } - - /** - * Gets the I18n'ed description of the caveat group. - */ - public String getDescription() - { - return CoreServicesExtras.getI18NMessageOrKey(descriptionKey); - } - - /** Gets the content model property in which the caveat marks will be recorded. */ - public QName getModelProperty() - { - return modelProperty; - } - - /** - * Indicates how the marks in the caveat groups are related. - */ - public CaveatGroupType getCaveatGroupType() - { - return caveatGroupType; - } - - /** - * Get the caveat marks in the order they were supplied. - */ - public ImmutableCollection getCaveatMarks() - { - return caveatMarks.values(); - } - - /** - * Indicates whether a mark exists in this caveat group or not. - * - * @param markId The identifier of the mark. - */ - public boolean hasCaveatMark(String markId) - { - return caveatMarks.containsKey(markId); - } - - /** - * Get caveat mark by identifier. - * - * @param markId The identified of the mark. - * @throws CaveatMarkNotFound If the supplied id does not match a mark in this group. - */ - public CaveatMark getCaveatMark(String markId) - { - if (!hasCaveatMark(markId)) - { - throw new CaveatMarkNotFound(markId); - } - return caveatMarks.get(markId); - } - - @Override - public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(this.getClass().getSimpleName()) - .append(":").append(id); - - return msg.toString(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CaveatGroup that = (CaveatGroup) o; - - return this.id.equals(that.id); - } - - @Override - public int hashCode() - { - return id.hashCode(); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroupType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroupType.java deleted file mode 100644 index 1b0d397a60..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroupType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.scheme; - -/** - * An enumeration of the type of caveat groups. - * - * @author Tom Page - * @since 2.4.a - */ -public enum CaveatGroupType -{ - /** Each mark in the group implies all earlier marks also apply. */ - HIERARCHICAL, - /** Many marks may be applied to content, and users need all marks to access it. */ - USER_REQUIRES_ALL, - /** Many marks may be applied to content, and users can access it with any one mark. */ - USER_REQUIRES_ANY -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatMark.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatMark.java deleted file mode 100644 index 1b89f91d8d..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatMark.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.scheme; - -import static org.alfresco.module.org_alfresco_module_rm.caveat.CaveatConstants.DEFAULT_CAVEAT_PREFIX; - -import java.io.Serializable; - -import org.alfresco.module.org_alfresco_module_rm.util.CoreServicesExtras; -import org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck; -import org.apache.commons.lang3.StringUtils; - -/** - * A marking from a caveat group that can be applied to content to restrict access to users who have a corresponding - * mark. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatMark implements Serializable -{ - /** Generated serial version id. */ - private static final long serialVersionUID = 2805846540946220526L; - /** The id of the group that this mark belongs to. */ - private String groupId; - /** The id for this mark. */ - private final String id; - /** The I18N key for the display label of this mark. */ - private String displayLabelKey; - - /** - * Constructor for the caveat group. - * - * @param id The id for this mark. - * @param displayLabelKey The I18N key for the display label of this mark. - * @param groupId The id of the group that this mark belongs to. If null is supplied then this can be set later. - */ - public CaveatMark(String id, String displayLabelKey, String groupId) - { - RMParameterCheck.checkNotBlank("id", id); - - this.id = id; - this.displayLabelKey = displayLabelKey; - if (!StringUtils.isBlank(groupId)) - { - // Set the group id, and also set the displayLabelKey to the default value if possible (and not already set). - setGroupId(groupId); - } - } - - /** - * Constructor for a caveat group that does not yet belong to a group. - * - * @param id The id for this mark. - * @param displayLabelKey The I18N key for the display label of this mark. If a key is not supplied then the default - * display label key is used instead. - */ - public CaveatMark(String id, String displayLabelKey) - { - this(id, displayLabelKey, null); - } - - /** - * Constructor for a caveat group that does not yet belong to a group. - *

- * This uses the default display label key. - * - * @param id The id for this mark. - */ - public CaveatMark(String id) - { - this(id, null); - } - - /** - * Get the identifier for the group that this mark belongs to. - */ - public String getGroupId() - { - return groupId; - } - - /** - * Set the identifier of the group that this mark belongs to. - *

- * If no display label key has been provided up to this point then also create a default value. - */ - public void setGroupId(String groupId) - { - RMParameterCheck.checkNotBlank("groupId", groupId); - - this.groupId = groupId; - - if (StringUtils.isBlank(displayLabelKey)) - { - displayLabelKey = DEFAULT_CAVEAT_PREFIX + groupId + ".mark." + id + ".label"; - } - } - - /** - * Get the identifier for the mark. - */ - public String getId() - { - return id; - } - - /** - * Get the display label for the mark. - */ - public String getDisplayLabel() - { - return CoreServicesExtras.getI18NMessageOrKey(displayLabelKey); - } - - /** - * Get the display label key for the mark. - */ - public String getDisplayLabelKey() - { - return displayLabelKey; - } - - @Override - public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(this.getClass().getSimpleName()) - .append(":").append(id); - - return msg.toString(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CaveatMark that = (CaveatMark) o; - - return this.id.equals(that.id); - } - - @Override - public int hashCode() - { - return id.hashCode(); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeService.java deleted file mode 100644 index badeffd017..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.scheme; - -import java.util.Set; - -public interface CaveatSchemeService -{ - /** - * Indicates whether a named caveat group exists or not. - */ - boolean existsCaveatGroup(String id); - - /** - * Gets a set of all the available caveat groups - */ - Set getCaveatGroups(); - - /** - * Gets a caveat group by its unique id. - */ - CaveatGroup getCaveatGroup(String id); -} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeServiceImpl.java deleted file mode 100644 index b76f10dbfe..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.scheme; - -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.caveat.dao.CaveatDAOInterface; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; - -public class CaveatSchemeServiceImpl extends ServiceBaseImpl implements CaveatSchemeService -{ - private CaveatDAOInterface caveatDAO; - - public void setCaveatDAO(CaveatDAOInterface caveatDAO) - { - this.caveatDAO = caveatDAO; - } - - @Override public boolean existsCaveatGroup(String id) - { - return caveatDAO.getCaveatGroups().containsKey(id); - } - - @Override public Set getCaveatGroups() - { - return new HashSet<>(caveatDAO.getCaveatGroups().values()); - } - - @Override public CaveatGroup getCaveatGroup(String id) - { - return caveatDAO.getGroupById(id); - } -} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationAspectProperties.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationAspectProperties.java deleted file mode 100644 index 276b2a4611..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationAspectProperties.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * A data transfer object for properties from the classification aspect. - * - * @author Tom Page - * @since 2.4.a - */ -public class ClassificationAspectProperties -{ - /** The security clearance needed to access the content. */ - private String classificationLevelId; - - /** Free-form text identifying who classified the content. */ - private String classifiedBy; - - /** The name of the agency responsible for the classification of this content. */ - private String classificationAgency; - - /** A non-empty set of ids of reasons for classifying the content in this way. */ - private Set classificationReasonIds = new HashSet<>(); - - /** If provided, this is the date of the next downgrade evaluation. */ - private Date downgradeDate; - - /** If provided, this is the event at which the next downgrade evaluation will take place. */ - private String downgradeEvent; - - /** If a downgrade date or event is given then this must be provided too with the instructions for the evaluation. */ - private String downgradeInstructions; - - /** If provided, this is the date of the next declassification evaluation. */ - private Date declassificationDate; - - /** If provided, this is the event at which the next declassification evaluation will take place. */ - private String declassificationEvent; - - /** An optional list of exemption category ids. */ - private Set exemptionCategoryIds = new HashSet<>(); - - /** This needs to be provided if the classification level is changed */ - private String lastReclassifyBy; - - /** This needs to be provided if the classification level is changed */ - private String lastReclassifyReason; - - /** @return The security clearance needed to access the content. */ - public String getClassificationLevelId() - { - return classificationLevelId; - } - - /** @param classificationLevelId The security clearance needed to access the content. */ - public void setClassificationLevelId(String classificationLevelId) - { - this.classificationLevelId = classificationLevelId; - } - - /** @return Free-form text identifying who classified the content. */ - public String getClassifiedBy() - { - return classifiedBy; - } - - /** @param classifiedBy Free-form text identifying who classified the content. */ - public void setClassifiedBy(String classifiedBy) - { - this.classifiedBy = classifiedBy; - } - - /** @return The name of the agency responsible for the classification of this content. */ - public String getClassificationAgency() - { - return classificationAgency; - } - - /** @param classificationAgency The name of the agency responsible for the classification of this content. */ - public void setClassificationAgency(String classificationAgency) - { - this.classificationAgency = classificationAgency; - } - - /** @return A non-empty set of ids of reasons for classifying the content in this way. */ - public Set getClassificationReasonIds() - { - return classificationReasonIds; - } - - /** - * Store an immutable copy of the given set of classification reason ids. - * - * @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way. - */ - public void setClassificationReasonIds(Set classificationReasonIds) - { - this.classificationReasonIds = ImmutableSet.copyOf(classificationReasonIds); - } - - /** @return If provided, this is the date of the next downgrade evaluation. */ - public Date getDowngradeDate() - { - return downgradeDate; - } - - /** @param downgradeDate If provided, this is the date of the next downgrade evaluation. */ - public void setDowngradeDate(Date downgradeDate) - { - this.downgradeDate = downgradeDate; - } - - /** @return If provided, this is the event at which the next downgrade evaluation will take place. */ - public String getDowngradeEvent() - { - return downgradeEvent; - } - - /** @param downgradeEvent If provided, this is the event at which the next downgrade evaluation will take place. */ - public void setDowngradeEvent(String downgradeEvent) - { - this.downgradeEvent = downgradeEvent; - } - - /** @return If a downgrade date or event is given then this must be provided too with the instructions for the evaluation. */ - public String getDowngradeInstructions() - { - return downgradeInstructions; - } - - /** @param downgradeInstructions If a downgrade date or event is given then this must be provided too with the instructions for the evaluation. */ - public void setDowngradeInstructions(String downgradeInstructions) - { - this.downgradeInstructions = downgradeInstructions; - } - - /** @return If provided, this is the date of the next declassification evaluation. */ - public Date getDeclassificationDate() - { - return declassificationDate; - } - - /** @param declassificationDate If provided, this is the date of the next declassification evaluation. */ - public void setDeclassificationDate(Date declassificationDate) - { - this.declassificationDate = declassificationDate; - } - - /** @return If provided, this is the event at which the next declassification evaluation will take place. */ - public String getDeclassificationEvent() - { - return declassificationEvent; - } - - /** @param declassificationEvent If provided, this is the event at which the next declassification evaluation will take place. */ - public void setDeclassificationEvent(String declassificationEvent) - { - this.declassificationEvent = declassificationEvent; - } - - /** @return This is an optional list of exemption category ids. */ - public Set getExemptionCategoryIds() - { - return exemptionCategoryIds; - } - - /** - * Store an immutable copy of the given set of exemption category ids. - * - * @param exemptionCategoryIds This is an optional list of exemption category ids. - */ - public void setExemptionCategoryIds(Set exemptionCategoryIds) - { - this.exemptionCategoryIds = ImmutableSet.copyOf(exemptionCategoryIds); - } - - /** - * The user name (free form value) who reclassified the previously classified content - * - * @return the lastReclassifyBy The user name who reclassified the content - */ - public String getLastReclassifyBy() - { - return this.lastReclassifyBy; - } - - /** - * The user name (free form value) who is reclassifying the previously classified content - * - * @param lastReclassifyBy the lastReclassifyBy to set - */ - public void setLastReclassifyBy(String lastReclassifyBy) - { - this.lastReclassifyBy = lastReclassifyBy; - } - - /** - * The reclassification reason - * - * @return the lastReclassifyReason The reason for reclassification - */ - public String getLastReclassifyReason() - { - return this.lastReclassifyReason; - } - - /** - * The reason for reclassification - * - * @param lastReclassifyReason the lastReclassifyReason to set - */ - public void setLastReclassifyReason(String lastReclassifyReason) - { - this.lastReclassifyReason = lastReclassifyReason; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationException.java deleted file mode 100644 index 0b2774e2c6..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationException.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.Collections; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Generic class for any runtime exception to do with classified records. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ClassificationException extends AlfrescoRuntimeException -{ - /** serial version uid */ - private static final long serialVersionUID = -7097573558438226725L; - - public ClassificationException(String msgId) { super(msgId); } - public ClassificationException(String msgId, Throwable cause) { super(msgId, cause); } - - /** Represents a fatal error due to missing required configuration. */ - public static class MissingConfiguration extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -750162955179494445L; - - public MissingConfiguration(String msgId) { super(msgId); } - } - - /** Represents a fatal error due to illegal configuration. - * The configuration was understood by the server, but was rejected as illegal. */ - public static class IllegalConfiguration extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -1139626996782741741L; - - public IllegalConfiguration(String msgId) { super(msgId); } - } - - /** Represents a fatal error due to illegal {@link ClassificationLevel#getId() classification level ID} configuration. - * The configuration was understood by the server, but was rejected as illegal. */ - public static class IllegalAbbreviationChars extends IllegalConfiguration - { - /** serial version uid */ - private static final long serialVersionUID = 98787676565465454L; - - private final List illegalChars; - public IllegalAbbreviationChars(String msgId, List illegalChars) - { - super(msgId); - this.illegalChars = illegalChars; - } - public List getIllegalChars() { return Collections.unmodifiableList(illegalChars); } - } - - /** Represents a fatal error due to malformed configuration. - * The configuration could not be understood by the server. */ - public static class MalformedConfiguration extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = 8191162359241035026L; - - public MalformedConfiguration(String msgId) { super(msgId); } - public MalformedConfiguration(String msgId, Throwable cause) { super(msgId, cause); } - } - - /** The supplied classification level id was not found in the configured list. */ - public static class LevelIdNotFound extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -8507186704795004383L; - - public LevelIdNotFound(String levelId) - { - super("Could not find classification level with id " + levelId); - } - } - - /** The supplied classification reason id was not found in the configured list. */ - public static class ReasonIdNotFound extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -643842413653375433L; - - public ReasonIdNotFound(String reasonId) - { - super("Could not find classification reason with id " + reasonId); - } - } - - /** The supplied exemption category id was not found in the configured list. */ - public static class ExemptionCategoryIdNotFound extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -6754627999115496384L; - - public ExemptionCategoryIdNotFound(String id) - { - super("Could not find classification reason with id " + id); - } - } - - public static class InvalidNode extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -4485335425932302477L; - - public InvalidNode(NodeRef nodeRef, String message) - { - super("Operation not permitted on node " + nodeRef + ", error message: " + message); - } - } - - /** A downgrade date or event has been specified, but there are no corresponding instructions. */ - public static class MissingDowngradeInstructions extends ClassificationException - { - /** serial version uid */ - private static final long serialVersionUID = -1561288436418050014L; - - public MissingDowngradeInstructions(NodeRef nodeRef) - { - super("A downgrade date or event has been specified, but there are no corresponding instructions for " - + nodeRef); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevel.java deleted file mode 100644 index b817a2206a..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevel.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatMark; -import org.alfresco.module.org_alfresco_module_rm.util.CoreServicesExtras; -import org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck; -import org.alfresco.util.ParameterCheck; - -/** - * This class is a POJO data type for a Classification Level. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public final class ClassificationLevel implements ClassificationSchemeEntity -{ - /** serial version uid */ - private static final long serialVersionUID = -3375064867090476422L; - - private CaveatMark caveatMark; - private String id; - private String displayLabelKey; - - public ClassificationLevel(final CaveatMark caveatMark) - { - ParameterCheck.mandatory("caveatMark", caveatMark); - this.caveatMark = caveatMark; - } - - public ClassificationLevel(final String id, final String displayLabelKey) - { - RMParameterCheck.checkNotBlank("id", id); - RMParameterCheck.checkNotBlank("displayLabelKey", displayLabelKey); - this.id = id; - this.displayLabelKey = displayLabelKey; - } - - /** Returns the unique identifier for this classification level. */ - public String getId() - { - if (caveatMark == null) - { - return this.id; - } - return caveatMark.getId(); - } - - /** Returns the key for the display label. */ - public String getDisplayLabelKey() - { - if (caveatMark == null) - { - return displayLabelKey; - } - return caveatMark.getDisplayLabelKey(); - } - - /** - * Returns the localised (current locale) display label for this classification level. If no translation is found - * then return the key instead. - */ - public String getDisplayLabel() - { - if (caveatMark == null) - { - return CoreServicesExtras.getI18NMessageOrKey(displayLabelKey); - } - return caveatMark.getDisplayLabel(); - } - - @Override public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(ClassificationLevel.class.getSimpleName()) - .append(":").append(getId()); - - return msg.toString(); - } - - @Override public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ClassificationLevel that = (ClassificationLevel) o; - - return this.getId().equals(that.getId()); - } - - @Override public int hashCode() { return getId().hashCode(); } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java deleted file mode 100644 index a176b14b1c..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.Comparator; - -/** - * A class to compare classification levels. More secure classification levels are "higher" than less secure levels. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationLevelComparator implements Comparator -{ - private ClassificationLevelManager classificationLevelManager; - - public ClassificationLevelComparator(ClassificationLevelManager classificationLevelManager) - { - this.classificationLevelManager = classificationLevelManager; - } - - /** - * Return a positive number if the first classification level is more secure than the second. {@inheritDoc} - */ - @Override - public int compare(ClassificationLevel oneLevel, ClassificationLevel otherLevel) - { - int oneIndex = classificationLevelManager.getClassificationLevels().indexOf(oneLevel); - int otherIndex = classificationLevelManager.getClassificationLevels().indexOf(otherLevel); - // Smaller indexes are more secure. - return otherIndex - oneIndex; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelConstraint.java deleted file mode 100644 index 73433e8136..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelConstraint.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.ArrayList; -import java.util.List; - -/** - * Check that a value is a valid {@link ClassificationLevel} by checking the {@link ClassificationSchemeService}. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationLevelConstraint extends ClassificationSchemeEntityConstraint -{ - /** - * Get the allowed values. Note that these are String instances, but may - * represent non-String values. It is up to the caller to distinguish. - * - * @return Returns the values allowed - */ - @Override - protected List getAllowedValues() - { - List classificationLevels = classificationSchemeService.getClassificationLevels(); - List values = new ArrayList(); - for (ClassificationLevel classificationLevel : classificationLevels) - { - values.add(classificationLevel.getId()); - } - return values; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelManager.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelManager.java deleted file mode 100644 index b1951e861c..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelManager.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.ArrayList; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; - -/** - * Container for the configured {@link ClassificationLevel} objects. - * - * @author tpage - */ -public class ClassificationLevelManager -{ - /** Unclassified classification level */ - public static final String UNCLASSIFIED_ID = "U"; - private static final String UNCLASSIFIED_MSG = "rm.classification.unclassified"; - public static final ClassificationLevel UNCLASSIFIED = new ClassificationLevel(UNCLASSIFIED_ID, UNCLASSIFIED_MSG); - - /** An immutable list of classification levels ordered from most to least secure. */ - private ImmutableList classificationLevels; - - /** - * Store an immutable copy of the given classification levels. - * - * @param classificationLevels A list of classification levels ordered from most to least secure. - */ - public void setClassificationLevels(List classificationLevels) - { - List temp = new ArrayList<>(classificationLevels); - temp.add(temp.size(), UNCLASSIFIED); - this.classificationLevels = ImmutableList.copyOf(temp); - } - - /** @return the highest security classification level. */ - public ClassificationLevel getMostSecureLevel() - { - return classificationLevels.get(0); - } - - /** @return An immutable list of classification levels ordered from most to least secure. */ - public ImmutableList getClassificationLevels() - { - return classificationLevels; - } - - /** - * Get a ClassificationLevel using its id. - * - * @param id The id of a classification level. - * @return The classification level. - * @throws LevelIdNotFound If the classification level cannot be found. - */ - public ClassificationLevel findLevelById(String id) throws LevelIdNotFound - { - for (ClassificationLevel classificationLevel : classificationLevels) - { - if (classificationLevel.getId().equals(id)) - { - return classificationLevel; - } - } - throw new LevelIdNotFound(id); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java deleted file mode 100644 index 5bfb8b11db..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck; -import org.springframework.extensions.surf.util.I18NUtil; - - -/** - * This class is a POJO data type for a classification reason. - * - * @author Tom Page - * @since 2.4.a - */ -public final class ClassificationReason implements ClassificationSchemeEntity -{ - private static final long serialVersionUID = 4876939094239038838L; - private final String id; - private final String displayLabelKey; - - /** - * Constructor to create a classification reason. - * - * @param id The unique identifier that represents this classification reason. - * @param displayLabelKey The I18N key for the display label for the reason. - */ - public ClassificationReason(final String id, final String displayLabelKey) - { - RMParameterCheck.checkNotBlank("id", id); - RMParameterCheck.checkNotBlank("displayLabelKey", displayLabelKey); - this.id = id; - this.displayLabelKey = displayLabelKey; - } - - /** - * Returns the unique identifier that represents this classification reason. - */ - public String getId() - { - return id; - } - - /** - * Returns the I18N key for the display label for the reason. - */ - public String getDisplayLabelKey() - { - return displayLabelKey; - } - - /** - * Returns the localised (current locale) display label for this classification reason. If no translation is found - * then return the key instead. - */ - public String getDisplayLabel() - { - String message = I18NUtil.getMessage(displayLabelKey); - return (message != null ? message : displayLabelKey); - } - - @Override - public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(ClassificationReason.class.getSimpleName()).append(":").append(id); - - return msg.toString(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ClassificationReason that = (ClassificationReason) o; - - return this.id.equals(that.id); - } - - @Override - public int hashCode() - { - return id.hashCode(); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonConstraint.java deleted file mode 100644 index cdd174969a..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonConstraint.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.ArrayList; -import java.util.List; - -/** - * Check that a value is a valid {@link ClassificationReason} by checking the {@link ClassificationSchemeService}. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationReasonConstraint extends ClassificationSchemeEntityConstraint -{ - /** - * Get the allowed values. Note that these are String instances, but may - * represent non-String values. It is up to the caller to distinguish. - * - * @return Returns the values allowed - */ - @Override - protected List getAllowedValues() - { - List classificationReasons = classificationSchemeService.getClassificationReasons(); - List values = new ArrayList(); - for (ClassificationReason classificationReason : classificationReasons) - { - values.add(classificationReason.getId()); - } - return values; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonManager.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonManager.java deleted file mode 100644 index e03babdf66..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonManager.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.Collection; - -import com.google.common.collect.ImmutableList; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; - -/** - * Container for the configured {@link ClassificationReason} objects. - * - * @author tpage - */ -public class ClassificationReasonManager -{ - /** An immutable list of classification reasons. */ - private ImmutableList classificationReasons; - - /** - * Store an immutable copy of the given reasons. - * - * @param classificationReasons The classification reasons. - */ - public void setClassificationReasons(Collection classificationReasons) - { - this.classificationReasons = ImmutableList.copyOf(classificationReasons); - } - - /** @return An immutable list of classification reasons. */ - public ImmutableList getClassificationReasons() - { - return classificationReasons; - } - - /** - * Get a ClassificationReason using its id. - * - * @param id The id of a classification reason. - * @return The classification reason. - * @throws ReasonIdNotFound If the classification reason cannot be found. - */ - public ClassificationReason findReasonById(String id) throws ReasonIdNotFound - { - for (ClassificationReason classificationReason : classificationReasons) - { - if (classificationReason.getId().equals(id)) - { - return classificationReason; - } - } - throw new ReasonIdNotFound(id); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntity.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntity.java deleted file mode 100644 index b698f5f0aa..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.io.Serializable; - -/** - * Marker interface for classes that contain basic information about the classification scheme. - * - * @author tpage - * @since 2.4.a - */ -public interface ClassificationSchemeEntity extends Serializable -{ - // Intentionally empty -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityConstraint.java deleted file mode 100644 index 8080086004..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityConstraint.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.caveat.RMConstraintMessageKeys; -import org.alfresco.repo.dictionary.constraint.AbstractConstraint; -import org.alfresco.service.cmr.dictionary.ConstraintException; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.cmr.repository.datatype.TypeConversionException; - -/** - * Abstract for constraints the check that a value is a valid {@link ClassificationSchemeEntity} using the - * {@link ClassificationSchemeService}. - * - * @author tpage - * @since 2.4.a - */ -public abstract class ClassificationSchemeEntityConstraint extends AbstractConstraint -{ - /** The classification scheme service provides access to the valid classification levels. */ - protected ClassificationSchemeService classificationSchemeService; - - /** Constraints must use a default constructor. */ - public ClassificationSchemeEntityConstraint() - { - super(); - this.classificationSchemeService = ClassificationSchemeServiceProvider.getClassificationSchemeService(); - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - // TODO Decide whether calling getAllowedValues() is a good idea. - sb.append(this.getClass().getSimpleName()) - .append("[allowedValues=").append(getAllowedValues()) - .append("]"); - return sb.toString(); - } - - /** - * Get the allowed values. Note that these are String instances, but may - * represent non-String values. It is up to the caller to distinguish. - * - * @return Returns the values allowed - */ - protected abstract List getAllowedValues(); - - /** {@inheritDoc} */ - @Override - protected void evaluateSingleValue(Object value) - { - // convert the value to a String - String valueStr = null; - try - { - valueStr = DefaultTypeConverter.INSTANCE.convert(String.class, value); - } - catch (TypeConversionException e) - { - throw new ConstraintException(RMConstraintMessageKeys.ERR_NON_STRING, value); - } - // Check that the classification level is one of the configured levels. - if (!getAllowedValues().contains(valueStr)) - { - throw new ConstraintException(RMConstraintMessageKeys.ERR_INVALID_VALUE, value); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityFactory.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityFactory.java deleted file mode 100644 index f2865f42ca..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Factory to create classification entities from JSON objects. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationSchemeEntityFactory -{ - /** - * Create the classification entity from the supplied JSON. - * - * @param clazz The class to create. - * @param jsonObject The JSON object from the configuration file. - * @return The new entity. - * @throws JSONException If there is an error in the JSON. - */ - @SuppressWarnings("unchecked") - public T create(Class clazz, JSONObject jsonObject) throws JSONException - { - if (clazz == ClassificationLevel.class) - { - String id = jsonObject.getString("name"); - String displayLabelKey = jsonObject.getString("displayLabel"); - return (T) new ClassificationLevel(id, displayLabelKey); - } - else if (clazz == ClassificationReason.class) - { - String id = jsonObject.getString("id"); - String displayLabelKey = jsonObject.getString("displayLabel"); - return (T) new ClassificationReason(id, displayLabelKey); - } - else if (clazz == ExemptionCategory.class) - { - String id = jsonObject.getString("id"); - String displayLabelKey = jsonObject.getString("displayLabel"); - return (T) new ExemptionCategory(id, displayLabelKey); - } - throw new IllegalStateException("Unsupported entity type: " + clazz); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeService.java deleted file mode 100644 index 958112faab..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeService.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; - -/** - * The Classification Scheme Service supports the 'Classified Records' feature, whereby Alfresco content can be given a - * {@link ClassificationLevel}. This restricts access to that content to users having the appropriate security - * clearance. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public interface ClassificationSchemeService -{ - /** - * Returns an immutable list of the defined classification levels visible to the current user. - * - * @return classification levels in descending order from highest to lowest - * (where fewer users have access to the highest classification levels - * and therefore access to the most restricted documents). - */ - List getClassificationLevels(); - - /** - * Returns an immutable list of all the classification levels defined in the system. - * - * @return classification levels in descending order from highest to lowest - * (where fewer users have access to the highest classification levels - * and therefore access to the most restricted documents). - */ - List getAllClassificationLevels(); - - /** - * Returns an immutable list of the defined classification reasons. - * @return classification reasons in the order that they are defined. - */ - List getClassificationReasons(); - - /** - * Gets the unclassified {@link ClassificationLevel}. - * @return the unclassified classification level - */ - ClassificationLevel getUnclassifiedClassificationLevel(); - - /** - * Gets the classification level for the given classification level id - * - * @param classificationLevelId {@link String} The classification level id for which the classification level should be retrieved. - * @return The classification level for the given classification level id - * @throws LevelIdNotFound If the given classification level id is not found - */ - ClassificationLevel getClassificationLevelById(String classificationLevelId) throws LevelIdNotFound; - - /** - * Gets the classification reason for the given classification reason id - * - * @param classificationReasonId {@link String} The classification reason id for which the classification reason should be retrieved. - * @return The classification reason for the given classification reason id - * @throws ReasonIdNotFound If the given classification reason id is not found - */ - ClassificationReason getClassificationReasonById(String classificationReasonId) throws ReasonIdNotFound; - - /** - * Returns an immutable list of the defined exemption categories. - * - * @return The exemption categories in the order that they are defined. - */ - List getExemptionCategories(); - - /** - * Gets the exemption category for the given exemption category id - * - * @param exemptionCategoryId {@link String} The exemption category id for which the exemption category should be retrieved. - * @return The exemption category for the given exemption category id - * @throws ExemptionCategoryIdNotFound If the given exemption id is not found - */ - ExemptionCategory getExemptionCategoryById(String exemptionCategoryId) throws ExemptionCategoryIdNotFound; - - /** - * Identifies the reclassification type for the provided pair of {@link ClassificationLevel levels}. - * - * @param from the first classification level. - * @param to the second classification level. - * @return the reclassification represented by this change, or {@code null} if it is not a change. - */ - Reclassification getReclassification(ClassificationLevel from, ClassificationLevel to); - - /** - * Gets the allowed values for reclassification actions. - * @see Reclassification - */ - Set getReclassificationValues(); - - /** Types of reclassification. */ - enum Reclassification - { - UPGRADE, DOWNGRADE, DECLASSIFY; - - /** Returns the name of this enum value in a format suitable for storage in the Alfresco repo. */ - public String toModelString() - { - final String name = toString(); - final StringBuilder result = new StringBuilder(name.length()); - result.append(name.charAt(0)) - .append(name.substring(1).toLowerCase()); - return result.toString(); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceImpl.java deleted file mode 100644 index b5ef297f0e..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static java.util.Collections.unmodifiableSet; -import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.util.ParameterCheck; - -/** - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ClassificationSchemeServiceImpl extends ServiceBaseImpl implements ClassificationSchemeService, - ClassifiedContentModel -{ - /** The classification levels currently configured in this server. */ - private ClassificationLevelManager levelManager; - /** The classification reasons currently configured in this server. */ - private ClassificationReasonManager reasonManager; - /** The exemption categories currently configured in this server. */ - private ExemptionCategoryManager exemptionCategoryManager; - private SecurityClearanceService securityClearanceService; - private ClassificationServiceBootstrap classificationServiceBootstrap; - - public void setNodeService(NodeService service) { this.nodeService = service; } - public void setSecurityClearanceService(SecurityClearanceService securityClearanceService) { this.securityClearanceService = securityClearanceService; } - public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap) { this.classificationServiceBootstrap = classificationServiceBootstrap; } - - /** Store the references to the classification level and reason managers in this class. */ - public void init() - { - levelManager = classificationServiceBootstrap.getClassificationLevelManager(); - reasonManager = classificationServiceBootstrap.getClassificationReasonManager(); - exemptionCategoryManager = classificationServiceBootstrap.getExemptionCategoryManager(); - } - - /** - * Create a list containing all classification levels up to and including the supplied level. - * - * @param allLevels The list of all the classification levels starting with the highest security. - * @param targetLevel The highest security classification level that should be returned. If this is not found then - * an empty list will be returned. - * @return an immutable list of the levels that a user at the target level can see. - */ - List restrictList(List allLevels, ClassificationLevel targetLevel) - { - int targetIndex = allLevels.indexOf(targetLevel); - if (targetIndex == -1) { return Collections.emptyList(); } - List subList = allLevels.subList(targetIndex, allLevels.size()); - return Collections.unmodifiableList(subList); - } - - @Override - public List getClassificationLevels() - { - if (levelManager == null) - { - return Collections.emptyList(); - } - SecurityClearance securityClearance = securityClearanceService.getUserSecurityClearance(); - ClassificationLevel usersLevel = securityClearance.getClearanceLevel().getHighestClassificationLevel(); - return restrictList(levelManager.getClassificationLevels(), usersLevel); - } - - @Override - public List getAllClassificationLevels() - { - if (levelManager == null) - { - return Collections.emptyList(); - } - return levelManager.getClassificationLevels(); - } - - @Override public List getClassificationReasons() - { - return reasonManager == null ? Collections.emptyList() : - Collections.unmodifiableList(reasonManager.getClassificationReasons()); - } - - @Override public ClassificationLevel getUnclassifiedClassificationLevel() - { - return ClassificationLevelManager.UNCLASSIFIED; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService#getClassificationLevelById(java.lang.String) - */ - @Override - public ClassificationLevel getClassificationLevelById(String classificationLevelId) throws LevelIdNotFound - { - checkNotBlank("classificationLevelId", classificationLevelId); - return levelManager.findLevelById(classificationLevelId); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService#getClassificationReasonById(java.lang.String) - */ - @Override - public ClassificationReason getClassificationReasonById(String classificationReasonId) throws ReasonIdNotFound - { - checkNotBlank("classificationReasonId", classificationReasonId); - return reasonManager.findReasonById(classificationReasonId); - } - - @Override - public List getExemptionCategories() - { - return (exemptionCategoryManager == null ? Collections.emptyList() : - Collections.unmodifiableList(exemptionCategoryManager.getExemptionCategories())); - } - - @Override - public Reclassification getReclassification(ClassificationLevel from, ClassificationLevel to) - { - ParameterCheck.mandatory("from", from); - ParameterCheck.mandatory("to", to); - - final List levels = getClassificationLevels(); - - final int fromIndex = levels.indexOf(from); - final int toIndex = levels.indexOf(to); - final int lastIndex = levels.size() - 1; - - if (from.equals(to)) - { return null; } - else if (toIndex == lastIndex) - { - return Reclassification.DECLASSIFY; - } - else - { - return fromIndex < toIndex ? Reclassification.DOWNGRADE : Reclassification.UPGRADE; - } - } - - @Override - public Set getReclassificationValues() - { - Set result = new HashSet<>(); - for (Reclassification r : Reclassification.values()) - { - result.add(r.toModelString()); - } - return unmodifiableSet(result); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService#getExemptionCategoryById(java.lang.String) - */ - @Override - public ExemptionCategory getExemptionCategoryById(String exemptionCategoryId) throws ExemptionCategoryIdNotFound - { - checkNotBlank("exemptionCategoryId", exemptionCategoryId); - return exemptionCategoryManager.findCategoryById(exemptionCategoryId); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceProvider.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceProvider.java deleted file mode 100644 index 142ae08066..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.concurrent.atomic.AtomicReference; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * A Spring class used to provide the {@link ClassificationSchemeService} to non-Spring classes. - * - * @author tpage - */ -public class ClassificationSchemeServiceProvider -{ - /** Logging utility for the class. */ - private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationSchemeServiceProvider.class); - /** The Spring application context. */ - private static final AtomicReference CLASSIFICATION_SCHEME_SERVICE_REF = new AtomicReference<>(); - - /** Constructor that takes the classification scheme service and makes it available statically. */ - public ClassificationSchemeServiceProvider(ClassificationSchemeService classificationSchemeService) - { - ClassificationSchemeService oldClassificationSchemeService = CLASSIFICATION_SCHEME_SERVICE_REF.getAndSet(classificationSchemeService); - if (oldClassificationSchemeService != null) - { - LOGGER.debug("Unexpected instantiation of ClassificationSchemeServiceProvider has updated reference to classification scheme service."); - } - } - - /** - * Get the ClassificationSchemeService as defined in the Spring context. - * - * @return The service bean. - */ - public static ClassificationSchemeService getClassificationSchemeService() - { - return CLASSIFICATION_SCHEME_SERVICE_REF.get(); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrap.java deleted file mode 100644 index f4add41e3d..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrap.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import org.alfresco.module.org_alfresco_module_rm.caveat.dao.CaveatDAOInterface; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroup; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatMark; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ClassificationLevelFieldsValidator; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ClassificationReasonFieldsValidator; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ClassificationSchemeEntityValidator; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ExemptionCategoryFieldsValidator; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.alfresco.service.transaction.TransactionService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * This class is responsible for initialising any Classification-specific data on server bootstrap. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ClassificationServiceBootstrap extends AbstractLifecycleBean implements ClassifiedContentModel -{ - /** Logging utility for the class. */ - private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationServiceBootstrap.class); - - private final AuthenticationUtil authenticationUtil; - private final TransactionService transactionService; - private AttributeService attributeService; - /** The classification levels currently configured in this server. */ - private ClassificationLevelManager classificationLevelManager = new ClassificationLevelManager(); - /** The classification reasons currently configured in this server. */ - private ClassificationReasonManager classificationReasonManager = new ClassificationReasonManager(); - /** The clearance levels currently configured in this server. */ - private ClearanceLevelManager clearanceLevelManager = new ClearanceLevelManager(); - /** The exemption categories currently configured in this server. */ - private ExemptionCategoryManager exemptionCategoryManager = new ExemptionCategoryManager(); - /** The caveat DAO, which is used to access the classification levels. */ - private CaveatDAOInterface caveatDAO; - private ClassificationServiceDAO classificationServiceDAO; - private ClassificationLevelFieldsValidator classificationLevelFieldsValidator = new ClassificationLevelFieldsValidator(); - private ClassificationSchemeEntityValidator classificationLevelValidator = new ClassificationSchemeEntityValidator<>(classificationLevelFieldsValidator); - private ClassificationReasonFieldsValidator classificationReasonFieldsValidator = new ClassificationReasonFieldsValidator(); - private ClassificationSchemeEntityValidator classificationReasonValidator = new ClassificationSchemeEntityValidator<>(classificationReasonFieldsValidator); - private ExemptionCategoryFieldsValidator exemptionCategoryFieldsValidator = new ExemptionCategoryFieldsValidator(); - private ClassificationSchemeEntityValidator exemptionCategoryValidator = new ClassificationSchemeEntityValidator<>(exemptionCategoryFieldsValidator); - - private boolean isInitialised = false; - - public ClassificationServiceBootstrap(AuthenticationUtil authUtil, - TransactionService txService, - AttributeService attributeService, - ClassificationServiceDAO classificationServiceDAO) - { - this.authenticationUtil = authUtil; - this.transactionService = txService; - this.attributeService = attributeService; - this.classificationServiceDAO = classificationServiceDAO; - } - - /** Set the caveat DAO, which is used to access the classification levels. */ - public void setCaveatDAO(CaveatDAOInterface caveatDAO) { this.caveatDAO = caveatDAO; } - /** Set the object from which configuration options will be read. */ - public void setClassificationServiceDAO(ClassificationServiceDAO classificationServiceDAO) { this.classificationServiceDAO = classificationServiceDAO; } - public void setAttributeService(AttributeService attributeService) { this.attributeService = attributeService; } - /** Used in unit tests. */ - protected void setExemptionCategoryManager(ExemptionCategoryManager exemptionCategoryManager) { this.exemptionCategoryManager = exemptionCategoryManager; } - /** Used in unit tests. */ - protected void setClearanceLevelManager(ClearanceLevelManager clearanceLevelManager) { this.clearanceLevelManager = clearanceLevelManager; } - - public ClassificationLevelManager getClassificationLevelManager() { return classificationLevelManager; } - public ClassificationReasonManager getClassificationReasonManager() { return classificationReasonManager; } - public ExemptionCategoryManager getExemptionCategoryManager() { return exemptionCategoryManager; } - public ClearanceLevelManager getClearanceLevelManager() { return clearanceLevelManager; } - - public boolean isInitialised() - { - return isInitialised; - } - - @Override public void onBootstrap(ApplicationEvent event) - { - authenticationUtil.runAsSystem(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Void execute() - { - List levels = getConfiguredClassificationLevels(LEVELS_KEY, classificationLevelValidator); - classificationLevelManager.setClassificationLevels(levels); - - List reasons = getConfiguredSchemeEntities( - ClassificationReason.class, REASONS_KEY, classificationReasonValidator); - classificationReasonManager.setClassificationReasons(reasons); - - List exemptionCategories = getConfiguredSchemeEntities( - ExemptionCategory.class, EXEMPTION_CATEGORIES_KEY, exemptionCategoryValidator); - exemptionCategoryManager.setExemptionCategories(exemptionCategories); - - initConfiguredClearanceLevels(classificationLevelManager.getClassificationLevels()); - isInitialised = true; - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(callback); - return null; - } - }); - } - - /** - * Gets an ordered list of some attribute persisted in the system. - * @return the list of values if they have been persisted, else {@code null}. - */ - private List getPersistedValues(final Serializable[] key) - { - return authenticationUtil.runAsSystem(new RunAsWork>() - { - @Override - @SuppressWarnings("unchecked") - public List doWork() throws Exception - { - return (List) attributeService.getAttribute(key); - } - }); - } - - private static boolean isEmpty(List l) { return l == null || l.isEmpty(); } - - /** Helper method for debug-logging of sensitive lists. */ - private String loggableStatusOf(List l) - { - if (l == null) { return "null"; } - else if (l.isEmpty()) { return "empty"; } - else { return "non-empty"; } - } - - /** - * Create the classification levels from the classification caveat group data. - * - * @param key The key used to persist the classification levels in the attribute service. - * @param validator The validator used to check the classification levels. - * @return A list of the configured classification levels. - */ - protected List getConfiguredClassificationLevels(Serializable[] key, ClassificationSchemeEntityValidator validator) - { - List persistedValues = getPersistedValues(key); - CaveatGroup classificationCaveatGroup = caveatDAO.getGroupById(CLASSIFICATION_LEVEL_CAVEAT); - Builder builder = ImmutableList.builder(); - for (CaveatMark caveatMark : classificationCaveatGroup.getCaveatMarks()) - { - builder.add(new ClassificationLevel(caveatMark)); - } - List classpathValues = builder.build(); - - // Note! We cannot log the entities or even the size of these lists for security reasons. - LOGGER.debug("Persisted ClassificationLevel: {}", loggableStatusOf(persistedValues)); - LOGGER.debug("Classpath ClassificationLevel: {}", loggableStatusOf(classpathValues)); - - validator.validate(classpathValues, ClassificationLevel.class.getSimpleName()); - - if (isEmpty(classpathValues)) - { - throw new MissingConfiguration("ClassificationLevel configuration is missing."); - } - if (classpathValues.equals(persistedValues)) - { - return persistedValues; - } - if (!isEmpty(persistedValues)) - { - LOGGER.warn("ClassificationLevel configuration changed. This may result in unpredictable results if the classification scheme is already in use."); - } - attributeService.setAttribute((Serializable) classpathValues, key); - return classpathValues; - } - - protected List getConfiguredSchemeEntities(Class clazz, Serializable[] key, ClassificationSchemeEntityValidator validator) - { - final List persistedValues = getPersistedValues(key); - final List classpathValues = classificationServiceDAO.getConfiguredValues(clazz); - - // Note! We cannot log the entities or even the size of these lists for security reasons. - LOGGER.debug("Persisted {}: {}", clazz.getSimpleName(), loggableStatusOf(persistedValues)); - LOGGER.debug("Classpath {}: {}", clazz.getSimpleName(), loggableStatusOf(classpathValues)); - - validator.validate(classpathValues, clazz.getSimpleName()); - - if (isEmpty(classpathValues)) - { - throw new MissingConfiguration(clazz.getSimpleName() + " configuration is missing."); - } - if (classpathValues.equals(persistedValues)) - { - return persistedValues; - } - if (!isEmpty(persistedValues)) - { - LOGGER.warn("{} configuration changed. This may result in unpredictable results if the classification scheme is already in use.", - clazz.getSimpleName()); - } - attributeService.setAttribute((Serializable) classpathValues, key); - return classpathValues; - } - - /** - * Initialise and create a {@link ClearanceLevelManager}. - * - * @param classificationLevels The list of classification levels to use to create clearance levels from. - */ - protected void initConfiguredClearanceLevels(ImmutableList classificationLevels) - { - List clearanceLevels = new ArrayList<>(); - for (ClassificationLevel classificationLevel : classificationLevels) - { - String displayLabelKey = classificationLevel.getDisplayLabelKey(); - if (classificationLevel.equals(ClassificationLevelManager.UNCLASSIFIED)) - { - displayLabelKey = "rm.classification.noClearance"; - } - clearanceLevels.add(new ClearanceLevel(classificationLevel, displayLabelKey)); - } - this.clearanceLevelManager.setClearanceLevels(clearanceLevels); - } - - @Override protected void onShutdown(ApplicationEvent event) - { - // Intentionally empty. - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceDAO.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceDAO.java deleted file mode 100644 index a2f04b8081..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceDAO.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MalformedConfiguration; -import org.apache.commons.io.IOUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; - -/** - * This class is responsible for providing the configured classification scheme entities, dealing with JSON schema as - * part of that. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -class ClassificationServiceDAO -{ - /** A map from the simple name of a POJO type to the corresponding location of the configuration file. */ - private Map configLocations = new HashMap<>(); - - private ClassificationSchemeEntityFactory classificationSchemeEntityFactory = new ClassificationSchemeEntityFactory(); - - /** Set the location of the reasons configuration file relative to the classpath. */ - public void setReasonConfigLocation(String reasonConfigLocation) - { - configLocations.put(ClassificationReason.class.getSimpleName(), reasonConfigLocation); - } - - /** Set the location of the exemption categories configuration file relative to the classpath. */ - public void setExemptionCategoryConfigLocation(String exemptionCategoryConfigLocation) - { - configLocations.put(ExemptionCategory.class.getSimpleName(), exemptionCategoryConfigLocation); - } - - /** - * Gets the list of values as defined in the classpath. - * - * @return The configured values, or an empty list if there are none. - */ - public List getConfiguredValues(Class clazz) - { - List result; - try (final InputStream in = this.getClass().getResourceAsStream(configLocations.get(clazz.getSimpleName()))) - { - if (in == null) { result = Collections.emptyList(); } - else - { - final String jsonString = IOUtils.toString(in); - final JSONArray jsonArray = new JSONArray(new JSONTokener(jsonString)); - - result = new ArrayList<>(jsonArray.length()); - - for (int i = 0; i < jsonArray.length(); i++) - { - final JSONObject nextObj = jsonArray.getJSONObject(i); - result.add(classificationSchemeEntityFactory.create(clazz, nextObj)); - } - } - } - catch (IOException | JSONException e) - { - String message = "Could not read " + clazz.getSimpleName() + " configuration: " + configLocations.get(clazz.getSimpleName()); - throw new MalformedConfiguration(message, e); - } - return result; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevel.java deleted file mode 100644 index 86537879e7..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevel.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.apache.commons.lang.StringUtils.isNotBlank; - -import org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck; -import org.alfresco.util.ParameterCheck; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * A POJO to represent a security clearance level. This wraps a {@link ClassificationLevel} and will often have the same - * display text as well. The main exception is that the clearance level corresponding to "Unclassified" is "No Clearance". - * - * @author tpage - */ -public class ClearanceLevel -{ - /** The highest classification level that can be accessed by users with this clearance. */ - private final ClassificationLevel highestClassificationLevel; - /** The key for the display label of this security clearance. */ - private final String displayLabelKey; - - /** - * Constructor. - * - * @param highestClassificationLevel The highest classification level that can be accessed by users with this clearance. - * @param displayLabelKey The key for the display label of this security clearance. - */ - public ClearanceLevel(ClassificationLevel highestClassificationLevel, String displayLabelKey) - { - ParameterCheck.mandatory("highestClassificationLevel", highestClassificationLevel); - RMParameterCheck.checkNotBlank("displayLabelKey", displayLabelKey); - this.highestClassificationLevel = highestClassificationLevel; - this.displayLabelKey = displayLabelKey; - } - - /** Return the highest classification level that can be accessed by users with this clearance. */ - public ClassificationLevel getHighestClassificationLevel() { return this.highestClassificationLevel; } - - /** - * Returns the localised (current locale) display label for this clearance level. If no translation is found - * then return the key instead. - */ - public String getDisplayLabel() - { - String message = I18NUtil.getMessage(displayLabelKey); - return (isNotBlank(message) ? message : displayLabelKey); - } - - @Override public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(ClassificationLevel.class.getSimpleName()) - .append(":").append(highestClassificationLevel.getId()); - - return msg.toString(); - } - - @Override public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ClearanceLevel that = (ClearanceLevel) o; - - return this.highestClassificationLevel.equals(that.highestClassificationLevel); - } - - @Override public int hashCode() { return highestClassificationLevel.hashCode(); } - - /** - * Get the display label key. This method is used for unit testing, where we want to avoid problems introduced by - * the static call to the I18N utility. - * - * @return The key for the display label of this security clearance. - */ - protected String getDisplayLabelKey() - { - return displayLabelKey; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevelManager.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevelManager.java deleted file mode 100644 index 197d1bc49a..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevelManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.List; - -import com.google.common.collect.ImmutableList; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; - -/** - * Container for the configured {@link ClearanceLevel} objects. - * - * @author tpage - */ -public class ClearanceLevelManager -{ - private static String NO_CLEARANCE_MSG = "rm.classification.noClearance"; - public static final ClearanceLevel NO_CLEARANCE = new ClearanceLevel(ClassificationLevelManager.UNCLASSIFIED, NO_CLEARANCE_MSG); - - /** An immutable list of clearance levels ordered from most to least secure. */ - private ImmutableList clearanceLevels; - - /** - * Store an immutable copy of the given levels. - * - * @param clearanceLevels A list of clearance levels ordered from most to least secure. - */ - public void setClearanceLevels(List clearanceLevels) - { - this.clearanceLevels = ImmutableList.copyOf(clearanceLevels); - } - - /** @return An immutable list of clearance levels ordered from most to least secure. */ - public ImmutableList getClearanceLevels() - { - return clearanceLevels; - } - - /** - * Get a ClearanceLevel using its id. - * - * @param classificationLevelId The id of the highest classification level accessible by a clearance level. - * @return The clearance level. - * @throws LevelIdNotFound If the clearance level cannot be found. - */ - public ClearanceLevel findLevelByClassificationLevelId(String classificationLevelId) throws LevelIdNotFound - { - for (ClearanceLevel clearanceLevel : clearanceLevels) - { - if (clearanceLevel.getHighestClassificationLevel().getId().equals(classificationLevelId)) - { - return clearanceLevel; - } - } - throw new LevelIdNotFound(classificationLevelId); - } - - /** - * @return the highest security clearance level. - */ - public ClearanceLevel getMostSecureLevel() - { - return clearanceLevels.get(0); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java deleted file mode 100644 index 0d91045954..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * A service to handle the classification of content. - * - * @author tpage - * @since 2.4.a - */ -public interface ContentClassificationService -{ - /** - * Returns the current classification level of a given node. - * - * @param nodeRef node reference - * @return {@link ClassificationLevel} classification level, unclassified if none - */ - ClassificationLevel getCurrentClassification(NodeRef nodeRef); - - /** - * Classify a piece of content. - * - * @param classificationAspectProperties The properties for the classification aspect. - * @param content The node to classify. - * @throws LevelIdNotFound If the supplied level id is not found. - * @throws IllegalArgumentException If the supplied {@code classifiedBy} is {@code null}, - * the empty string or a string consisting only of whitespace. - * @throws ReasonIdNotFound If any of the supplied reason ids are not found. - * @throws InvalidNodeRefException If the node could not be found. - * @throws InvalidNode If the supplied node is not a content node. - */ - void classifyContent(ClassificationAspectProperties classificationAspectProperties, NodeRef content) - throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode; - - /** - * Edits the classified content. - * - * @param classificationAspectProperties The properties for the classification aspect. - * @param content The classified content which will be edited. - * @throws LevelIdNotFound If the supplied level id is not found. - * @throws IllegalArgumentException If the supplied {@code classifiedBy} is {@code null}, - * the empty string or a string consisting only of whitespace. - * @throws ReasonIdNotFound If any of the supplied reason ids are not found. - * @throws InvalidNodeRefException If the node could not be found. - * @throws InvalidNode If the supplied node is not a content node. - */ - void editClassifiedContent(ClassificationAspectProperties classificationAspectProperties, NodeRef content) - throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode; - - /** - * Checks if the node is classified or not. A node classified - * as "Unclassified" will be treated as not classified. - * - * @param nodeRef Node reference - * @return true if the node is classified, false otherwise - */ - boolean isClassified(NodeRef nodeRef); - - /** - * Indicates whether the currently authenticated user has clearance to see the - * provided node. - *

- * Note that users, regardless of their clearance level, are always cleared to see a node that has no classification - * applied. - * - * @param nodeRef node reference - * @return boolean true if cleared to see node, false otherwise - */ - boolean hasClearance(NodeRef nodeRef); -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java deleted file mode 100644 index 9123e6a800..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager.UNCLASSIFIED_ID; -import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank; -import static org.alfresco.util.ParameterCheck.mandatory; -import static org.apache.commons.lang3.StringUtils.isNotBlank; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.QuickShareModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -/** - * A service to handle the classification of content. - * - * @author tpage - * @since 2.4.a - */ -public class ContentClassificationServiceImpl extends ServiceBaseImpl - implements ContentClassificationService, ClassifiedContentModel -{ - private ClassificationLevelManager levelManager; - private ClassificationReasonManager reasonManager; - private SecurityClearanceService securityClearanceService; - private ClassificationServiceBootstrap classificationServiceBootstrap; - private FreezeService freezeService; - private ReferredMetadataService referredMetadataService; - - public void setLevelManager(ClassificationLevelManager levelManager) { this.levelManager = levelManager; } - public void setReasonManager(ClassificationReasonManager reasonManager) { this.reasonManager = reasonManager; } - public void setSecurityClearanceService(SecurityClearanceService securityClearanceService) { this.securityClearanceService = securityClearanceService; } - public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap) { this.classificationServiceBootstrap = classificationServiceBootstrap; } - public void setFreezeService(FreezeService service) { this.freezeService = service; } - public void setReferredMetadataService(ReferredMetadataService service) - { - this.referredMetadataService = service; - } - - public void init() - { - this.levelManager = classificationServiceBootstrap.getClassificationLevelManager(); - this.reasonManager = classificationServiceBootstrap.getClassificationReasonManager(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#getCurrentClassification(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public ClassificationLevel getCurrentClassification(final NodeRef nodeRef) - { - return AuthenticationUtil.runAsSystem(new RunAsWork() - { - public ClassificationLevel doWork() throws Exception - { - final String classificationId; - - if (nodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)) - { - classificationId = (String)nodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION); - } - else if (referredMetadataService.isReferringMetadata(nodeRef, ASPECT_CLASSIFIED)) - { - classificationId = (String) referredMetadataService.getReferredProperty(nodeRef, PROP_CURRENT_CLASSIFICATION); - // Note that this property value could be null/missing. - } - else - { - classificationId = null; - } - - // by default everything is unclassified - return classificationId == null ? ClassificationLevelManager.UNCLASSIFIED : levelManager.findLevelById(classificationId); - } - }); - }; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#classifyContent(ClassificationAspectProperties, NodeRef) - */ - @Override - public void classifyContent(ClassificationAspectProperties classificationAspectProperties, final NodeRef content) - { - validateProperties(classificationAspectProperties); - validateContent(content); - - final Map properties = createPropertiesMap(classificationAspectProperties, content); - - // Add aspect - authenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() - { - if (freezeService.isFrozen(content)) - { - throw new AccessDeniedException("Frozen nodes can not be classified."); - } - - nodeService.addAspect(content, ASPECT_CLASSIFIED, properties); - return null; - } - }); - } - - /** - * Validate the properties contained in the {@link ClassificationAspectProperties}. - * - * @param classificationAspectProperties The DTO containing properties to be stored on the aspect. - */ - protected void validateProperties(ClassificationAspectProperties classificationAspectProperties) - { - String classificationLevelId = classificationAspectProperties.getClassificationLevelId(); - checkNotBlank("classificationLevelId", classificationLevelId); - checkNotBlank("classifiedBy", classificationAspectProperties.getClassifiedBy()); - mandatory("classificationReasonIds", classificationAspectProperties.getClassificationReasonIds()); - - if (!securityClearanceService.isCurrentUserClearedForClassification(classificationLevelId)) - { - throw new LevelIdNotFound(classificationLevelId); - } - - for (String classificationReasonId : classificationAspectProperties.getClassificationReasonIds()) - { - // Check the classification reason id - an exception will be thrown if the id cannot be found - reasonManager.findReasonById(classificationReasonId); - } - } - - /** - * Check the node is suitable for classifying. - * - * @param content The node to be classified. - */ - protected void validateContent(NodeRef content) - { - mandatory("content", content); - - if (!dictionaryService.isSubClass(nodeService.getType(content), ContentModel.TYPE_CONTENT)) - { - throw new InvalidNode(content, "The supplied node is not a content node."); - } - if (nodeService.hasAspect(content, QuickShareModel.ASPECT_QSHARE)) - { - throw new IllegalStateException("A shared content cannot be classified."); - } - } - - /** - * Create a map suitable for storing against the aspect from the data transfer object. - * - * @param propertiesDTO The properties data transfer object. - * @param content The node to be classified. - * @return A map from {@link QName QNames} to values. - */ - protected Map createPropertiesMap( - ClassificationAspectProperties propertiesDTO, NodeRef content) - { - final Map propertiesMap = new HashMap<>(); - - if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null) - { - propertiesMap.put(PROP_INITIAL_CLASSIFICATION, propertiesDTO.getClassificationLevelId()); - } - propertiesMap.put(PROP_CURRENT_CLASSIFICATION, propertiesDTO.getClassificationLevelId()); - propertiesMap.put(PROP_CLASSIFICATION_AGENCY, propertiesDTO.getClassificationAgency()); - propertiesMap.put(PROP_CLASSIFIED_BY, propertiesDTO.getClassifiedBy()); - propertiesMap.put(PROP_CLASSIFICATION_REASONS, new HashSet<>(propertiesDTO.getClassificationReasonIds())); - propertiesMap.put(PROP_DOWNGRADE_DATE, propertiesDTO.getDowngradeDate()); - propertiesMap.put(PROP_DOWNGRADE_EVENT, propertiesDTO.getDowngradeEvent()); - propertiesMap.put(PROP_DOWNGRADE_INSTRUCTIONS, propertiesDTO.getDowngradeInstructions()); - propertiesMap.put(PROP_DECLASSIFICATION_DATE, propertiesDTO.getDeclassificationDate()); - propertiesMap.put(PROP_DECLASSIFICATION_EVENT, propertiesDTO.getDeclassificationEvent()); - propertiesMap.put(PROP_DECLASSIFICATION_EXEMPTIONS, new HashSet<>(propertiesDTO.getExemptionCategoryIds())); - - String lastReclassifyBy = propertiesDTO.getLastReclassifyBy(); - if (isNotBlank(lastReclassifyBy)) - { - propertiesMap.put(PROP_LAST_RECLASSIFY_BY, lastReclassifyBy); - } - - String lastReclassifyReason = propertiesDTO.getLastReclassifyReason(); - if (isNotBlank(lastReclassifyReason)) - { - propertiesMap.put(PROP_LAST_RECLASSIFY_REASON, lastReclassifyReason); - } - - return propertiesMap; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#hasClearance(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean hasClearance(NodeRef nodeRef) - { - boolean result = true; - if (nodeService.exists(nodeRef)) - { - // Get the node's current classification - ClassificationLevel currentClassification = getCurrentClassification(nodeRef); - result = securityClearanceService.isCurrentUserClearedForClassification(currentClassification.getId()); - } - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#isClassified(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public boolean isClassified(NodeRef nodeRef) - { - mandatory("nodeRef", nodeRef); - - boolean isClassified = false; - - final String currentClassification; - if (nodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)) - { - currentClassification = (String) nodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION); - isClassified = currentClassification != null && ! UNCLASSIFIED_ID.equals(currentClassification); - } - else if (referredMetadataService.isReferringMetadata(nodeRef, ASPECT_CLASSIFIED)) - { - currentClassification = (String) referredMetadataService.getReferredProperty(nodeRef, PROP_CURRENT_CLASSIFICATION); - // This could be a null/missing property. - - isClassified = currentClassification != null && ! UNCLASSIFIED_ID.equals(currentClassification); - } - - return isClassified; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#editClassifiedContent(ClassificationAspectProperties, NodeRef) - */ - @Override - public void editClassifiedContent(ClassificationAspectProperties classificationAspectProperties, NodeRef content) - throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode - { - classifyContent(classificationAspectProperties, content); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategory.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategory.java deleted file mode 100644 index 8e9de12674..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategory.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.apache.commons.lang.StringUtils.isNotBlank; - -import org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * This class is a POJO data type for an exemption category. It gives a reason why a piece of content should not be - * declassified. - * - * @author tpage - * @since 2.4.a - */ -public final class ExemptionCategory implements ClassificationSchemeEntity -{ - /** serial version uid */ - private static final long serialVersionUID = -8990809567320071986L; - - private final String id; - private final String displayLabelKey; - - public ExemptionCategory(final String id, final String displayLabelKey) - { - RMParameterCheck.checkNotBlank("id", id); - RMParameterCheck.checkNotBlank("displayLabelKey", displayLabelKey); - this.id = id; - this.displayLabelKey = displayLabelKey; - } - - /** Returns the unique identifier for this exemption category. */ - public String getId() { return this.id; } - - /** Returns the key for the display label. */ - public String getDisplayLabelKey() { return displayLabelKey; } - - /** - * Returns the localised (current locale) display label for this exemption category. If no translation is found then - * return the key instead. - */ - public String getDisplayLabel() - { - String message = I18NUtil.getMessage(displayLabelKey); - return (isNotBlank(message) ? message : displayLabelKey); - } - - @Override public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(ExemptionCategory.class.getSimpleName()) - .append(":").append(id); - - return msg.toString(); - } - - @Override public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ExemptionCategory that = (ExemptionCategory) o; - - return this.id.equals(that.id); - } - - @Override public int hashCode() { return id.hashCode(); } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryConstraint.java deleted file mode 100644 index e188d71804..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryConstraint.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.ArrayList; -import java.util.List; - -/** - * Check that a value is a valid {@link ExemptionCategory} by checking the {@link ClassificationSchemeService}. - * - * @author tpage - * @since 2.4.a - */ -public class ExemptionCategoryConstraint extends ClassificationSchemeEntityConstraint -{ - /** - * Get the allowed values. Note that these are String instances, but may - * represent non-String values. It is up to the caller to distinguish. - * - * @return Returns the values allowed - */ - @Override - protected List getAllowedValues() - { - List exemptionCategories = classificationSchemeService.getExemptionCategories(); - List values = new ArrayList(); - for (ExemptionCategory exemptionCategory : exemptionCategories) - { - values.add(exemptionCategory.getId()); - } - return values; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryManager.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryManager.java deleted file mode 100644 index 0a0da814cd..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryManager.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.Collection; - -import com.google.common.collect.ImmutableList; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound; - -/** - * Container for the configured {@link ExemptionCategory} objects. - * - * @author tpage - * @since 2.4.a - */ -public class ExemptionCategoryManager -{ - /** An immutable list of exemption categories. */ - private ImmutableList exemptionCategories; - - /** - * Store an immutable copy of the given categories. - * - * @param exemptionCategories The exemption categories. - */ - public void setExemptionCategories(Collection exemptionCategories) - { - this.exemptionCategories = ImmutableList.copyOf(exemptionCategories); - } - - /** @return An immutable list of exemption categories. */ - public ImmutableList getExemptionCategories() - { - return exemptionCategories; - } - - /** - * Get a ExemptionCategory using its id. - * - * @param id The id of an exemption category. - * @return The exemption category. - * @throws ExemptionCategoryIdNotFound If the exemption category cannot be found. - */ - public ExemptionCategory findCategoryById(String id) throws ExemptionCategoryIdNotFound - { - for (ExemptionCategory exemptionCategory : exemptionCategories) - { - if (exemptionCategory.getId().equals(id)) - { - return exemptionCategory; - } - } - throw new ExemptionCategoryIdNotFound(id); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/InitialClassificationLevelConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/InitialClassificationLevelConstraint.java deleted file mode 100644 index 82d0ea9d5f..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/InitialClassificationLevelConstraint.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.ArrayList; -import java.util.List; - -/** - * Check that a value is a valid initial {@link ClassificationLevel} by checking the {@link ClassificationSchemeService}. - * The initial classification level is allowed to be any level, regardless of the clearance of the current user. - * - * @author tpage - * @since 2.4.a - */ -public class InitialClassificationLevelConstraint extends ClassificationSchemeEntityConstraint -{ - /** - * Get the allowed values. Note that these are String instances, but may - * represent non-String values. It is up to the caller to distinguish. - * - * @return the values allowed. - */ - @Override - protected List getAllowedValues() - { - List classificationLevels = classificationSchemeService.getAllClassificationLevels(); - List values = new ArrayList(); - for (ClassificationLevel classificationLevel : classificationLevels) - { - values.add(classificationLevel.getId()); - } - return values; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ReclassificationValueConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ReclassificationValueConstraint.java deleted file mode 100644 index 3240527ad4..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ReclassificationValueConstraint.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static java.util.Collections.unmodifiableList; - -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - * Check that a {@link ClassifiedContentModel#PROP_LAST_RECLASSIFICATION_ACTION reclassifiction action }value is valid. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReclassificationValueConstraint extends ClassificationSchemeEntityConstraint -{ - @Override - protected List getAllowedValues() - { - final Set resultSet = classificationSchemeService.getReclassificationValues(); - List result = new ArrayList<>(resultSet.size()); - result.addAll(resultSet); - - return unmodifiableList(result); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearance.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearance.java deleted file mode 100644 index 5a7de03ec4..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearance.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.io.Serializable; -import java.util.Objects; - -import org.alfresco.service.cmr.security.PersonService.PersonInfo; - -/** - * A simple data type for a single user's security clearance. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public final class SecurityClearance implements Serializable -{ - /** Serial version uid */ - private static final long serialVersionUID = 8410664575120817707L; - - private final PersonInfo personInfo; - private final ClearanceLevel clearanceLevel; - - public SecurityClearance(final PersonInfo personInfo, final ClearanceLevel clearanceLevel) - { - // Do not check the PersonInfo, as it may be null for the system user's SecurityClearance. - Objects.requireNonNull(clearanceLevel); - - this.personInfo = personInfo; - this.clearanceLevel = clearanceLevel; - } - - /** Returns the {@link PersonInfo} for this security clearance. */ - public PersonInfo getPersonInfo() { return this.personInfo; } - - /** Returns the {@link ClearanceLevel} for this security clearance. */ - public ClearanceLevel getClearanceLevel() { return this.clearanceLevel; } - - @Override public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(SecurityClearance.class.getSimpleName()) - .append(':').append(personInfo.getUserName()) - .append(" [").append(clearanceLevel).append(']'); - - return msg.toString(); - } - - @Override public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SecurityClearance that = (SecurityClearance) o; - - return this.personInfo.equals(that.personInfo) && - this.clearanceLevel.equals(that.clearanceLevel); - } - - @Override public int hashCode() { return Objects.hash(personInfo, clearanceLevel); } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java deleted file mode 100644 index 005d540018..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import java.util.List; - -import org.alfresco.query.PagingResults; -import org.alfresco.service.cmr.security.NoSuchPersonException; - -/** - * This service offers access to users' security clearance levels. - * - * @author Neil Mc Erlean - * @author David Webster - * @since 2.4.a - */ -public interface SecurityClearanceService -{ - /** - * Get the currently authenticated user's security clearance. - * - * @return the security clearance for the currently authenticated user. - * @throws NoSuchPersonException if the current user's person node cannot be found. - */ - SecurityClearance getUserSecurityClearance(); - - /** - * Get users' security clearances. - * - * @param queryParams parameters for the query. - * @return security clearances for the specified page of users. - */ - PagingResults getUsersSecurityClearance(UserQueryParams queryParams); - - /** - * Check if a classification can be accessed by the current user. - * - * @param classificationId The classification level to look for. - * @return {@code true} if the user can access the classification level; {@code false} if the user doesn't have - * clearance, or the classification level doesn't exist. - */ - boolean isCurrentUserClearedForClassification(String classificationId); - - /** - * Set the clearance level for a user. - * - * @param userName The username of the user. - * @param clearanceId The identifier for the new clearance level. - * @return the user's security clearance - */ - SecurityClearance setUserSecurityClearance(String userName, String clearanceId); - - /** - * Returns an immutable list of the defined clearance levels. - * - * @return clearance levels in descending order from highest to lowest - * (where fewer users have access to the highest clearance levels - * and therefore access to the most restricted documents). - */ - List getClearanceLevels(); - - /** - * Checks if the current user has any clearance set - * - * @return true if the current user has a clearance set different than "No Clearance", false otherwise - */ - boolean hasCurrentUserClearance(); - - /** - * Checks if the user with the given id has any clearance set - * - * @param userId {@link String} The user id - * @return true if the user with the given id has a clearance set different than "No Clearance", false otherwise - */ - boolean hasUserClearance(String userId); -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java deleted file mode 100644 index 7720eac702..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevelManager.NO_CLEARANCE; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.ASPECT_SECURITY_CLEARANCE; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLEARANCE_LEVEL; -import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.security.PersonService.PersonInfo; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; - -/** - * @author Neil Mc Erlean - * @author David Webster - * @since 2.4.a - */ -public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements SecurityClearanceService -{ - /** The clearance levels currently configured in this server. */ - private ClearanceLevelManager clearanceManager; - /** The object containing the {@link ClassificationLevel}s in the system. */ - private ClassificationLevelManager classificationLevelManager; - private PersonService personService; - private ClassificationServiceBootstrap classificationServiceBootstrap; - private ClassificationLevelComparator classificationLevelComparator; - - public void setClearanceManager(ClearanceLevelManager clearanceManager) { this.clearanceManager = clearanceManager; } - public void setClassificationLevelManager(ClassificationLevelManager classificationLevelManager) { this.classificationLevelManager = classificationLevelManager; } - public void setPersonService(PersonService service) { this.personService = service; } - public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap) { this.classificationServiceBootstrap = classificationServiceBootstrap; } - public void setClassificationLevelComparator(ClassificationLevelComparator classificationLevelComparator) { this.classificationLevelComparator = classificationLevelComparator; } - - /** Store the references to the classification and clearance level managers in this class. */ - public void init() - { - this.classificationLevelManager = classificationServiceBootstrap.getClassificationLevelManager(); - this.clearanceManager = classificationServiceBootstrap.getClearanceLevelManager(); - - classificationLevelComparator = new ClassificationLevelComparator(classificationLevelManager); - } - - @Override - public SecurityClearance getUserSecurityClearance() - { - if (authenticationUtil.isRunAsUserTheSystemUser()) - { - return new SecurityClearance(null, clearanceManager.getMostSecureLevel()); - } - - final String currentUser = authenticationUtil.getRunAsUser(); - ParameterCheck.mandatoryString("currentUser", currentUser); - - return getUserSecurityClearance(currentUser); - } - - /** - * Gets the user's security clearance. - * - * @param userName user name - * @return {@link SecurityClearance} provides information about the user and their clearance level - */ - private SecurityClearance getUserSecurityClearance(final String userName) - { - final NodeRef personNode = personService.getPerson(userName, false); - final PersonInfo personInfo = personService.getPerson(personNode); - - ClearanceLevel clearanceLevel = ClearanceLevelManager.NO_CLEARANCE; - if (nodeService.hasAspect(personNode, ASPECT_SECURITY_CLEARANCE)) - { - final String clearanceLevelId = (String)nodeService.getProperty(personNode, PROP_CLEARANCE_LEVEL); - clearanceLevel = (clearanceLevelId == null ? ClearanceLevelManager.NO_CLEARANCE - : clearanceManager.findLevelByClassificationLevelId(clearanceLevelId)); - } - - return new SecurityClearance(personInfo, clearanceLevel); - } - - @Override - public PagingResults getUsersSecurityClearance(UserQueryParams queryParams) - { - final PagingRequest pagingRequest = new PagingRequest(queryParams.getSkipCount(), - queryParams.getMaxItems()); - // We want an accurate count of how many users there are in the system (in this query). - // Else paging in the UI won't work properly. - pagingRequest.setRequestTotalCountMax(Integer.MAX_VALUE); - - final PagingResults p = personService.getPeople(queryParams.getSearchTerm(), - queryParams.getFilterProps(), - queryParams.getSortProps(), - pagingRequest); - - return new PagingResults() - { - @Override public List getPage() - { - List pcPage= new ArrayList<>(p.getPage().size()); - for (PersonInfo pi : p.getPage()) - { - pcPage.add(getUserSecurityClearance(pi.getUserName())); - } - return pcPage; - } - - @Override public boolean hasMoreItems() { return p.hasMoreItems(); } - @Override public Pair getTotalResultCount() { return p.getTotalResultCount(); } - @Override public String getQueryExecutionId() { return p.getQueryExecutionId(); } - }; - } - - @Override - public boolean isCurrentUserClearedForClassification(String classificationId) - { - // Get the current user's security clearance. - SecurityClearance securityClearance = getUserSecurityClearance(); - - ClassificationLevel suppliedLevel; - try - { - suppliedLevel = classificationLevelManager.findLevelById(classificationId); - } - catch(LevelIdNotFound e) - { - // Return false to make "Level not found" indistinguishable from "Not cleared". - return false; - } - ClassificationLevel usersHighestLevel = securityClearance.getClearanceLevel().getHighestClassificationLevel(); - - int comparison = classificationLevelComparator.compare(usersHighestLevel, suppliedLevel); - return (comparison >= 0); - } - - @Override - public SecurityClearance setUserSecurityClearance(String userName, String clearanceId) - { - ParameterCheck.mandatoryString("userName", userName); - ParameterCheck.mandatoryString("clearanceId", clearanceId); - - final NodeRef personNode = personService.getPerson(userName, false); - - // Check the current user has clearance to see the specified level. - if (!isCurrentUserClearedForClassification(clearanceId)) - { - throw new LevelIdNotFound(clearanceId); - } - - nodeService.setProperty(personNode, PROP_CLEARANCE_LEVEL, clearanceId); - - return getUserSecurityClearance(userName); - } - - @Override - public List getClearanceLevels() - { - if (clearanceManager == null) - { - return Collections.emptyList(); - } - // FIXME Currently assume user has highest security clearance, this should be fixed as part of RM-2112. - ClearanceLevel usersLevel = clearanceManager.getMostSecureLevel(); - - return restrictList(clearanceManager.getClearanceLevels(), usersLevel); - } - - /** - * Create a list containing all clearance levels up to and including the supplied level. - * - * @param allLevels The list of all the clearance levels starting with the highest security. - * @param targetLevel The highest security clearance level that should be returned. If this is not found then - * an empty list will be returned. - * @return an immutable list of the levels that a user at the target level can see. - */ - private List restrictList(List allLevels, ClearanceLevel targetLevel) - { - int targetIndex = allLevels.indexOf(targetLevel); - if (targetIndex == -1) { return Collections.emptyList(); } - List subList = allLevels.subList(targetIndex, allLevels.size()); - return Collections.unmodifiableList(subList); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService#hasCurrentUserClearance() - */ - @Override - public boolean hasCurrentUserClearance() - { - return hasUserClearance(authenticationUtil.getRunAsUser()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService#hasUserClearance(java.lang.String) - */ - @Override - public boolean hasUserClearance(String userId) - { - checkNotBlank("userId", userId); - - boolean hasUserClearance = false; - - ClearanceLevel userCleranceLevel = getUserSecurityClearance(userId).getClearanceLevel(); - if (userCleranceLevel != null && userCleranceLevel != NO_CLEARANCE) - { - hasUserClearance = true; - } - - return hasUserClearance; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/UserQueryParams.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/UserQueryParams.java deleted file mode 100644 index ee5d1851b5..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/UserQueryParams.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static java.util.Arrays.asList; -import static org.alfresco.model.ContentModel.PROP_FIRSTNAME; -import static org.alfresco.model.ContentModel.PROP_LASTNAME; -import static org.alfresco.model.ContentModel.PROP_USERNAME; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; - -/** - * Configurable options to be used when querying for users by {@link SecurityClearance}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class UserQueryParams -{ - /** Required parameter. No default value. This is the username fragment. */ - private final String searchTerm; - - // These configurable parameters have default values. - private List filterProps = asList(PROP_USERNAME, PROP_FIRSTNAME, PROP_LASTNAME); - private List> sortProps = asList(new Pair<>(PROP_USERNAME, true)); - private int skipCount = 0; - private int maxItems = 10; - - /** - * Create a new object for searching for people. - * - * @param searchTerm The unescaped string to search for in the people service. - */ - public UserQueryParams(final String searchTerm) - { - ParameterCheck.mandatory("searchTerm", searchTerm); - // Escape backslashes before using in the query. (The person service does not do this for us) - this.searchTerm = searchTerm.replace("\\", "\\\\"); - } - - /** Sets the skip count required for the query. */ - public UserQueryParams withSkipCount(final int skipCount) - { - this.skipCount = skipCount; - return this; - } - - /** Sets the max items count required for the query. */ - public UserQueryParams withMaxItems(final int maxItems) - { - this.maxItems = maxItems; - return this; - } - - /** Sets the filter properties required for the query. */ - public UserQueryParams withFilterProps(QName firstFilterProp, QName... otherFilterProps) - { - this.filterProps = Collections.unmodifiableList(toList(firstFilterProp, otherFilterProps)); - return this; - } - - /** Sets the sort properties required for the query. */ - @SuppressWarnings("unchecked") - public UserQueryParams withSortProps(Pair firstSortProp, Pair... otherSortProps) - { - this.sortProps = Collections.unmodifiableList(toList(firstSortProp, otherSortProps)); - return this; - } - - /** - * Sets the sort properties required for the query. - * - * @param sortProps A list of pairs of properties and sort directions. - * @return The updated {@code UserQueryParams} object. - */ - public UserQueryParams withSortProps(List> sortProps) - { - this.sortProps = ImmutableList.copyOf(sortProps); - validateList(sortProps); - return this; - } - - public String getSearchTerm() { return this.searchTerm; } - public List getFilterProps() { return this.filterProps; } - public List> getSortProps() { return this.sortProps; } - public int getSkipCount() { return this.skipCount; } - public int getMaxItems() { return this.maxItems; } - - /** Helper method to turn a varargs into a List, ensuring at least one element is present. */ - @SuppressWarnings("unchecked") - private List toList(T firstElem, T... otherElems) - { - List elementList = new ArrayList<>(); - elementList.add(firstElem); - - if (otherElems != null) - { - elementList.addAll(asList(otherElems)); - } - - validateList(elementList); - - return elementList; - } - - /** Validate a list of elements to check none of them are null. */ - private void validateList(List elementList) - { - if (elementList.contains(null)) - { - throw new IllegalArgumentException("Unexpected null in parameter list: " + elementList); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java deleted file mode 100644 index cf02d739a0..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.model; - -import java.io.Serializable; - -import org.alfresco.service.namespace.QName; - -/** - * Classified content model interface. - *

- * Helper containing reusable information about the classified content model. - * - * @author Roy Wetherall - * @since 2.4.a - */ -public interface ClassifiedContentModel -{ - /** Namespace details */ - String CLF_URI = "http://www.alfresco.org/model/classifiedcontent/1.0"; - String CLF_PREFIX = "clf"; - - String CLASSIFICATION_LEVEL_CAVEAT = "classification"; - - Serializable[] LEVELS_KEY = new String[] { "org.alfresco", "module.org_alfresco_module_rm", "classification.levels" }; - Serializable[] REASONS_KEY = new String[] { "org.alfresco", "module.org_alfresco_module_rm", "classification.reasons" }; - Serializable[] EXEMPTION_CATEGORIES_KEY = new String[] { "org.alfresco", "module.org_alfresco_module_rm", "classification.exemptionCategories" }; - - /** Classified aspect */ - QName ASPECT_CLASSIFIED = QName.createQName(CLF_URI, "classified"); - QName PROP_INITIAL_CLASSIFICATION = QName.createQName(CLF_URI, "initialClassification"); - QName PROP_CURRENT_CLASSIFICATION = QName.createQName(CLF_URI, "currentClassification"); - QName PROP_CLASSIFICATION_AGENCY = QName.createQName(CLF_URI, "classificationAgency"); - QName PROP_CLASSIFIED_BY = QName.createQName(CLF_URI, "classifiedBy"); - QName PROP_CLASSIFICATION_REASONS = QName.createQName(CLF_URI, "classificationReasons"); - QName PROP_DOWNGRADE_DATE = QName.createQName(CLF_URI, "downgradeDate"); - QName PROP_DOWNGRADE_EVENT = QName.createQName(CLF_URI, "downgradeEvent"); - QName PROP_DOWNGRADE_INSTRUCTIONS = QName.createQName(CLF_URI, "downgradeInstructions"); - QName PROP_DECLASSIFICATION_DATE = QName.createQName(CLF_URI, "declassificationDate"); - QName PROP_DECLASSIFICATION_EVENT = QName.createQName(CLF_URI, "declassificationEvent"); - QName PROP_DECLASSIFICATION_EXEMPTIONS = QName.createQName(CLF_URI, "declassificationExemptions"); - - QName PROP_LAST_RECLASSIFY_BY = QName.createQName(CLF_URI, "lastReclassifyBy"); - QName PROP_LAST_RECLASSIFY_AT = QName.createQName(CLF_URI, "lastReclassifyAt"); - QName PROP_LAST_RECLASSIFY_REASON = QName.createQName(CLF_URI, "lastReclassifyReason"); - QName PROP_LAST_RECLASSIFICATION_ACTION = QName.createQName(CLF_URI, "lastReclassificationAction"); - - /** Security Clearance aspect. */ - QName ASPECT_SECURITY_CLEARANCE = QName.createQName(CLF_URI, "securityClearance"); - QName PROP_CLEARANCE_LEVEL = QName.createQName(CLF_URI, "clearanceLevel"); - - /** Classified Rendition aspect. */ - QName ASPECT_CLASSIFIED_RENDITION = QName.createQName(CLF_URI, "classifiedRendition"); - QName ASSOC_CLASSIFIED_RENDITION = QName.createQName(CLF_URI, "classifiedRendition"); -} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/package-info.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/package-info.java deleted file mode 100644 index cfc66c5fa3..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/package-info.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -/** - * This package contains the various types required for the 'Classified Records' feature. - * Nodes within Alfresco can be given a {@link org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel} - * which then restricts access to them to users having the appropriate clearance. - *

- * The {@link org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService} is responsible - * for the management of those levels and it is the - * {@link org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService} which deals - * wth users and their clearances. - * - * @since 2.4.a - */ -package org.alfresco.module.org_alfresco_module_rm.classification; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessor.java deleted file mode 100644 index 0427bdcf35..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessor.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.permission; - -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; -import org.alfresco.repo.security.permissions.processor.impl.PermissionPreProcessorBaseImpl; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.util.Triple; - -/** - * Classification permission pre-processor implementation. - * - * @author Roy Wetherall - * @since 2.4.a - */ -public class ClassificationPermissionPreProcessor extends PermissionPreProcessorBaseImpl -{ - /** transaction resource keys */ - /*package*/ static final String KEY_PROCESSING = ClassificationPermissionPreProcessor.class.getName() + ".processing"; - /*package*/ static final String KEY_CACHE = ClassificationPermissionPreProcessor.class.getName() + ".cache"; - - /** content classification service */ - private ContentClassificationService contentClassificationService; - - /** transaction resource helper */ - private TransactionalResourceHelper transactionalResourceHelper; - - /** classificaiton service bootstrap */ - private ClassificationServiceBootstrap classificationServiceBootstrap; - - /** authentication util */ - private AuthenticationUtil authenticationUtil; - - /** - * @param contentClassificationService content classification service - */ - public void setContentClassificationService(ContentClassificationService contentClassificationService) - { - this.contentClassificationService = contentClassificationService; - } - - /** - * @param transactionalResourceHelper transaction resource helper - */ - public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) - { - this.transactionalResourceHelper = transactionalResourceHelper; - } - - /** - * @param classificationServiceBootstrap classification service bootstrap - */ - public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap) - { - this.classificationServiceBootstrap = classificationServiceBootstrap; - } - - /** - * @param authenticationUtil authentication util - */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) - { - this.authenticationUtil = authenticationUtil; - } - - /** - * @see org.alfresco.repo.security.permissions.processor.PermissionPreProcessor#process(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - @Override - public AccessStatus process(NodeRef nodeRef, String perm) - { - AccessStatus result = AccessStatus.UNDETERMINED; - - // ensure the classification bootstrap has been initialised - if (classificationServiceBootstrap.isInitialised()) - { - // do not process a node that is already being processed - Set processing = transactionalResourceHelper.getSet(KEY_PROCESSING); - if (!processing.contains(nodeRef)) - { - processing.add(nodeRef); - try - { - // create key - final String currentUser = authenticationUtil.getRunAsUser(); - Triple key = new Triple(nodeRef, perm, currentUser); - - // get transaction cache (the purpose of this is prevent duplicate tests within the same transaction) - Map, AccessStatus> cache = transactionalResourceHelper.getMap(KEY_CACHE); - if (!cache.containsKey(key)) - { - // determine whether the current user has clearance for the node - if (!contentClassificationService.hasClearance(nodeRef)) - { - result = AccessStatus.DENIED; - } - - // cache value (in transaction) - cache.put(key, result); - } - else - { - result = cache.get(key); - } - } - finally - { - processing.remove(nodeRef); - } - } - } - - return result; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelFieldsValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelFieldsValidator.java deleted file mode 100644 index 913fa9c6a8..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelFieldsValidator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalAbbreviationChars; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; - -/** - * Validator for the fields in {@link ClassificationLevel}. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationLevelFieldsValidator implements EntityFieldsValidator -{ - /** The maximum number of characters allowed in a {@link ClassificationLevel#getId() level ID}. */ - private static final int ABBREVIATION_LENGTH_LIMIT = 10; - /** Validator for the length of the level abbreviation. */ - private FieldValidator lengthFieldValidator = new LengthFieldValidator(1, ABBREVIATION_LENGTH_LIMIT); - /** Validator for the characters in the level abbreviation. */ - private FieldValidator filenameFieldValidator = new FilenameFieldValidator(); - /** Validator that checks that the reserved symbol "U" is not configured as a classification level. */ - private FieldValidator classificationLevelIsNotUnclassifiedValidator = new ClassificationLevelIsNotUnclassifiedValidator(); - - /** - * Validates the provided {@link ClassificationLevel}. - * - * @param classificationLevel the level to validate. - * @throws MissingConfiguration if the level abbreviation is missing. - * @throws IllegalConfiguration if the level abbreviation violates the standard restrictions. - * @throws IllegalAbbreviationChars if the level abbreviation contains illegal characters. - */ - @Override - public void validate(ClassificationLevel classificationLevel) - { - final String levelId = classificationLevel.getId(); - - lengthFieldValidator.validate(levelId, "level abbreviation"); - filenameFieldValidator.validate(levelId, "level abbreviation"); - classificationLevelIsNotUnclassifiedValidator.validate(levelId, "level abbreviation"); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelIsNotUnclassifiedValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelIsNotUnclassifiedValidator.java deleted file mode 100644 index 0d24e2efe2..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelIsNotUnclassifiedValidator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager; - -/** - * A validator that checks that the reserved symbol "U" is not configured as a classification level. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationLevelIsNotUnclassifiedValidator implements FieldValidator -{ - @Override - public void validate(String levelId, String fieldName) throws ClassificationException - { - if (levelId.equals(ClassificationLevelManager.UNCLASSIFIED_ID)) - { - throw new IllegalConfiguration("The unclassified abbreviation '" + - ClassificationLevelManager.UNCLASSIFIED_ID + "' is reserved for system use."); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationReasonFieldsValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationReasonFieldsValidator.java deleted file mode 100644 index 2642c461c7..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationReasonFieldsValidator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReason; - -/** - * Validator for the fields in {@link ClassificationReason}. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationReasonFieldsValidator implements EntityFieldsValidator -{ - /** Validator for the length of the reason id and display key. */ - private FieldValidator lengthFieldValidator = new LengthFieldValidator(1); - /** Validator for the start characters in the reason id and display key. */ - private FieldValidator startCharacterFieldValidator = new StartCharacterFieldValidator(); - - /** - * Validates the given {@link ClassificationReason}. - * - * @param classificationReason the reason to validate. - * @throws MissingConfiguration if the reason is missing. - * @throws IllegalConfiguration if the reason configuration is invalid. - */ - @Override - public void validate(ClassificationReason classificationReason) - { - final String id = classificationReason.getId(); - lengthFieldValidator.validate(id, "reason id"); - startCharacterFieldValidator.validate(id, "reason id"); - - final String displayKey = classificationReason.getDisplayLabelKey(); - lengthFieldValidator.validate(displayKey, "reason display key"); - startCharacterFieldValidator.validate(displayKey, "reason display key"); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationSchemeEntityValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationSchemeEntityValidator.java deleted file mode 100644 index efba33688c..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationSchemeEntityValidator.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import static org.alfresco.module.org_alfresco_module_rm.util.RMCollectionUtils.getDuplicateElements; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeEntity; - -/** - * This class is responsible for validating configured data objects for use in the classification feature. - * - * @author Neil Mc Erlean - * @author tpage - * @since 2.4.a - */ -public class ClassificationSchemeEntityValidator -{ - private EntityFieldsValidator entityFieldsValidator; - - public ClassificationSchemeEntityValidator(EntityFieldsValidator entityFieldsValidator) - { - this.entityFieldsValidator = entityFieldsValidator; - } - - /** - * Validates the provided entities as a whole and individually. - * @param objects the entities to validate. - * @param entityName the simple name of the class to validate. - * @throws MissingConfiguration if the configuration is missing. - * @throws IllegalConfiguration if configuration is invalid. - */ - public void validate(List objects, String entityName) - { - if (objects == null || objects.isEmpty()) - { - throw new MissingConfiguration(entityName + " configuration is missing."); - } - - final List duplicateObjects= getDuplicateElements(objects); - if (!duplicateObjects.isEmpty()) - { - throw new IllegalConfiguration("Illegal " + entityName + " configuration - duplicate values are not allowed: " + duplicateObjects); - } - - for (T object : objects) - { - entityFieldsValidator.validate(object); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/EntityFieldsValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/EntityFieldsValidator.java deleted file mode 100644 index cea3b6948b..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/EntityFieldsValidator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeEntity; - -/** - * A validator for all the fields of a classification POJO. - * - * @author tpage - * @since 2.4.a - */ -public interface EntityFieldsValidator -{ - /** - * Validate the fields of the given POJO. - * - * @param pojo The object to validate. - */ - void validate(T pojo); -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ExemptionCategoryFieldsValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ExemptionCategoryFieldsValidator.java deleted file mode 100644 index 4a3aaaa586..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ExemptionCategoryFieldsValidator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory; - -/** - * Validator for the fields in {@link ExemptionCategory}. - * - * @author tpage - * @since 2.4.a - */ -public class ExemptionCategoryFieldsValidator implements EntityFieldsValidator -{ - /** Validator for the length of the category id and display key. */ - private FieldValidator lengthFieldValidator = new LengthFieldValidator(1); - /** Validator for the start characters in the category id and display key. */ - private FieldValidator startCharacterFieldValidator = new StartCharacterFieldValidator(); - - /** - * Validates the given {@link ExemptionCategory}. - * - * @param exemptionCategory the category to validate. - * @throws MissingConfiguration if the category is missing. - * @throws IllegalConfiguration if the category configuration is invalid. - */ - @Override - public void validate(ExemptionCategory exemptionCategory) - { - final String id = exemptionCategory.getId(); - lengthFieldValidator.validate(id, "exemption category id"); - startCharacterFieldValidator.validate(id, "exemption category id"); - - final String displayKey = exemptionCategory.getDisplayLabelKey(); - lengthFieldValidator.validate(displayKey, "exemption category display key"); - startCharacterFieldValidator.validate(displayKey, "exemption category display key"); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/FieldValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/FieldValidator.java deleted file mode 100644 index 2f446ceed8..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/FieldValidator.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; - -/** - * Validate a field. - * - * @author tpage - * @since 2.4.a - */ -public interface FieldValidator -{ - void validate(T field, String fieldName) throws ClassificationException; -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/FilenameFieldValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/FilenameFieldValidator.java deleted file mode 100644 index 096a9b15c2..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/FilenameFieldValidator.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import static java.util.Arrays.asList; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalAbbreviationChars; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; - -/** - * Check that a field is suitable to be used as part of a filename. - * - * @author tpage - * @since 2.4.a - */ -public class FilenameFieldValidator implements FieldValidator -{ - /** - * Illegal characters in a {@link ClassificationLevel#getId() level ID}. - * Equals to Alfresco's disallowed filename characters. - */ - // See in contentModel.xml - static final List ILLEGAL_ABBREVIATION_CHARS = asList('"', '*', '\\', '>', '<', '?', '/', ':', '|'); - - private List getIllegalAbbreviationChars(String s) - { - final List result = new ArrayList<>(); - for (Character c : ILLEGAL_ABBREVIATION_CHARS) - { - if (s.contains(c.toString())) result.add(c); - } - return result; - } - - @Override - public void validate(String field, String fieldName) throws ClassificationException - { - List illegalAbbreviationChars = getIllegalAbbreviationChars(field); - if (!illegalAbbreviationChars.isEmpty()) - { - throw new IllegalAbbreviationChars("Illegal character(s) in " + fieldName, illegalAbbreviationChars); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/LengthFieldValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/LengthFieldValidator.java deleted file mode 100644 index b20f7d7c03..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/LengthFieldValidator.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; - -/** - * Validate the length of a field. - * - * @author tpage - * @since 2.4.a - */ -public class LengthFieldValidator implements FieldValidator -{ - /** The minimum allowed length for the field. */ - private int minimumLength; - /** The maximum allowed length for the field, or {@code null} if there is no maximum length. */ - private Integer maximumLength = null; - - /** - * Create a validator that only checks the minimum length. - * - * @param minimumLength The length of the shortest allowable field. - */ - public LengthFieldValidator(int minimumLength) - { - this.minimumLength = minimumLength; - } - - /** - * Create a validator that checks the minimum and maximum length. - * - * @param minimumLength The length of the shortest allowable field. - * @param maximumLength The length of the longest allowable field. - */ - public LengthFieldValidator(int minimumLength, int maximumLength) - { - if (minimumLength > maximumLength) - { - throw new IllegalArgumentException("The minimum length may not be larger than the maximum length."); - } - - this.minimumLength = minimumLength; - this.maximumLength = maximumLength; - } - - @Override - public void validate(String field, String fieldName) throws ClassificationException - { - if (field == null || (field.length() == 0 && minimumLength > 0)) - { - throw new MissingConfiguration(fieldName + " is missing."); - } - else if (field.length() < minimumLength) - { - throw new IllegalConfiguration("Illegal " + fieldName + ": Length " + field.length() + " < " + minimumLength); - } - else if (maximumLength != null && field.length() > maximumLength) - { - throw new IllegalConfiguration("Illegal " + fieldName + ": Length " + field.length() + " > " + maximumLength); - } - } - -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/StartCharacterFieldValidator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/StartCharacterFieldValidator.java deleted file mode 100644 index 3be5429e07..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/StartCharacterFieldValidator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.apache.commons.lang3.StringUtils; - -/** - * Validator that fails if the first character of a field is non-alphanumeric. - * - * @author tpage - * @since 2.4.a - */ -public class StartCharacterFieldValidator implements FieldValidator -{ - @Override - public void validate(String field, String fieldName) throws ClassificationException - { - if (field == null || field.length() == 0) - { - // If the first character doesn't exist then don't fail. - return; - } - if (!StringUtils.isAlphanumeric(field.substring(0, 1))) - { - throw new IllegalConfiguration("Illegal " + fieldName + ": First character of '" + field + "' is not alphanumeric."); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java index 714595005e..ee60e787ad 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java @@ -24,15 +24,8 @@ import java.util.Set; import org.alfresco.model.ContentModel; import org.alfresco.model.RenditionModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; @@ -42,66 +35,68 @@ import org.alfresco.service.namespace.QName; /** * Content destruction component. - *

- * Listens for the destruction of sensitive nodes (classified content and records) and schedules - * all their content for immediate destruction. - *

- * If enabled, the content is also cleansed before destruction. - * + * * @author Roy Wetherall * @since 2.4.a */ @BehaviourBean -public class ContentDestructionComponent implements NodeServicePolicies.BeforeDeleteNodePolicy +public class ContentDestructionComponent { - /** authentication utils */ - private AuthenticationUtil authenticationUtil; - - /** content classification service */ - private ContentClassificationService contentClassificationService; - - /** record service */ - private RecordService recordService; - /** eager content store cleaner */ private EagerContentStoreCleaner eagerContentStoreCleaner; - + /** dictionary service */ private DictionaryService dictionaryService; - + /** node service */ private NodeService nodeService; - + /** behaviour filter */ private BehaviourFilter behaviourFilter; - + /** indicates whether cleansing is enabled or not */ private boolean cleansingEnabled = false; - + /** - * @param authenticationUtil authentication utils + * @return the eagerContentStoreCleaner */ - public void setAuthenticationUtil(AuthenticationUtil authenticationUtil) + protected EagerContentStoreCleaner getEagerContentStoreCleaner() { - this.authenticationUtil = authenticationUtil; + return this.eagerContentStoreCleaner; } - + /** - * @param contentClassificationService content classification service + * @return the dictionaryService */ - public void setContentClassificationService(ContentClassificationService contentClassificationService) + protected DictionaryService getDictionaryService() { - this.contentClassificationService = contentClassificationService; + return this.dictionaryService; } - + /** - * @param recordService record service + * @return the nodeService */ - public void setRecordService(RecordService recordService) + protected NodeService getNodeService() { - this.recordService = recordService; + return this.nodeService; } - + + /** + * @return the behaviourFilter + */ + protected BehaviourFilter getBehaviourFilter() + { + return this.behaviourFilter; + } + + /** + * @return true if cleansing is enabled, false otherwise + */ + public boolean isCleansingEnabled() + { + return cleansingEnabled; + } + /** * @param eagerContentStoreCleaner eager content store cleaner */ @@ -109,7 +104,7 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe { this.eagerContentStoreCleaner = eagerContentStoreCleaner; } - + /** * @param dictionaryService dictionary service */ @@ -125,15 +120,7 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe { this.nodeService = nodeService; } - - /** - * @param cleansingEnabled true if cleansing enabled, false otherwise - */ - public void setCleansingEnabled(boolean cleansingEnabled) - { - this.cleansingEnabled = cleansingEnabled; - } - + /** * @param behaviourFilter behaviour filter */ @@ -141,62 +128,28 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe { this.behaviourFilter = behaviourFilter; } - + /** - * @return true if cleansing is enabled, false otherwise + * @param cleansingEnabled true if cleansing enabled, false otherwise */ - public boolean isCleansingEnabled() + public void setCleansingEnabled(boolean cleansingEnabled) { - return cleansingEnabled; + this.cleansingEnabled = cleansingEnabled; } - - /** - * System behaviour implementation that listens for sensitive nodes - * and schedules them for immediate destruction. - *

- * Note that the content destruction and cleansing takes place on transaction - * commit. If the transaction is rolled back after this behaviour is encountered - * then the content will not be destroyed or cleansed. - * - * @param nodeRef node reference about to be deleted - */ - @Override - @Behaviour - ( - isService = true, - kind = BehaviourKind.CLASS - ) - public void beforeDeleteNode(final NodeRef nodeRef) - { - authenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() throws Exception - { - // if enable and content is classified or a record - if (contentClassificationService.isClassified(nodeRef) || - recordService.isRecord(nodeRef)) - { - // then register all content for destruction - registerAllContentForDestruction(nodeRef, false); - } - return null; - } - }); - } - + /** * Destroy content - * + * * @param nodeRef */ public void destroyContent(NodeRef nodeRef) { destroyContent(nodeRef, true); } - + /** * Destroy content - * + * * @param nodeRef * @param includeRenditions */ @@ -205,7 +158,7 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe { // destroy the nodes content properties registerAllContentForDestruction(nodeRef, true); - + // Remove the renditioned aspect (and its properties and associations) if it is present. // // From Alfresco 3.3 it is the rn:renditioned aspect which defines the @@ -215,12 +168,12 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe // We want to remove the rn:renditioned aspect, but due to the possibility // that there is Alfresco 3.2-era data with the cm:thumbnailed aspect // applied, we must consider removing it too. - if (nodeService.hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || - nodeService.hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) + if (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || + getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) { // get the rendition assoc types Set childAssocTypes = dictionaryService.getAspect(RenditionModel.ASPECT_RENDITIONED).getChildAssociations().keySet(); - for (ChildAssociationRef child : nodeService.getChildAssocs(nodeRef)) + for (ChildAssociationRef child : getNodeService().getChildAssocs(nodeRef)) { if (childAssocTypes.contains(child.getTypeQName())) { @@ -230,36 +183,36 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe } } } - + /** * Registers all content on the given node for destruction. - * + * * @param nodeRef node reference * @param clearContentProperty if true then clear content property, otherwise false */ - private void registerAllContentForDestruction(NodeRef nodeRef, boolean clearContentProperty) + protected void registerAllContentForDestruction(NodeRef nodeRef, boolean clearContentProperty) { - Map properties = nodeService.getProperties(nodeRef); - + Map properties = getNodeService().getProperties(nodeRef); + for (Map.Entry entry : properties.entrySet()) { if (entry.getValue() instanceof ContentData) { // get content data ContentData dataContent = (ContentData)entry.getValue(); - - // if enabled cleanse content + + // if enabled cleanse content if (isCleansingEnabled()) { // register for cleanse then immediate destruction - eagerContentStoreCleaner.registerOrphanedContentUrlForCleansing(dataContent.getContentUrl()); + getEagerContentStoreCleaner().registerOrphanedContentUrlForCleansing(dataContent.getContentUrl()); } else { // register for immediate destruction - eagerContentStoreCleaner.registerOrphanedContentUrl(dataContent.getContentUrl(), true); + getEagerContentStoreCleaner().registerOrphanedContentUrl(dataContent.getContentUrl(), true); } - + // clear the property if (clearContentProperty) { @@ -267,7 +220,7 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe behaviourFilter.disableBehaviour(); try { - nodeService.removeProperty(nodeRef, entry.getKey()); + getNodeService().removeProperty(nodeRef, entry.getKey()); } finally { @@ -275,6 +228,6 @@ public class ContentDestructionComponent implements NodeServicePolicies.BeforeDe } } } - } + } } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java index ec0a83b3d2..b7a0cab128 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java @@ -19,18 +19,13 @@ package org.alfresco.module.org_alfresco_module_rm.forms; import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAsSystem; -import static org.apache.commons.lang.StringUtils.isNotBlank; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.model.ContentModel; import org.alfresco.model.ImapModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl; @@ -75,10 +70,6 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter protected static final String TRANSIENT_DECLARED = "rmDeclared"; protected static final String TRANSIENT_CATEGORY_ID = "rmCategoryIdentifier"; protected static final String TRANSIENT_DISPOSITION_INSTRUCTIONS = "rmDispositionInstructions"; - protected static final String TRANSIENT_CURRENT_CLASSIFICATION = "clfCurrentClassification"; - protected static final String TRANSIENT_INITIAL_CLASSIFICATION = "clfInitialClassification"; - protected static final String TRANSIENT_CLASSIFICATION_REASON_LABELS = "clfClassificationReasonLabels"; - protected static final String TRANSIENT_DECLASSIFICATION_EXEMPTIONS = "clfDeclassificationExemptions"; /** Disposition service */ private DispositionService dispositionService; @@ -86,9 +77,6 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter /** File Plan Service */ private FilePlanService filePlanService; - /** Classification Scheme Service */ - private ClassificationSchemeService classificationSchemeService; - /** * Returns the disposition service * @@ -109,16 +97,6 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter return this.filePlanService; } - /** - * Returns the classification scheme service - * - * @return Classification scheme service - */ - protected ClassificationSchemeService getClassificationSchemeService() - { - return this.classificationSchemeService; - } - /** * Sets the disposition service * @@ -137,14 +115,6 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter this.filePlanService = filePlanService; } - /** - * @param classificationSchemeService classification scheme service - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - /** * @see org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, java.util.List, java.util.List, org.alfresco.repo.forms.Form, java.util.Map) */ @@ -202,53 +172,6 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter } } } - - if (dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT)) - { - String initialClassificationId = (String) nodeService.getProperty(nodeRef, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION); - if (isNotBlank(initialClassificationId)) - { - String initialClassificationDisplayLabel = getClassificationSchemeService().getClassificationLevelById(initialClassificationId).getDisplayLabel(); - addTransientPropertyField(form, TRANSIENT_INITIAL_CLASSIFICATION, DataTypeDefinition.TEXT, initialClassificationDisplayLabel); - } - - String currentClassificationId = (String) nodeService.getProperty(nodeRef, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION); - if (isNotBlank(currentClassificationId)) - { - String currentClassificationDisplayLabel = getClassificationSchemeService().getClassificationLevelById(currentClassificationId).getDisplayLabel(); - addTransientPropertyField(form, TRANSIENT_CURRENT_CLASSIFICATION, DataTypeDefinition.TEXT, currentClassificationDisplayLabel); - } - - @SuppressWarnings("unchecked") - List classificationReasons = (List) nodeService.getProperty(nodeRef, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS); - if (classificationReasons != null && !classificationReasons.isEmpty()) - { - List classificationReasonLabels = new ArrayList<>(); - int size = classificationReasons.size(); - for (int i = 0; i < size; i++) - { - String id = classificationReasons.get(i); - String displayLabel = getClassificationSchemeService().getClassificationReasonById(id).getDisplayLabel(); - classificationReasonLabels.add(id + ": " + displayLabel + (i < size - 1 ? "|": "")); - } - addTransientPropertyField(form, TRANSIENT_CLASSIFICATION_REASON_LABELS, DataTypeDefinition.TEXT, classificationReasonLabels); - } - - @SuppressWarnings("unchecked") - List declassificationExemptions = (List) nodeService.getProperty(nodeRef, ClassifiedContentModel.PROP_DECLASSIFICATION_EXEMPTIONS); - if (declassificationExemptions != null && !declassificationExemptions.isEmpty()) - { - List declassificationExemptionLabels = new ArrayList<>(); - int size = declassificationExemptions.size(); - for (int i = 0; i < size; i++) - { - String id = declassificationExemptions.get(i); - String displayLabel = getClassificationSchemeService().getExemptionCategoryById(id).getDisplayLabel(); - declassificationExemptionLabels.add(id + ": " + displayLabel + (i < size - 1 ? "|": "")); - } - addTransientPropertyField(form, TRANSIENT_DECLASSIFICATION_EXEMPTIONS, DataTypeDefinition.TEXT, declassificationExemptionLabels); - } - } } /** diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 867bf3f606..26af812421 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -29,8 +29,6 @@ import java.util.Map; import org.alfresco.model.ContentModel; 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.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; @@ -70,8 +68,6 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS private static final String IS_RM_SITE_CREATED = "isRmSiteCreated"; private static final String IS_RECORD_CONTRIBUTOR_GROUP_ENABLED = "isRecordContributorGroupEnabled"; private static final String RECORD_CONTRIBUTOR_GROUP_NAME = "recordContributorGroupName"; - public static final String IS_CLASSIFIED = "isClassified"; - private static final String HAS_CURRENT_USER_CLEARANCE = "hasCurrentUserClearance"; /** true if record contributor group is enabled, false otherwise */ private boolean isRecordContributorsGroupEnabled = false; @@ -94,12 +90,6 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS /** site service */ private SiteService siteService; - /** Content classification service */ - private ContentClassificationService contentClassificationService; - - /** Security clearance service */ - private SecurityClearanceService securityClearanceService; - /** Indicators */ private List indicators = new ArrayList(); @@ -171,22 +161,6 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS this.siteService = siteService; } - /** - * @param contentClassificationService the contentClassificationService to set - */ - public void setContentClassificationService(ContentClassificationService contentClassificationService) - { - this.contentClassificationService = contentClassificationService; - } - - /** - * @param securityClearanceService the securityClearanceService to set - */ - public void setSecurityClearanceService(SecurityClearanceService securityClearanceService) - { - this.securityClearanceService = securityClearanceService; - } - /** * @param indicator registered indicator */ @@ -270,12 +244,6 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS // Get the node reference for convenience NodeRef nodeRef = nodeInfo.getNodeRef(); - // Is the node classified - rootJSONObject.put(IS_CLASSIFIED, contentClassificationService.isClassified(nodeRef)); - - // Has current user clearance - rootJSONObject.put(HAS_CURRENT_USER_CLEARANCE, securityClearanceService.hasCurrentUserClearance()); - if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, ViewRecordsCapability.NAME))) { // Indicate whether the node is a RM object or not diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/ClassifiedRenditions.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/ClassifiedRenditions.java deleted file mode 100644 index aec6c61e4b..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/ClassifiedRenditions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.model.clf; - -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.service.cmr.rendition.RenditionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Behaviour bean for classified rendition nodes. - * - * @since 2.4.a - */ -@BehaviourBean -( - defaultType = "rn:rendition" -) -public class ClassifiedRenditions extends BaseBehaviourBean - implements NodeServicePolicies.OnAddAspectPolicy, - ClassifiedContentModel -{ - private ContentClassificationService contentClassificationService; - private ReferralAdminService referralAdminService; - private RenditionService renditionService; - - public void setContentClassificationService(ContentClassificationService service) - { - this.contentClassificationService = service; - } - - public void setReferralAdminService(ReferralAdminService service) - { - this.referralAdminService = service; - } - - public void setRenditionService(RenditionService service) - { - this.renditionService = service; - } - - /** - * Behaviour associated with creating a rendition of an already classified node. - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.EVERY_EVENT - ) - public void onAddAspect(final NodeRef renditionNodeRef, final QName aspectTypeQName) - { - // When a rendition is created, set up a metadata link of its classification to the source node. - authenticationUtil.runAs(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() - { - public Void doWork() - { - final ChildAssociationRef chAssRef = renditionService.getSourceNode(renditionNodeRef); - final NodeRef sourceNode = chAssRef.getParentRef(); - if (contentClassificationService.isClassified(sourceNode) && - referralAdminService.getAttachedReferralFrom(renditionNodeRef, ASPECT_CLASSIFIED) != null) - { - referralAdminService.attachReferrer(renditionNodeRef, sourceNode, ASPECT_CLASSIFIED); - } - - return null; - } - }, authenticationUtil.getSystemUserName()); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java deleted file mode 100644 index de13b25b65..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.model.clf.aspect; - -import static org.alfresco.module.org_alfresco_module_rm.util.RMCollectionUtils.diffKey; -import static org.apache.commons.lang3.StringUtils.isBlank; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingDowngradeInstructions; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.Reclassification; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService; -import org.alfresco.module.org_alfresco_module_rm.util.RMCollectionUtils.Difference; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.annotation.Behaviour; -import org.alfresco.repo.policy.annotation.BehaviourBean; -import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.rendition.RenditionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * clf:classification behaviour bean - * - * @since 2.4.a - */ -@BehaviourBean -( - defaultType = "clf:classified" -) -public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePolicies.OnUpdatePropertiesPolicy, - NodeServicePolicies.OnAddAspectPolicy, - NodeServicePolicies.OnRemoveAspectPolicy, - ClassifiedContentModel -{ - private ClassificationSchemeService classificationSchemeService; - private ReferralAdminService referralAdminService; - private RenditionService renditionService; - - public void setClassificationSchemeService(ClassificationSchemeService service) - { - this.classificationSchemeService = service; - } - - public void setReferralAdminService(ReferralAdminService service) - { - this.referralAdminService = service; - } - - public void setRenditionService(RenditionService service) - { - this.renditionService = service; - } - - /** - * Behaviour associated with updating the classified aspect properties. - *

- * Validates the consistency of the properties. - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.EVERY_EVENT - ) - public void onUpdateProperties(final NodeRef classifiedNode, - final Map before, - final Map after) - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - final Difference classificationChange = diffKey(before, after, PROP_CURRENT_CLASSIFICATION); - - if (classificationChange == Difference.CHANGED && nodeService.hasAspect(classifiedNode, ASPECT_CLASSIFIED)) - { - final String oldValue = (String)before.get(PROP_CURRENT_CLASSIFICATION); - final String newValue = (String)after.get(PROP_CURRENT_CLASSIFICATION); - - final ClassificationLevel oldLevel = classificationSchemeService.getClassificationLevelById(oldValue); - final ClassificationLevel newLevel = classificationSchemeService.getClassificationLevelById(newValue); - - Reclassification reclassification = classificationSchemeService.getReclassification(oldLevel, newLevel); - - if (reclassification != null) - { - nodeService.setProperty(classifiedNode, PROP_LAST_RECLASSIFICATION_ACTION, reclassification.toModelString()); - nodeService.setProperty(classifiedNode, PROP_LAST_RECLASSIFY_AT, new Date()); - } - } - - checkConsistencyOfProperties(classifiedNode); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Behaviour associated with adding the classified aspect. - *

- * Validates the consistency of the properties. - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onAddAspect(final NodeRef classifiedNode, final QName aspectTypeQName) - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - checkConsistencyOfProperties(classifiedNode); - - // If this node has any renditions, we must ensure that they inherit the classification - // from their source node. - final List renditions = renditionService.getRenditions(classifiedNode); - for (ChildAssociationRef chAssRef : renditions) - { - final NodeRef renditionNode = chAssRef.getChildRef(); - if (referralAdminService.getAttachedReferralFrom(renditionNode, ASPECT_CLASSIFIED) == null) - { - referralAdminService.attachReferrer(renditionNode, classifiedNode, ASPECT_CLASSIFIED); - } - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Behaviour associated with removing the classified aspect. - *

- * Validates the consistency of the properties. - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT - ) - public void onRemoveAspect(final NodeRef classifiedNode, final QName aspectTypeQName) - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - // If this node has any renditions, we should remove the metadata link - final List renditions = renditionService.getRenditions(classifiedNode); - for (ChildAssociationRef chAssRef : renditions) - { - // In RM, renditions are only attached to one metadata referent - the source node. - // Therefore it is safe to (and we must) remove the aspect from the rendition node. - nodeService.removeAspect(chAssRef.getChildRef(), ASPECT_CLASSIFIED_RENDITION); - } - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Check the consistency of the classification properties and throw an exception if they are invalid. - * - * @param nodeRef The classified node. - */ - protected void checkConsistencyOfProperties(NodeRef nodeRef) throws MissingDowngradeInstructions - { - if (nodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)) - { - Serializable downgradeDate = nodeService.getProperty(nodeRef, PROP_DOWNGRADE_DATE); - Serializable downgradeEvent = nodeService.getProperty(nodeRef, PROP_DOWNGRADE_EVENT); - Serializable downgradeInstructions = nodeService.getProperty(nodeRef, PROP_DOWNGRADE_INSTRUCTIONS); - if (isEmpty(downgradeInstructions) && !(isEmpty(downgradeDate) && isEmpty(downgradeEvent))) - { - throw new MissingDowngradeInstructions(nodeRef); - } - } - } - - /** - * Check if a property is null or the empty string. Note that this is the same as - * {@link org.apache.commons.lang.StringUtils#isEmpty(String)}, except that it takes a Serializable rather than a - * String. This avoids awkward casting exceptions when working with properties. - * - * @param value The (probably String) value to check. - * @return true if the supplied value is null or the empty string. - */ - private boolean isEmpty(Serializable value) - { - boolean isEmpty; - - if (value instanceof String) - { - isEmpty = isBlank((String) value); - } - else - { - isEmpty = (value == null || value.equals("")); - } - - return isEmpty; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24ClearanceForAdmin.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24ClearanceForAdmin.java deleted file mode 100644 index 4303f01bf8..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24ClearanceForAdmin.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.patch.v24; - -import org.alfresco.module.org_alfresco_module_rm.bootstrap.ClearanceForAdminBootstrapComponent; -import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; - -/** - * Patch to provide the highest clearance to the admin user. - * - * @author tpage - */ -public class RMv24ClearanceForAdmin extends AbstractModulePatch -{ - private ClearanceForAdminBootstrapComponent bootstrapComponent; - - public void setBootstrapComponent(ClearanceForAdminBootstrapComponent bootstrapComponent) - { - this.bootstrapComponent = bootstrapComponent; - } - - /** - * Give the admin user the maximum clearance. - * - * @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal() - */ - @Override - public void applyInternal() - { - bootstrapComponent.createClearanceForAdmin(); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index 6226aded14..dbccfd6eec 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -18,6 +18,7 @@ */ package org.alfresco.module.org_alfresco_module_rm.record; +import static com.google.common.collect.Lists.newArrayList; import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_VERSIONED_NODEREF; import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_VERSION_LABEL; import static org.apache.commons.lang.StringUtils.isNotBlank; @@ -43,7 +44,6 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFi 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.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; @@ -146,18 +146,19 @@ public class RecordServiceImpl extends BaseBehaviourBean }; /** always edit model URI's */ - private static final String[] ALWAYS_EDIT_URIS = new String[] + protected List getAlwaysEditURIs() { - NamespaceService.SECURITY_MODEL_1_0_URI, - NamespaceService.SYSTEM_MODEL_1_0_URI, - NamespaceService.WORKFLOW_MODEL_1_0_URI, - NamespaceService.APP_MODEL_1_0_URI, - NamespaceService.DATALIST_MODEL_1_0_URI, - NamespaceService.DICTIONARY_MODEL_1_0_URI, - NamespaceService.BPM_MODEL_1_0_URI, - NamespaceService.RENDITION_MODEL_1_0_URI, - ClassifiedContentModel.CLF_URI - }; + return newArrayList( + NamespaceService.SECURITY_MODEL_1_0_URI, + NamespaceService.SYSTEM_MODEL_1_0_URI, + NamespaceService.WORKFLOW_MODEL_1_0_URI, + NamespaceService.APP_MODEL_1_0_URI, + NamespaceService.DATALIST_MODEL_1_0_URI, + NamespaceService.DICTIONARY_MODEL_1_0_URI, + NamespaceService.BPM_MODEL_1_0_URI, + NamespaceService.RENDITION_MODEL_1_0_URI + ); + } /** record model URI's */ public static final List RECORD_MODEL_URIS = Collections.unmodifiableList( @@ -166,7 +167,7 @@ public class RecordServiceImpl extends BaseBehaviourBean RM_CUSTOM_URI, ReportModel.RMR_URI, RecordableVersionModel.RMV_URI, - DOD5015Model.DOD_URI + DOD5015Model.DOD_URI )); /** non-record model URI's */ @@ -602,7 +603,11 @@ public class RecordServiceImpl extends BaseBehaviourBean @Override public void disablePropertyEditableCheck() { - getBehaviour("onUpdateProperties").disable(); + org.alfresco.repo.policy.Behaviour behaviour = getBehaviour("onUpdateProperties"); + if (behaviour != null) + { + getBehaviour("onUpdateProperties").disable(); + } } /** @@ -620,7 +625,11 @@ public class RecordServiceImpl extends BaseBehaviourBean @Override public void enablePropertyEditableCheck() { - getBehaviour("onUpdateProperties").enable(); + org.alfresco.repo.policy.Behaviour behaviour = getBehaviour("onUpdateProperties"); + if (behaviour != null) + { + behaviour.enable(); + } } /** @@ -1259,7 +1268,7 @@ public class RecordServiceImpl extends BaseBehaviourBean { result = AuthenticationUtil.runAsSystem(new RunAsWork() { - public Boolean doWork() throws Exception + public Boolean doWork() throws Exception { return (null != nodeService.getProperty(nodeRef, PROP_DATE_FILED)); } @@ -1640,7 +1649,7 @@ public class RecordServiceImpl extends BaseBehaviourBean */ private boolean alwaysEditProperty(QName property) { - return (ArrayUtils.contains(ALWAYS_EDIT_URIS, property.getNamespaceURI()) || + return (getAlwaysEditURIs().contains(property.getNamespaceURI()) || ArrayUtils.contains(ALWAYS_EDIT_PROPERTIES, property) || isProtectedProperty(property)); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/MetadataReferral.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/MetadataReferral.java deleted file mode 100644 index 2b739e6a23..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/MetadataReferral.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.InvalidMetadataReferral; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.namespace.QName; - -import java.util.Collections; -import java.util.Objects; -import java.util.Set; - -/** - * A {@link MetadataReferral} is a definition of a {@link #aspects set of metadata} which are, in effect, shared - * between multiple nodes. - * Using a {@link MetadataReferral}, you can link two NodeRefs such that {@code hasAspect} and - * {@code getPropert[y|ies]} calls on one node can can be delegated to the other. In this way a defined set of - * metadata on one node can be made available for read access via another node. - *

- * The connection between the nodes is made with a specified {@link #assocType peer association}. - *

- * Note that a {@link MetadataReferral} is not an instance of a link between two nodes, but the definition of such a link. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class MetadataReferral -{ - private DictionaryService dictionaryService; - private ReferralRegistry referralRegistry; - private Set aspects; - private QName assocType; - - public MetadataReferral() - { - // Intentionally empty. - } - - public void setDictionaryService(DictionaryService service) - { - this.dictionaryService = service; - } - - public void setReferralRegistry(ReferralRegistry registry) - { - this.referralRegistry = registry; - } - - public void setAssocType(QName assocType) - { - this.assocType = assocType; - } - - public void setAspects(Set aspects) - { - this.aspects = aspects; - } - - public void validateAndRegister() - { - if (this.assocType == null) - { - throw new InvalidMetadataReferral("Illegal null assocType"); - } - if (aspects == null || aspects.isEmpty()) - { - throw new InvalidMetadataReferral("Illegal null or empty aspects set"); - } - if (dictionaryService.getAssociation(assocType) == null) - { - throw new InvalidMetadataReferral("Association not found: " + assocType); - } - for (QName aspect : aspects) - { - if (dictionaryService.getAspect(aspect) == null) - { - throw new InvalidMetadataReferral("Aspect not found: " + aspect); - } - } - - this.referralRegistry.register(this); - } - - /** Gets the type of the peer association linking the node to its delegate. */ - public QName getAssocType() - { - return assocType; - } - - /** Gets the set of aspects which are being referred. */ - public Set getAspects() - { - return Collections.unmodifiableSet(aspects); - } - - @Override public int hashCode() - { - return Objects.hash(aspects, assocType); - } - - @Override public boolean equals(Object other) - { - boolean result = false; - if (other instanceof MetadataReferral) - { - MetadataReferral that = (MetadataReferral)other; - result = this.aspects.equals(that.aspects) && - this.assocType.equals(that.assocType); - } - return result; - } - - @Override public String toString() - { - StringBuilder result = new StringBuilder(); - result.append(this.getClass().getSimpleName()).append(':') - .append("--").append(assocType).append("->") - .append(aspects); - return result.toString(); - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminService.java deleted file mode 100644 index 52a94d7a09..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminService.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.ChainedMetadataReferralUnsupported; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -import java.util.Set; - -/** - * A service to manage the referral of aspect metadata. - * Using this service a node can be {@link #attachReferrer linked} to a referrer node for a specific set of aspects. - * (Note that this referrer node must already exist within the database.) - * Then any read request for relevant metadata such as hasAspect or getProperties can be delegated to the - * linked node. - *

- * For a link to be made, there must be a {@link ReferralRegistry#getMetadataReferrals()} defined MetadataReferral} - * already in the system. - * This means that a peer-association type will have to have been declared and that a spring bean will have to have - * defined which aspects are to be handled by this {@link MetadataReferral}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public interface ReferralAdminService -{ - /** - * Creates a link between two nodes such that the first {@code referrer} can 'inherit' or reuse some aspect - * metadata from another node - the {@code referrer}. - *

- * Note that attaching a referrer for the specified aspect will also link the two nodes for - * all aspects defined in the {@link MetadataReferral}. - *

- * Note that links can currently only extend between two pairs of nodes and cannot be chained. - * - * @param referrer the node which is to inherit additional metadata. - * @param referent the node which will provide the additional metadata. - * @param aspectName the name of the aspect whose metadata is to be attached. - * @return a {@link MetadataReferral} object which defines the link type. - * @throws ChainedMetadataReferralUnsupported if an attempt is made to attach nodes such that a chain would be made. - */ - MetadataReferral attachReferrer(NodeRef referrer, NodeRef referent, QName aspectName); - - /** - * Removes an existing metadata link between two nodes. - *

- * Note that detaching a referrer for the specified aspect will also unlink the two nodes for - * all aspects defined in the {@link MetadataReferral}. - * - * @param referrer the node which has been linked to a metadata source. - * @param aspectName the name of the aspect whose metadata is to be detached. - * @return the removed {@link MetadataReferral}. - */ - MetadataReferral detachReferrer(NodeRef referrer, QName aspectName); // FIXME Chase all references - - /** - * Gets the set of {@link MetadataReferral}s which are currently applied from the specified {@code referrer}. - * From these, the types of peer associations which are linked to the specified - * {@code referrer} as well as the aspect types that are handled can be retrieved. - * - * @param referrer the NodeRef whose {@link MetadataReferral}s are sought. - * @return the set of {@link MetadataReferral}s from the specified referrer. - */ - Set getAttachedReferralsFrom(NodeRef referrer); - - /** - * Gets the {@link MetadataReferral} from the specified {@code referrer} for the specified {@code aspectName}, - * if there is one. - * - * @param referrer the node whose {@link MetadataReferral} is sought. - * @param aspectName the aspect name for which a {@link MetadataReferral} is sought. - * @return the {@link MetadataReferral} which is attached to the specified node if there is one, else {@code null}. - */ - MetadataReferral getAttachedReferralFrom(NodeRef referrer, QName aspectName); -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java deleted file mode 100644 index 9afcbc0259..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static org.alfresco.util.collections.CollectionUtils.transform; - -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.ChainedMetadataReferralUnsupported; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.collections.Function; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReferralAdminServiceImpl implements ReferralAdminService -{ - // Author's implementation note - // ---------------------------- - // - // I can imagine that these services would be potentially useful in core Alfresco. - // However they are not yet full services and couldn't be moved as is into core. - // They solve a very specific RM problem in a fairly generic way that should allow - // someone to use them as the basis for fuller services within core. - // - // The problem they solve is that of 'classified renditions' whereby the classification - // metadata on a node should appear to be on its renditions as well. This particular problem - // is simplified by the fact that renditions are not 'normal' nodes, as they are usually - // not accessed directly. This implementation also relies on the fact that RM already - // has interceptors for checking content classification and we can programmatically add - // the calls to metadata referral within the ContentClassificationService. - // - // To solve the problem of Metadata Referral in a general way would require the provision - // of 'MetadataReferral' interceptors that could sit in front of the NodeService. Only in this - // way could the services be used declaratively, thus minimising their impact on calling code. - // To add these to core would require careful assessment of their impact, not least in - // performance terms. This work is beyond RM's scope at this stage. - // The addition of such interceptors to the NodeService would also ensure that any metadata - // returned to e.g. Share for a particular node could automatically include 'linked' metadata - // which would be important. - // - // There are further enhancements that should be considered if these were developed into - // fuller services including the automatic registration of behaviours (onAddAspect, onRemoveAspect) - // for the aspect types which are linked. Currently these behaviours need to be hand-coded. - // See ClassifiedAspect.java for an example. - - private ReferralRegistry registry; - private NodeService nodeService; - - public void setNodeService(NodeService service) - { - this.nodeService = service; - } - - public void setReferralRegistry(ReferralRegistry registry) - { - this.registry = registry; - } - - @Override public MetadataReferral attachReferrer(NodeRef referrer, NodeRef referent, QName aspectName) - { - final MetadataReferral metadataReferral = registry.getReferralForAspect(aspectName); - if (metadataReferral == null) - { - throw new IllegalArgumentException("No defined " + MetadataReferral.class.getSimpleName() + - " for aspect " + aspectName); - } - final QName assocType = metadataReferral.getAssocType(); - - // Prevent the creation of chains of metadata linking from node A to B to C. - - // If any nodes are already linked to referrer for the specified assoc, then we can't chain. - final List existingReferrerAssocs = nodeService.getSourceAssocs(referrer, assocType); - if ( !existingReferrerAssocs.isEmpty()) - { - final List existingReferrers = transform(existingReferrerAssocs, - new Function() - { - @Override public NodeRef apply(AssociationRef assocRef) - { - return assocRef.getSourceRef(); - } - }); - throw new ChainedMetadataReferralUnsupported("Cannot attach referrer", existingReferrers); - } - - // Likewise if this referent node is already itself linked elsewhere, we cannot chain. - final List existingReferentAssocs = nodeService.getTargetAssocs(referent, assocType); - if ( !existingReferentAssocs.isEmpty()) - { - // If it's not empty, it should only have one value in it, but just in case... - final List existingReferents = transform(existingReferentAssocs, - new Function() - { - @Override public NodeRef apply(AssociationRef assocRef) - { - return assocRef.getTargetRef(); - } - }); - throw new ChainedMetadataReferralUnsupported("Cannot attach referent", existingReferents); - } - - // OK. We're good to go. We're not making a chain here. - nodeService.createAssociation(referrer, referent, assocType); - - return metadataReferral; - } - - @Override public MetadataReferral detachReferrer(NodeRef referrer, QName aspectName) - { - final MetadataReferral referral = registry.getReferralForAspect(aspectName); - final QName assocType = referral.getAssocType(); - - // Is the association there? - final List assocs = nodeService.getTargetAssocs(referrer, assocType); - - if (assocs == null || assocs.isEmpty()) - { - return null; - } - else - { - // There should only be one such association... but we'll remove them all just in case - for (AssociationRef assocRef : assocs) - { - nodeService.removeAssociation(referrer, assocRef.getTargetRef(), assocType); - } - - return referral; - } - } - - @Override public Set getAttachedReferralsFrom(NodeRef referrer) - { - final Set allMetadataReferrals = registry.getMetadataReferrals(); - - final Set result = new HashSet<>(); - for (MetadataReferral d : allMetadataReferrals) - { - final QName assocType = d.getAssocType(); - if ( !nodeService.getTargetAssocs(referrer, assocType).isEmpty()) - { - result.add(d); - } - } - - return result; - } - - @Override public MetadataReferral getAttachedReferralFrom(NodeRef referrer, QName aspectName) - { - final Set allMetadataReferrals = getAttachedReferralsFrom(referrer); - - for (MetadataReferral d : allMetadataReferrals) - { - if (d.getAspects().contains(aspectName)) return d; - } - return null; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralRegistry.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralRegistry.java deleted file mode 100644 index 653e2e7790..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralRegistry.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.MetadataReferralAlreadyExists; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.InvalidMetadataReferral; -import org.alfresco.service.namespace.QName; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * This is a registry of {@link MetadataReferral}s which have been defined in the system. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReferralRegistry -{ - private final Set metadataReferrals = new HashSet<>(); - - public void register(MetadataReferral metadataReferral) - { - // Various validation steps to do here to ensure we get consistent, sensible referrals registered. - if (metadataReferrals.contains(metadataReferral)) - { - throw new MetadataReferralAlreadyExists("Cannot register duplicate referral", metadataReferral); - } - for (MetadataReferral existingMetadataReferral : metadataReferrals) - { - if (existingMetadataReferral.getAssocType().equals(metadataReferral.getAssocType())) - { - throw new InvalidMetadataReferral("Cannot register two referrals with the same assocType. " + - "Existing: " + existingMetadataReferral + - " New: " + metadataReferral); - } - // Yes this is a for loop inside a for loop but we're assuming these sets will not be large. - for (QName existingAspect : existingMetadataReferral.getAspects()) - { - if (metadataReferral.getAspects().contains(existingAspect)) - { - throw new InvalidMetadataReferral("Cannot register two referrals with the same aspect. " + - "Existing: " + existingMetadataReferral + - " New: " + metadataReferral); - } - } - } - - this.metadataReferrals.add(metadataReferral); - } - - public Set getMetadataReferrals() - { - return Collections.unmodifiableSet(metadataReferrals); - } - - /** - * Gets the {@link MetadataReferral} which is defined to use the specified {@code assocType}. - * - * @param assocType the peer association type whose {@link MetadataReferral} is sought. - * @return the {@link MetadataReferral} defined to use the specified {@code assocType} if there is one, else {@code null}. - */ - public MetadataReferral getReferralForAssociation(QName assocType) - { - for (MetadataReferral mr : metadataReferrals) - { - if (mr.getAssocType().equals(assocType)) - { - return mr; - } - } - return null; - } - - /** - * Gets the {@link MetadataReferral} which is defined to handle the specified aspect. - * - * @param aspectName the name of the aspect whose {@link MetadataReferral} is sought. - * @return the {@link MetadataReferral} handling the specified aspect if there is one, else {@code null}. - */ - public MetadataReferral getReferralForAspect(QName aspectName) - { - for (MetadataReferral mr : metadataReferrals) - { - if (mr.getAspects().contains(aspectName)) - { - return mr; - } - } - return null; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataException.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataException.java deleted file mode 100644 index aaaf992871..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataException.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; - -import java.util.List; - -/** - * Generic class for any runtime exceptions related to metadata referrals. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReferredMetadataException extends AlfrescoRuntimeException -{ - private static final long serialVersionUID = -6059777070036571486L; - - public ReferredMetadataException(String msgId) { super(msgId); } - public ReferredMetadataException(String msgId, Throwable cause) { super(msgId, cause); } - - /** This exception may be thrown when a {@link MetadataReferral} was incorrectly initialised. */ - public static class InvalidMetadataReferral extends ReferredMetadataException - { - private static final long serialVersionUID = 8507076314709440295L; - - public InvalidMetadataReferral(String msgId) - { - super(msgId); - } - } - - /** This exception may be thrown when a {@link MetadataReferral} already exists. */ - public static class MetadataReferralAlreadyExists extends ReferredMetadataException - { - private static final long serialVersionUID = 8119954252195817706L; - - private final MetadataReferral metadataReferral; - - public MetadataReferralAlreadyExists(String msgId, MetadataReferral metadataReferral) - { - super(msgId); - this.metadataReferral = metadataReferral; - } - - public MetadataReferral getMetadataReferral() - { - return this.metadataReferral; - } - } - - /** A {@link MetadataReferral} has not been found. */ - public static class MetadataReferralNotFound extends ReferredMetadataException - { - private static final long serialVersionUID = 8648089074801662142L; - - public MetadataReferralNotFound(String msgId) - { - super(msgId); - } - } - - /** A referent Node has not been found. */ - public static class ReferentNodeNotFound extends ReferredMetadataException - { - private static final long serialVersionUID = -6003487925958374458L; - - public ReferentNodeNotFound(String msgId) - { - super(msgId); - } - } - - /** Exception to report that chains of metadata referral are not currently supported. */ - public static class ChainedMetadataReferralUnsupported extends ReferredMetadataException - { - private static final long serialVersionUID = -2293262325447442964L; - - private final List existingReferrers; - - public ChainedMetadataReferralUnsupported(String msgId, List existingReferrers) - { - super(msgId); - this.existingReferrers = existingReferrers; - } - - public List getExistingReferrers() - { - return this.existingReferrers; - } - - @Override public String toString() - { - StringBuilder msg = new StringBuilder(); - msg.append(this.getClass().getSimpleName()).append(" Already referring from: ") - .append(existingReferrers.toString()); - return msg.toString(); - } - } - - /** Exception to report that metadata referral is not supported for metadata defined on content types. */ - public static class TypeMetadataReferralUnsupported extends ReferredMetadataException - { - private static final long serialVersionUID = 7498707640089715503L; - - public TypeMetadataReferralUnsupported(String msgId) - { - super(msgId); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataService.java deleted file mode 100644 index 77d234dbfe..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataService.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.MetadataReferralNotFound; -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.TypeMetadataReferralUnsupported; - -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -import java.io.Serializable; -import java.util.Map; - -/** - * This service provides read-only access to linked metadata. It is primarily concerned with data transfer. - * For an overview, see the package javadoc. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public interface ReferredMetadataService -{ - /** - * Checks if the specified referrer has an attached {@link MetadataReferral} for the specified aspect. - * - * @param potentialReferrer the referrer which may or may not be linked to a referent node. - * @param aspectName the name of the aspect. - * @return whether the node is linked to a referent node for the specified aspect. - * @throws InvalidNodeRefException if the supplied referrer does not exist. - * @throws MetadataReferralNotFound if no {@link MetadataReferral} is defined for the specified aspect. - */ - boolean isReferringMetadata(NodeRef potentialReferrer, QName aspectName); - - /** - * Gets the referent node for the specified aspect, if there is one. - * - * @param referrer the node whose referent is sought. - * @param aspectName the aspect name. - * @return the referent of the provided referrer if there is one, else {@code null}. - * @throws InvalidNodeRefException if the supplied referrer does not exist. - * @throws MetadataReferralNotFound if no {@link MetadataReferral} is defined for the specified aspect. - */ - NodeRef getReferentNode(NodeRef referrer, QName aspectName); - - /** - * Gets all the property values from the referent node for the specified aspect. - * - * @param referrer the referring node. - * @param aspectName the aspect name which holds the properties we want. - * @return the property values as obtained from the referent node. - */ - Map getReferredProperties(NodeRef referrer, QName aspectName); - - /** - * Gets the specified property value from the referent node. - * - * @param referrer the referring node. - * @param propertyName the property name whose value is sought. - * @return the property value as obtained from the referent node. - * @throws IllegalArgumentException if the specified property is not defined. - * @throws TypeMetadataReferralUnsupported if the specified property is not defined on an aspect. - */ - Serializable getReferredProperty(NodeRef referrer, QName propertyName); - - /** - * Determines if the specified aspect is present on a node's referent. - * - * @param referrer the referring node. - * @param aspectName the aspect which is to be checked on the referent node. - * @return Returns true if the aspect has been applied to the referent node, - * otherwise false - */ - boolean hasReferredAspect(NodeRef referrer, QName aspectName); - - /** - * Gets all {@link MetadataReferral referrals} currently attached to the specified node. - * - * @param potentialReferrer the node whose attached {@link MetadataReferral referrals} are sought. - * @return Returns a map of all attached {@link MetadataReferral referrals} for the specified nodeRef. - * The map has the form {@code (key, value) = (MetadataReferral, referent Node for that Referral)} - * The map may be empty but will not be {@code null}. - */ - Map getAttachedReferrals(NodeRef potentialReferrer); -} - diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataServiceImpl.java deleted file mode 100644 index fe9eaca755..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataServiceImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.MetadataReferralNotFound; -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.ReferentNodeNotFound; -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.TypeMetadataReferralUnsupported; -import static org.alfresco.util.collections.CollectionUtils.filterKeys; - -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.collections.Function; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReferredMetadataServiceImpl implements ReferredMetadataService -{ - private ReferralAdminService referralAdminService; - private ReferralRegistry referralRegistry; - private DictionaryService dictionaryService; - private NodeService nodeService; - - public void setReferralAdminService(ReferralAdminService service) - { - this.referralAdminService = service; - } - - public void setReferralRegistry(ReferralRegistry registry) - { - this.referralRegistry = registry; - } - - public void setDictionaryService(DictionaryService service) - { - this.dictionaryService = service; - } - - public void setNodeService(NodeService service) - { - this.nodeService = service; - } - - @Override public boolean isReferringMetadata(NodeRef potentialReferrer, QName aspectName) - { - if ( !nodeService.exists(potentialReferrer)) - { - throw new InvalidNodeRefException(potentialReferrer); - } - - final MetadataReferral metadataReferral = referralRegistry.getReferralForAspect(aspectName); - - if (metadataReferral == null) - { - throw new MetadataReferralNotFound("No defined referral found for aspect: " + aspectName); - } - else - { - final List targetAssocs = nodeService.getTargetAssocs(potentialReferrer, metadataReferral.getAssocType()); - return !targetAssocs.isEmpty(); - } - } - - @Override public NodeRef getReferentNode(NodeRef referrer, QName aspectName) - { - if ( !nodeService.exists(referrer)) - { - throw new InvalidNodeRefException(referrer); - } - - final MetadataReferral d = referralRegistry.getReferralForAspect(aspectName); - - if (d == null) - { - throw new MetadataReferralNotFound("No defined referral found for aspect: " + aspectName); - } - else - { - final QName assocType = d.getAssocType(); - final List assocs = nodeService.getTargetAssocs(referrer, assocType); - - return assocs.isEmpty() ? null : assocs.get(0).getTargetRef(); - } - } - - @Override public Map getReferredProperties(NodeRef referrer, final QName aspectName) - { - final NodeRef referentNode = getReferentNode(referrer, aspectName); - - if (referentNode == null) - { - throw new ReferentNodeNotFound("No referent node found for " + referrer + " " + aspectName); - } - else - { - final Map allProps = nodeService.getProperties(referentNode); - final Map aspectProps = filterKeys(allProps, - new Function() - { - @Override public Boolean apply(QName propName) - { - final QName containerClassname = dictionaryService.getProperty(propName) - .getContainerClass() - .getName(); - return containerClassname.equals(aspectName); - } - }); - return aspectProps; - } - } - - @Override public Serializable getReferredProperty(NodeRef referrer, QName propertyName) - { - final PropertyDefinition propDefn = dictionaryService.getProperty(propertyName); - - if (propDefn == null) - { - throw new IllegalArgumentException("Property " + propertyName + " not found."); - } - - final ClassDefinition aspectDefn = propDefn.getContainerClass(); - if (!aspectDefn.isAspect()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Property '").append(propertyName).append("' is not defined on an aspect: ") - .append(aspectDefn.getName()); - - throw new TypeMetadataReferralUnsupported(msg.toString()); - } - - final Map allPropValues = getReferredProperties(referrer, aspectDefn.getName()); - return allPropValues.get(propertyName); - } - - @Override public boolean hasReferredAspect(NodeRef referrer, QName aspectName) - { - final NodeRef referentNode = getReferentNode(referrer, aspectName); - - if (referentNode == null) - { - throw new ReferentNodeNotFound("No referent node found for " + referrer + " " + aspectName); - } - else - { - return nodeService.hasAspect(referentNode, aspectName); - } - } - - @Override public Map getAttachedReferrals(NodeRef potentialReferrer) - { - Set metadataReferrals = referralAdminService.getAttachedReferralsFrom(potentialReferrer); - - Map result = new HashMap<>(); - for (MetadataReferral mr : metadataReferrals) - { - // We need only use the first aspect to get the MetadataReferral object - if (!mr.getAspects().isEmpty()) - { - result.put(mr, getReferentNode(potentialReferrer, mr.getAspects().iterator().next())); - } - } - - return result; - } -} - diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/package-info.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/package-info.java deleted file mode 100644 index 7a1a00ae73..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/package-info.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -/** - * This package contains the types that deliver the Metadata Referral feature. - * Metadata referral allows node metadata to be shared between multiple Alfresco nodes. - *

- * In this way nodes can 'inherit' some of their metadata from another node which may - * have benefits when more than one node is required to share some of the same metadata. - *

- * Only aspect metadata can be shared and it is only shared as read-only data to the other nodes. - * The node which contains the metadata values is the 'referent' node and any nodes which have been - * linked to the referent and share the metadata are known as referrers. - *

- * Multiple nodes may share the same referent node and one node may be linked to multiple referrers. - *

- * The linking of nodes to their metadata referents is done with Alfresco peer associations. - * Association types must be declared in an Alfresco content model in the normal way. - * Spring configuration is used to assign each association type a set of aspects which will - * be available from the referent via the association. - *

- * See {@link org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService} - * for details on how to create and destroy metadata links between nodes. - *

- * See {@link org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService} - * for details on how the data access is performed. - *

- * See {@link org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralRegistry} - * for details on what {@link org.alfresco.module.org_alfresco_module_rm.referredmetadata.MetadataReferral}s - * are defined in the system. - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassificationLevelsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassificationLevelsGet.java deleted file mode 100644 index e5337f78a4..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassificationLevelsGet.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the classification levels. - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassificationLevelsGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String LEVELS = "levels"; - - /** Classification scheme service */ - private ClassificationSchemeService classificationSchemeService; - - /** - * Sets the classification scheme service - * - * @param classificationSchemeService The classification scheme service - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map result = new HashMap(); - result.put(LEVELS, classificationSchemeService.getClassificationLevels()); - return result; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java deleted file mode 100644 index b789874de7..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static org.alfresco.util.WebScriptUtils.getJSONArrayFromJSONObject; -import static org.alfresco.util.WebScriptUtils.getJSONArrayValue; -import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject; -import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; -import static org.apache.commons.lang3.StringUtils.isBlank; -import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATE_FORMAT; -import static org.springframework.extensions.webscripts.Status.STATUS_BAD_REQUEST; - -import java.text.ParseException; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang3.time.DateUtils; -import org.json.JSONArray; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Base class for classify content actions - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public abstract class ClassifyContentBase extends AbstractRmWebScript -{ - /** Constants */ - public static final String CLASSIFICATION_LEVEL_ID = "classificationLevelId"; - public static final String CLASSIFIED_BY = "classifiedBy"; - public static final String CLASSIFICATION_AGENCY = "classificationAgency"; - public static final String CLASSIFICATION_REASONS = "classificationReasons"; - public static final String DOWNGRADE_DATE = "downgradeDate"; - public static final String DOWNGRADE_EVENT = "downgradeEvent"; - public static final String DOWNGRADE_INSTRUCTIONS = "downgradeInstructions"; - public static final String DECLASSIFICATION_DATE = "declassificationDate"; - public static final String DECLASSIFICATION_EVENT = "declassificationEvent"; - public static final String DECLASSIFICATION_EXEMPTIONS = "declassificationExemptions"; - public static final String RECLASSIFY_BY = "reclassifyBy"; - public static final String RECLASSIFY_REASON = "reclassifyReason"; - public static final String LAST_RECLASSIFY_BY = "lastReclassifyBy"; - public static final String LAST_RECLASSIFY_REASON = "lastReclassifyReason"; - - /** The service responsible for classifying content. */ - private ContentClassificationService contentClassificationService; - - /** - * Get the service responsible for classifying content. - * - * @return the contentClassificationService - */ - protected ContentClassificationService getContentClassificationService() - { - return this.contentClassificationService; - } - - /** - * Set the service responsible for classifying content. - * - * @param contentClassificationService The service responsible for classifying content. - */ - public void setContentClassificationService(ContentClassificationService contentClassificationService) - { - this.contentClassificationService = contentClassificationService; - } - - /** - * Abstract method which does the action of either - * classifying a content or editing a classified content - * - * @param classificationAspectProperties The properties to use when classifying the content. - * @param document The classified content which will be edited. - */ - protected abstract void doClassifyAction(ClassificationAspectProperties classificationAspectProperties, NodeRef document); - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - JSONObject jsonObject = getRequestContentAsJsonObject(req); - String classificationLevelId = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_LEVEL_ID); - String classifiedBy = getStringValueFromJSONObject(jsonObject, CLASSIFIED_BY); - String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY, false, false); - Set classificationReasonIds = getClassificationReasonIds(jsonObject); - String downgradeDate = getStringValueFromJSONObject(jsonObject, DOWNGRADE_DATE, false, false); - String downgradeEvent = getStringValueFromJSONObject(jsonObject, DOWNGRADE_EVENT, false, false); - String downgradeInstructions = getStringValueFromJSONObject(jsonObject, DOWNGRADE_INSTRUCTIONS, false, false); - String declassificationDate = getStringValueFromJSONObject(jsonObject, DECLASSIFICATION_DATE, false, false); - String declassificationEvent = getStringValueFromJSONObject(jsonObject, DECLASSIFICATION_EVENT, false, false); - Set exemptionCategoryIds = getExemptionCategoryIds(jsonObject); - String lastReclassifyBy = getStringValueFromJSONObject(jsonObject, RECLASSIFY_BY, false, false); - String lastReclassifyReason = getStringValueFromJSONObject(jsonObject, RECLASSIFY_REASON, false, false); - if (isBlank(lastReclassifyBy) || isBlank(lastReclassifyReason)) - { - lastReclassifyBy = getStringValueFromJSONObject(jsonObject, LAST_RECLASSIFY_BY, false, false); - lastReclassifyReason = getStringValueFromJSONObject(jsonObject, LAST_RECLASSIFY_REASON, false, false); - } - - ClassificationAspectProperties propertiesDTO = new ClassificationAspectProperties(); - propertiesDTO.setClassificationLevelId(classificationLevelId); - propertiesDTO.setClassifiedBy(classifiedBy); - propertiesDTO.setClassificationAgency(classificationAgency); - propertiesDTO.setClassificationReasonIds(classificationReasonIds); - propertiesDTO.setDowngradeDate(parseDate(downgradeDate)); - propertiesDTO.setDowngradeEvent(downgradeEvent); - propertiesDTO.setDowngradeInstructions(downgradeInstructions); - propertiesDTO.setDeclassificationDate(parseDate(declassificationDate)); - propertiesDTO.setDeclassificationEvent(declassificationEvent); - propertiesDTO.setExemptionCategoryIds(exemptionCategoryIds); - propertiesDTO.setLastReclassifyBy(lastReclassifyBy); - propertiesDTO.setLastReclassifyReason(lastReclassifyReason); - - NodeRef document = parseRequestForNodeRef(req); - - doClassifyAction(propertiesDTO, document); - - Map model = new HashMap<>(1); - model.put(SUCCESS, true); - - return model; - } - - /** - * Helper method used to get the classification reason ids and exemption category ids - * - * @param jsonObject The json object representing the request body - * @param key The key - * @return {@link Set}<{@link String}> ids - */ - private Set getIds(JSONObject jsonObject, String key) - { - Set ids = new HashSet<>(); - - JSONArray jsonArray = getJSONArrayFromJSONObject(jsonObject, key); - for (int i = 0; i < jsonArray.length(); i++) - { - JSONObject id = (JSONObject) getJSONArrayValue(jsonArray, i); - ids.add(getStringValueFromJSONObject(id, ID)); - } - - return ids; - } - - /** - * Helper method to get the classification reason ids - * - * @param jsonObject The json object representing the request body - * @return {@link Set}<{@link String}> classification ids - */ - private Set getClassificationReasonIds(JSONObject jsonObject) - { - return getIds(jsonObject, CLASSIFICATION_REASONS); - } - - /** - * Helper method to get the exemption category ids - * - * @param jsonObject The json object representing the request body - * @return {@link Set}<{@link String}> exemption category ids - */ - private Set getExemptionCategoryIds(JSONObject jsonObject) - { - Set exemptionCategoryIds = new HashSet<>(); - - if (jsonObject.has(DECLASSIFICATION_EXEMPTIONS)) - { - exemptionCategoryIds.addAll(getIds(jsonObject, DECLASSIFICATION_EXEMPTIONS)); - } - - return exemptionCategoryIds; - } - - /** - * Parses the given date - * - * @param date The {@link Object} which will be parsed - * @return The parsed date. If the given date is null then null will be returned. - */ - private Date parseDate(String date) - { - Date parsedDate = null; - - if (isNotBlank(date)) - { - try - { - parsedDate = DateUtils.parseDate(date, ISO_DATE_FORMAT.getPattern()); - } - catch (ParseException error) - { - throw new WebScriptException(STATUS_BAD_REQUEST, "The given date '" + date + "' could not be parsed."); - } - } - - return parsedDate; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java deleted file mode 100644 index 564d56b469..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Implementation for Java backed webscript to classify a content. - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassifyContentPost extends ClassifyContentBase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase#doClassifyAction(java.lang.String, java.lang.String, java.lang.String, java.util.Set, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void doClassifyAction(ClassificationAspectProperties classificationAspectProperties, NodeRef document) - { - getContentClassificationService().classifyContent(classificationAspectProperties, document); - } -} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPut.java deleted file mode 100644 index 76f4efb57f..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPut.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Implementation for Java backed webscript to edit a classified content. - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassifyContentPut extends ClassifyContentBase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase#doClassifyAction(java.lang.String, java.lang.String, java.lang.String, java.util.Set, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void doClassifyAction(ClassificationAspectProperties classificationAspectProperties, NodeRef document) - { - getContentClassificationService().editClassifiedContent(classificationAspectProperties, document); - } -} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClearanceLevelsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClearanceLevelsGet.java deleted file mode 100644 index 3a1a22e4eb..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClearanceLevelsGet.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -import java.util.HashMap; -import java.util.Map; - -/** - * Implementation for Java backed webscript to get the clearance levels. - * - * @author David Webster - * @since 2.4.a - */ -public class ClearanceLevelsGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String LEVELS = "levels"; - - /** Classification service */ - private SecurityClearanceService securityClearanceService; - - /** - * Sets the classification service - * - * @param securityClearanceService The classification service - */ - public void setSecurityClearanceService(SecurityClearanceService securityClearanceService) - { - this.securityClearanceService = securityClearanceService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map result = new HashMap(); - result.put(LEVELS, securityClearanceService.getClearanceLevels()); - return result; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ExemptionCategoriesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ExemptionCategoriesGet.java deleted file mode 100644 index d7a603c316..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ExemptionCategoriesGet.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the exemption categories. - * - * @author tpage - * @since 2.4.a - */ -public class ExemptionCategoriesGet extends AbstractRmWebScript -{ - /** The exemption category key for the map. */ - private static final String EXEMPTION_CATEGORIES = "exemptionCategories"; - - /** The classification scheme service. */ - private ClassificationSchemeService classificationSchemeService; - - /** - * Sets the classification scheme service. - * - * @param classificationSchemeService The classification scheme service. - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map result = new HashMap(); - result.put(EXEMPTION_CATEGORIES, classificationSchemeService.getExemptionCategories()); - return result; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGet.java deleted file mode 100644 index 8358b57104..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGet.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get the classification reasons. - * - * @author tpage - * @since 2.4.a - */ -public class ReasonsGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String REASONS = "reasons"; - - /** Classification scheme service */ - private ClassificationSchemeService classificationSchemeService; - - /** - * Sets the classification scheme service - * - * @param classificationSchemeService The classification scheme service - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map result = new HashMap(); - result.put(REASONS, classificationSchemeService.getClassificationReasons()); - return result; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearanceGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearanceGet.java deleted file mode 100644 index 2d75e6765b..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearanceGet.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static java.lang.Boolean.parseBoolean; -import static java.lang.Integer.parseInt; -import static org.apache.commons.lang.StringUtils.isBlank; -import static org.apache.commons.lang.StringUtils.isNotBlank; -import static org.springframework.extensions.surf.util.URLDecoder.decode; -import static org.springframework.extensions.webscripts.Status.STATUS_INTERNAL_SERVER_ERROR; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.classification.UserQueryParams; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.alfresco.query.PagingResults; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.apache.commons.collections.iterators.ArrayIterator; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * Implementation for Java backed webscript to get users security clearance. - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class UserSecurityClearanceGet extends AbstractRmWebScript -{ - /** Constants */ - private static final String TOTAL = "total"; - private static final String SKIP_COUNT = "startIndex"; - private static final String MAX_ITEMS = "pageSize"; - private static final String SORT_FIELDS = "sortField"; - private static final String SORT_ASCENDING_FLAGS = "sortAscending"; - private static final String SEPARATOR = ","; - private static final String ITEM_COUNT = "itemCount"; - private static final String ITEMS = "items"; - private static final String DATA = "data"; - private static final String NAME_FILTER = "nameFilter"; - private static final String PAGE_NUMBER = "page"; - - /** Security clearance service */ - private SecurityClearanceService securityClearanceService; - - /** - * @return the securityClearanceService - */ - protected SecurityClearanceService getSecurityClearanceService() - { - return this.securityClearanceService; - } - - /** - * @param securityClearanceService the securityClearanceService to set - */ - public void setSecurityClearanceService(SecurityClearanceService securityClearanceService) - { - this.securityClearanceService = securityClearanceService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String nameFilter = getNameFilter(req); - UserQueryParams userQueryParams = new UserQueryParams(nameFilter); - setMaxItems(userQueryParams, req); - setSkipCount(userQueryParams, req); - setSortProps(userQueryParams, req); - - PagingResults usersSecurityClearance = getSecurityClearanceService().getUsersSecurityClearance(userQueryParams); - - int total = getTotal(usersSecurityClearance).intValue(); - int maxItems = userQueryParams.getMaxItems(); - if (total != 0 && getPageNumber(req) > Math.ceil((double) total / (double) maxItems)) - { - throw new WebScriptException("The requested page is not valid"); - } - - List securityClearanceItems = getSecurityClearanceItems(usersSecurityClearance); - - Map securityClearanceData = new HashMap<>(); - securityClearanceData.put(TOTAL, total); - securityClearanceData.put(MAX_ITEMS, maxItems); - securityClearanceData.put(SKIP_COUNT, userQueryParams.getSkipCount()); - securityClearanceData.put(ITEM_COUNT, securityClearanceItems.size()); - securityClearanceData.put(ITEMS, securityClearanceItems); - - Map model = new HashMap<>(); - model.put(DATA, securityClearanceData); - - return model; - } - - /** - * Helper method to get the total number of security clearance items - * - * @param usersSecurityClearance {@link PagingResults} The security clearance results - * @return The total number of security clearance items - */ - private Integer getTotal(PagingResults usersSecurityClearance) - { - Pair totalResultCount = usersSecurityClearance.getTotalResultCount(); - if (totalResultCount == null) - { - throw new WebScriptException(STATUS_INTERNAL_SERVER_ERROR, "Total result count cannot be determined."); - } - return totalResultCount.getFirst(); - } - - /** - * Helper method to get the security clearance items from the {@link PagingResults} - * - * @param usersSecurityClearance {@link PagingResults} The security clearance results - * @return {@link List}<{@link SecurityClearance}> The list of security clearance items - */ - private List getSecurityClearanceItems(PagingResults usersSecurityClearance) - { - return usersSecurityClearance.getPage(); - } - - /** - * Gets the name filter from the webscript request - * - * @param req {@link WebScriptRequest} The webscript request - * @return {@link String} The name filter from the request (or the empty string if the request doesn't contain one). - */ - private String getNameFilter(WebScriptRequest req) - { - String nameFilter = req.getParameter(NAME_FILTER); - return (nameFilter != null ? nameFilter : ""); - } - - /** - * Gets the page number from the webscript request - * - * @param req {@link WebScriptRequest} The webscript request - * @return int The page number - */ - private int getPageNumber(WebScriptRequest req) - { - String pageNumber = req.getParameter(PAGE_NUMBER); - return isNotBlank(pageNumber) ? parseInt(pageNumber) : 1; - } - - /** - * Helper method to set the max index for the request query object - * - * @param userQueryParams {@link UserQueryParams} The request query object - * @param req {@link WebScriptRequest} The webscript request - */ - private void setMaxItems(UserQueryParams userQueryParams, WebScriptRequest req) - { - String maxItems = req.getParameter(MAX_ITEMS); - if (isNotBlank(maxItems)) - { - userQueryParams.withMaxItems(parseInt(maxItems)); - } - } - - /** - * Helper method to set the skip count for the query object - * - * @param userQueryParams {@link UserQueryParams} The request query object - * @param req {@link WebScriptRequest} The webscript request - */ - private void setSkipCount(UserQueryParams userQueryParams, WebScriptRequest req) - { - String skipCount = req.getParameter(SKIP_COUNT); - if (isNotBlank(skipCount)) - { - userQueryParams.withSkipCount(parseInt(skipCount)); - } - } - - /** - * Helper method to set sort properties for the query object - * - * @param userQueryParams {@link UserQueryParams} The request query object - * @param req {@link WebScriptRequest} The webscript request - */ - @SuppressWarnings("unchecked") - protected void setSortProps(UserQueryParams userQueryParams, WebScriptRequest req) - { - String sortFields = req.getParameter(SORT_FIELDS); - if (isBlank(sortFields)) - { - return; - } - sortFields = decode(sortFields); - String sortAscendingFlags = req.getParameter(SORT_ASCENDING_FLAGS); - sortAscendingFlags = (isBlank(sortAscendingFlags) ? "True" : sortAscendingFlags); - - List> sortPairs = new ArrayList<>(); - Iterator ascendingFlagIterator = new ArrayIterator(sortAscendingFlags.split(SEPARATOR)); - for (String sortField : sortFields.split(SEPARATOR)) - { - boolean ascendingFlag = (ascendingFlagIterator.hasNext() ? parseBoolean(ascendingFlagIterator.next()) : true); - - if (isNotBlank(sortField)) - { - Pair sortPair = new Pair<>(QName.createQName(sortField, getNamespaceService()), ascendingFlag); - sortPairs.add(sortPair); - } - } - if (!sortPairs.isEmpty()) - { - userQueryParams.withSortProps(sortPairs); - } - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearancePut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearancePut.java deleted file mode 100644 index a32726aa90..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearancePut.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; -import org.springframework.extensions.surf.util.URLDecoder; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -import java.util.HashMap; -import java.util.Map; - -/** - * Implementation for Java backed webscript to set users security clearance. - * - * @author David Webster - * @author Tom Page - * @since 2.4.a - */ -public class UserSecurityClearancePut extends AbstractRmWebScript -{ - /** Constants */ - private static final String USERNAME = "username"; - private static final String CLEARANCE_ID = "clearanceId"; - private static final String ITEM = "item"; - - /** Security clearance service */ - private SecurityClearanceService securityClearanceService; - - /** - * @param securityClearanceService the securityClearanceService to set - */ - public void setSecurityClearanceService(SecurityClearanceService securityClearanceService) - { - this.securityClearanceService = securityClearanceService; - } - - /** - * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, - * org.springframework.extensions.webscripts.Status, - * org.springframework.extensions.webscripts.Cache) - */ - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - String username = URLDecoder.decode(req.getParameter(USERNAME)); - String clearanceId = req.getParameter(CLEARANCE_ID); - SecurityClearance securityClearance; - - try - { - securityClearance = securityClearanceService.setUserSecurityClearance(username, - clearanceId); - } - catch (ClassificationException.LevelIdNotFound exception) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to find clearance level"); - } - - Map model = new HashMap<>(); - model.put(ITEM, securityClearance); - - return model; - } -} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/CoreServicesExtras.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/CoreServicesExtras.java deleted file mode 100644 index d6cc6bc9c9..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/util/CoreServicesExtras.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.util; - -import static org.alfresco.util.collections.CollectionUtils.filterKeys; -import static org.apache.commons.lang.StringUtils.isNotBlank; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryException; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.collections.Function; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Provides additional methods of general use that could (in principle) be moved to the core services. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class CoreServicesExtras -{ - private DictionaryService dictionaryService; - private NodeService nodeService; - - public void setDictionaryService(DictionaryService service) - { - this.dictionaryService = service; - } - - public void setNodeService(NodeService service) - { - this.nodeService = service; - } - - /** - * This method copies the property values for the specified aspect from one node to another. - * All associations are ignored. Inherited properties are not copied. - * - * @param from the node whose property values are to be read. - * @param to the node to which the property values are to be written. - * @return a Map of the property values which were copied. - */ - public Map copyAspect(final NodeRef from, final NodeRef to, final QName aspectQName) - { - final AspectDefinition aspectDefn = dictionaryService.getAspect(aspectQName); - - if (aspectDefn == null) { throw new DictionaryException("Unknown aspect: " + aspectQName); } - - final Map aspectProperties = aspectDefn.getProperties(); - - final Map nodeProperties = nodeService.getProperties(from); - final Map relevantPropVals = filterKeys(nodeProperties, new Function() - { - @Override public Boolean apply(QName value) - { - // Only copy property values that are defined on the provided aspect. - final PropertyDefinition propDef = aspectProperties.get(value); - return propDef != null && propDef.getContainerClass().getName().equals(aspectQName); - } - }); - nodeService.addProperties(to, relevantPropVals); - return relevantPropVals; - } - - /** - * Use the {@link I18NUtil} to look up a key and return the localised message. If no entry for the current language - * is found then return the key. - * - * @param i18nKey The message key. - * @return The message if one exists, or the key. Never returns null (unless null is supplied as the key). - */ - public static String getI18NMessageOrKey(String i18nKey) - { - String message = I18NUtil.getMessage(i18nKey); - return (isNotBlank(message) ? message : i18nKey); - } -} diff --git a/rm-server/source/java/org/alfresco/repo/jscript/app/ClassificationReasonsPropertyDecorator.java b/rm-server/source/java/org/alfresco/repo/jscript/app/ClassificationReasonsPropertyDecorator.java deleted file mode 100644 index df75a6fadd..0000000000 --- a/rm-server/source/java/org/alfresco/repo/jscript/app/ClassificationReasonsPropertyDecorator.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.repo.jscript.app; - -import static org.alfresco.util.ParameterCheck.mandatory; - -import java.io.Serializable; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReason; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.json.simple.JSONArray; -import org.json.simple.JSONAware; -import org.json.simple.JSONObject; - -import com.google.gson.Gson; - -/** - * Classification reasons property decorator - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassificationReasonsPropertyDecorator extends BasePropertyDecorator -{ - /** Constants */ - protected static final String ID = "id"; - protected static final String LABEL = "label"; - protected static final String VALUE = "value"; - protected static final String DISPLAY_LABEL = "displayLabel"; - protected static final String FULL_REASON = "fullReason"; - - /** Classification scheme service */ - private ClassificationSchemeService classificationSchemeService; - - /** - * @return the classificationSchemeService - */ - protected ClassificationSchemeService getClassificationSchemeService() - { - return this.classificationSchemeService; - } - - /** - * @param classificationSchemeService the classificationSchemeService to set - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - - /** - * @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) - */ - @SuppressWarnings("unchecked") - public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value) - { - mandatory("value", value); - - JSONArray jsonArray = new JSONArray(); - JSONArray classificationReasonIds = new JSONArray(); - - if (value instanceof String) - { - classificationReasonIds = new Gson().fromJson((String) value, JSONArray.class); - } - else if (value instanceof List) - { - List values = (List) value; - for (String classificationReasonId : values) - { - classificationReasonIds.add(classificationReasonId); - } - } - else - { - throw new AlfrescoRuntimeException("Unexpected value instance: '" + value + "'."); - } - - for (int i = 0; i < classificationReasonIds.size(); i++) - { - String classificationReasonId = (String) classificationReasonIds.get(i); - ClassificationReason classificationReason = getClassificationSchemeService().getClassificationReasonById(classificationReasonId); - String classificationReasonDisplayLabel = classificationReason.getDisplayLabel(); - String classificationFullReason = classificationReasonId + ": " + classificationReasonDisplayLabel; - - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ID, classificationReasonId); - jsonObject.put(LABEL, classificationFullReason); - jsonObject.put(VALUE, classificationReasonId); - jsonObject.put(DISPLAY_LABEL, classificationReasonDisplayLabel); - jsonObject.put(FULL_REASON, classificationFullReason); - - jsonArray.add(jsonObject); - } - - return jsonArray; - } -} diff --git a/rm-server/source/java/org/alfresco/repo/jscript/app/CurrentClassificationPropertyDecorator.java b/rm-server/source/java/org/alfresco/repo/jscript/app/CurrentClassificationPropertyDecorator.java deleted file mode 100644 index a6739475f7..0000000000 --- a/rm-server/source/java/org/alfresco/repo/jscript/app/CurrentClassificationPropertyDecorator.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.repo.jscript.app; - -import static org.alfresco.util.ParameterCheck.mandatory; - -import java.io.Serializable; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.json.simple.JSONAware; -import org.json.simple.JSONObject; - -/** - * Current classification property decorator - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class CurrentClassificationPropertyDecorator extends BasePropertyDecorator -{ - /** Constants */ - protected static final String ID = "id"; - protected static final String LABEL = "label"; - - /** Classification scheme service */ - private ClassificationSchemeService classificationSchemeService; - - /** - * @return the classificationSchemeService - */ - protected ClassificationSchemeService getClassificationSchemeService() - { - return this.classificationSchemeService; - } - - /** - * @param classificationSchemeService the classificationSchemeService to set - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - - /** - * @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) - */ - @SuppressWarnings("unchecked") - public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value) - { - mandatory("value", value); - JSONObject jsonObj = new JSONObject(); - String currentClassificationId = value.toString(); - jsonObj.put(ID, currentClassificationId); - jsonObj.put(LABEL, getClassificationSchemeService().getClassificationLevelById(currentClassificationId).getDisplayLabel()); - return jsonObj; - } -} diff --git a/rm-server/source/java/org/alfresco/repo/jscript/app/ExemptionsCategoriesPropertyDecorator.java b/rm-server/source/java/org/alfresco/repo/jscript/app/ExemptionsCategoriesPropertyDecorator.java deleted file mode 100644 index 9e6cbcb089..0000000000 --- a/rm-server/source/java/org/alfresco/repo/jscript/app/ExemptionsCategoriesPropertyDecorator.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.repo.jscript.app; - -import static org.alfresco.util.ParameterCheck.mandatory; - -import java.io.Serializable; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.json.simple.JSONArray; -import org.json.simple.JSONAware; -import org.json.simple.JSONObject; - -import com.google.gson.Gson; - -/** - * Exemption categories property decorator - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ExemptionsCategoriesPropertyDecorator extends BasePropertyDecorator -{ - /** Constants */ - protected static final String ID = "id"; - protected static final String LABEL = "label"; - protected static final String VALUE = "value"; - protected static final String DISPLAY_LABEL = "displayLabel"; - protected static final String FULL_CATEGORY = "fullCategory"; - - /** Classification scheme service */ - private ClassificationSchemeService classificationSchemeService; - - /** - * @return the classificationSchemeService - */ - protected ClassificationSchemeService getClassificationSchemeService() - { - return this.classificationSchemeService; - } - - /** - * @param classificationSchemeService the classificationSchemeService to set - */ - public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService) - { - this.classificationSchemeService = classificationSchemeService; - } - - /** - * @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) - */ - @SuppressWarnings("unchecked") - public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value) - { - mandatory("value", value); - - JSONArray jsonArray = new JSONArray(); - JSONArray exemptionCategoryIds = new JSONArray(); - - if (value instanceof String) - { - exemptionCategoryIds = new Gson().fromJson((String) value, JSONArray.class); - } - else if (value instanceof List) - { - List values = (List) value; - for (String exemptionCategoryId : values) - { - exemptionCategoryIds.add(exemptionCategoryId); - } - } - else - { - throw new AlfrescoRuntimeException("Unexpected value instance: '" + value + "'."); - } - - for (int i = 0; i < exemptionCategoryIds.size(); i++) - { - String exemptionCategoryId = (String) exemptionCategoryIds.get(i); - ExemptionCategory exemptionCategory = getClassificationSchemeService().getExemptionCategoryById(exemptionCategoryId); - String exemptionCategoryDisplayLabel = exemptionCategory.getDisplayLabel(); - String exemptionCategoryFullCategory = exemptionCategoryId + ": " + exemptionCategoryDisplayLabel; - - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ID, exemptionCategoryId); - jsonObject.put(LABEL, exemptionCategoryFullCategory); - jsonObject.put(VALUE, exemptionCategoryId); - jsonObject.put(DISPLAY_LABEL, exemptionCategoryDisplayLabel); - jsonObject.put(FULL_CATEGORY, exemptionCategoryFullCategory); - - jsonArray.add(jsonObject); - } - - return jsonArray; - } -} diff --git a/rm-server/source/java/org/alfresco/repo/quickshare/ExtendedQuickShareServiceImpl.java b/rm-server/source/java/org/alfresco/repo/quickshare/ExtendedQuickShareServiceImpl.java deleted file mode 100644 index 9eeb6bd6fe..0000000000 --- a/rm-server/source/java/org/alfresco/repo/quickshare/ExtendedQuickShareServiceImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.alfresco.repo.quickshare; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.service.cmr.quickshare.QuickShareDTO; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; - -/** - * Extend the QuickShareService to check that content isn't classified before sharing it. - * - * @author David Webster - */ -public class ExtendedQuickShareServiceImpl extends QuickShareServiceImpl -{ - private NodeService nodeService; - - /** - * Set node service locally as inherited instance is private. - * - * @param nodeService the nodeService used to check node props and aspects - */ - @Override - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - super.setNodeService(nodeService); - } - - @Override - public QuickShareDTO shareContent(final NodeRef nodeRef) - { - if (!nodeService.hasAspect(nodeRef, ClassifiedContentModel.ASPECT_CLASSIFIED) || nodeService.getProperty(nodeRef, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION) - .equals(ClassificationLevelManager.UNCLASSIFIED_ID)) - { - return super.shareContent(nodeRef); - } - else - { - throw new IllegalStateException("Unable to share classified content"); - } - } -} \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationConstraintTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationConstraintTest.java deleted file mode 100644 index 8e01ee3306..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationConstraintTest.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; -import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.authority.AuthorityDAO; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.GUID; -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; - -/** - * Integration tests that require the constraints to be executed by a user other than Admin. - * - * @author Tom Page - * @since 2.4.a - */ -public class ClassificationConstraintTest implements RMPermissionModel -{ - /* test data */ - private static final String CLASSIFICATION_REASON = "Test Reason 1"; - private static final String CLASSIFIED_BY = "classified by text"; - private static final String RECORD_NAME = "recordname.txt"; - - /* Application context */ - protected String[] getConfigLocations() - { - return new String[] - { - "classpath:alfresco/application-context.xml", - "classpath:test-context.xml" - }; - } - private ApplicationContext applicationContext; - - /** Common test utils */ - private CommonRMTestUtils utils; - - /* Services */ - private NodeService nodeService; - private MutableAuthenticationService authenticationService; - private SiteService siteService; - private PersonService personService; - - /* RM Services */ - private FilePlanRoleService filePlanRoleService; - private FilePlanPermissionService filePlanPermissionService; - private FilePlanService filePlanService; - private RecordFolderService recordFolderService; - private SecurityClearanceService securityClearanceService; - private ContentClassificationService contentClassificationService; - - /* test data */ - private String siteId; - private NodeRef filePlan; - private NodeRef rmContainer; - private NodeRef rmFolder; - - /** Load the application context and create the test data. */ - @Before - public void setUp() throws Exception - { - // Get the application context - applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations()); - utils = new CommonRMTestUtils(applicationContext); - - // Initialise the service beans - initServices(); - - // Setup test data - setupTestData(); - } - - /** Initialise the service beans. */ - protected void initServices() - { - // Get services - nodeService = (NodeService)applicationContext.getBean("NodeService"); - siteService = (SiteService)this.applicationContext.getBean("SiteService"); - authenticationService = (MutableAuthenticationService)this.applicationContext.getBean("AuthenticationService"); - personService = (PersonService)this.applicationContext.getBean("PersonService"); - - // Get RM services - filePlanRoleService = (FilePlanRoleService)this.applicationContext.getBean("FilePlanRoleService"); - filePlanPermissionService = (FilePlanPermissionService)this.applicationContext.getBean("FilePlanPermissionService"); - filePlanService = (FilePlanService) applicationContext.getBean("FilePlanService"); - recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService"); - securityClearanceService = (SecurityClearanceService) applicationContext.getBean("SecurityClearanceService"); - contentClassificationService = (ContentClassificationService) applicationContext.getBean("ContentClassificationService"); - } - - /** Setup test data for tests */ - protected void setupTestData() - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - public Void doWork() - { - AuthorityDAO authDao = (AuthorityDAO)applicationContext.getBean("authorityDAO"); - if (!authDao.authorityExists(AuthenticationUtil.getSystemUserName())) - { - createPerson(AuthenticationUtil.getSystemUserName(), false); - } - assertTrue("No person object for System available.", authDao.authorityExists(AuthenticationUtil.getSystemUserName())); - - siteId = GUID.generate(); - siteService.createSite( - "rm-site-dashboard", - siteId, - "title", - "descrition", - SiteVisibility.PUBLIC, - RecordsManagementModel.TYPE_RM_SITE); - - filePlan = siteService.getContainer(siteId, RmSiteType.COMPONENT_DOCUMENT_LIBRARY); - assertNotNull("Site document library container was not created successfully.", filePlan); - - // Create RM container - rmContainer = filePlanService.createRecordCategory(filePlan, "rmContainer"); - assertNotNull("Could not create rm container", rmContainer); - - // Create RM folder - rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder"); - assertNotNull("Could not create rm folder", rmFolder); - - return null; - } - }); - } - - /** - * Mid-level user further downgrading a downgraded record. - *

- * RM-2502

-     * Given I have secret clearance
-     * And a record has an initial classification of top secret
-     * And the record has a current classification of secret
-     * When I try to downgrade the record to confidential
-     * Then I am successful.
-     * 
- */ - @Test - public void testInitialClassificationConstraint() - { - // Given I set up some test data (admin at TS, midLevelUser at S and a new record). - final String midLevelUser = GUID.generate(); - final NodeRef record = AuthenticationUtil.runAsSystem(new RunAsWork() - { - public NodeRef doWork() - { - // Ensure admin is TS cleared. - securityClearanceService.setUserSecurityClearance(AuthenticationUtil.getAdminUserName(), "TS"); - // Create user with S clearance. - createPerson(midLevelUser, true); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, midLevelUser); - filePlanPermissionService.setPermission(rmContainer, midLevelUser, FILING); - securityClearanceService.setUserSecurityClearance(midLevelUser, "S"); - // Create a record to be classified during the test. - return utils.createRecord(rmFolder, RECORD_NAME); - } - }); - - // And admin creates a downgraded record. - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - // Create a TS record and downgrade it to S. - classifyAs(record, "TS"); - classifyAs(record, "S"); - - assertTrue("Record should have been classified.", - nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED)); - assertEquals("Record have initial classification of 'TS'.", "TS", - nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); - assertEquals("Record should be 'S' classified.", "S", - nodeService.getProperty(record, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); - return null; - } - }, AuthenticationUtil.getAdminUserName()); - - // When the mid-level user downgrades the record to C. - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - // Check that the mid-clearance user can further downgrade the classification (even though the initial - // classification was above their clearance). - classifyAs(record, "C"); - return null; - } - }, midLevelUser); - - // Then the record is classified at C (with initial classification TS). - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() - { - assertTrue("Record should still be classified.", - nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED)); - assertEquals("Record have initial classification of 'TS'.", "TS", - nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); - assertEquals("Record should be 'C' classified.", "C", - nodeService.getProperty(record, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); - return null; - } - }, AuthenticationUtil.getAdminUserName()); - } - - /** - * Util method to create a person. - * - * @param userName user name - * @param createAuth Whether to give the user a password or not. - * @return NodeRef user node reference - */ - private NodeRef createPerson(String userName, boolean createAuth) - { - if (createAuth) - { - authenticationService.createAuthentication(userName, "password".toCharArray()); - } - Map properties = new HashMap(); - properties.put(ContentModel.PROP_USERNAME, userName); - return personService.createPerson(properties); - } - - /** - * Classify the given node. - * - * @param node The node to classify. - * @param level The id of the classification level to use. - */ - private void classifyAs(final NodeRef node, final String level) - { - ClassificationAspectProperties propertiesDTO = new ClassificationAspectProperties(); - propertiesDTO.setClassificationLevelId(level); - propertiesDTO.setClassifiedBy(CLASSIFIED_BY); - propertiesDTO.setClassificationReasonIds(Collections.singleton(CLASSIFICATION_REASON)); - contentClassificationService.editClassifiedContent(propertiesDTO, node); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationLevelsTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationLevelsTest.java deleted file mode 100644 index 5566b209c0..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationLevelsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Classification level integration test - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassificationLevelsTest extends BaseRMTestCase -{ - public void testClassificationLevels() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - public void when() throws Exception - { - // Server is up and running - } - - public void then() throws Exception - { - List levels = classificationSchemeService.getClassificationLevels(); - List expectedLevels = Arrays.asList( - new ClassificationLevel("TS", "rm.caveat.classification.mark.ts.label.label"), - new ClassificationLevel("S", "rm.caveat.classification.mark.s.label.label"), - new ClassificationLevel("C", "rm.caveat.classification.mark.c.label.label"), - ClassificationLevelManager.UNCLASSIFIED); - assertEquals(levels, expectedLevels); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationReasonsTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationReasonsTest.java deleted file mode 100644 index b77a353a7c..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassificationReasonsTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReason; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Tests of classification reason handling. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationReasonsTest extends BaseRMTestCase -{ - /** - * Given the default classification reasons config file is on the classpath When the system has finished starting up - * Then the classification service exposes the classification reasons. - *

- * Note that this test requires a clean db, as otherwise the classification scheme service will use the persisted - * classification reasons in preference to those given on the classpath (see the logic in - * {@link ClassificationServiceBootstrap#initConfiguredClassificationReasons()}). - */ - public void testLoadBootstrappedClassificationReasons() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - public void given() throws Exception - { - // NOOP: The default classification reasons config file is on the classpath. - } - - public void when() throws Exception - { - // NOOP: The system has finished starting up. - } - - public void then() throws Exception - { - // Check the classification scheme service exposes the classification reasons. - List reasons = classificationSchemeService.getClassificationReasons(); - assertNotNull(reasons); - assertEquals("The default classification reasons in test/resources/alfresco/module/" - + "org_alfresco_module_rm/classification/rm-classification-reasons.json " - + "contains four reasons.", 4, reasons.size()); - // Check a couple of fields in the loaded data. - assertEquals("Unexpected id for the first test reason.", "Test Reason 1", reasons.get(0).getId()); - assertEquals("Unexpected displayLabelKey for the fourth test reason.", - "rm.test.classification-reason.foreignRelations", reasons.get(3).getDisplayLabel()); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java deleted file mode 100644 index b808fb7b47..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification; - -import java.util.Collections; -import java.util.Date; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingDowngradeInstructions; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.GUID; - -/** - * Classification level integration test - * - * @author Roy Wetherall - * @since 2.4.a - */ -public class ClassifyTest extends BaseRMTestCase -{ - /** test data */ - private static final String CLASSIFICATION_LEVEL = "TS"; - private static final String LOWER_CLASSIFICATION_LEVEL = "S"; - private static final String CLASSIFICATION_REASON = "Test Reason 1"; - private static final String CLASSIFICATION_AGENCY = "classification agency"; - private static final String CLASSIFIED_BY = "classified by text"; - private static final String RECORD_NAME = "recordname.txt"; - - private ClassificationAspectProperties propertiesDTO; - - @Override - public void setUp() throws Exception - { - super.setUp(); - propertiesDTO = new ClassificationAspectProperties(); - propertiesDTO.setClassificationLevelId(CLASSIFICATION_LEVEL); - propertiesDTO.setClassifiedBy(CLASSIFIED_BY); - propertiesDTO.setClassificationAgency(CLASSIFICATION_AGENCY); - propertiesDTO.setClassificationReasonIds(Collections.singleton(CLASSIFICATION_REASON)); - } - - /** - * Given that a record is frozen - * And unclassified - * When I set the initial classification - * Then a AccessDeniedException is raised - */ - public void testClassifyFrozenRecord() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) - { - private NodeRef record; - - public void given() throws Exception - { - record = utils.createRecord(rmFolder, RECORD_NAME); - - NodeRef hold = holdService.createHold(filePlan, "my hold", "for test", "for test"); - holdService.addToHold(hold, record); - } - - public void when() throws Exception - { - contentClassificationService.classifyContent(propertiesDTO, record); - } - }); - } - - /** - * Given that a record is complete - * And unclassified - * Then I can successfully set the initial classification - */ - public void testClassifyCompleteRecord() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - - public void given() throws Exception - { - record = utils.createRecord(rmFolder, RECORD_NAME); - utils.completeRecord(record); - } - - public void when() throws Exception - { - contentClassificationService.classifyContent(propertiesDTO, record); - } - - public void then() throws Exception - { - assertTrue(nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED)); - assertEquals(CLASSIFICATION_LEVEL, (String) nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); - assertEquals(CLASSIFICATION_LEVEL, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); - assertEquals(CLASSIFICATION_AGENCY, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY)); - assertEquals(CLASSIFIED_BY, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFIED_BY)); - assertEquals(Collections.singletonList(CLASSIFICATION_REASON), nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS)); - } - }); - } - - /** - * Given I have top secret clearance - * When I try to classify content as top secret - * Then the content is classified. - */ - public void testClassifyContent() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private String myUser; - private NodeRef record; - - public void given() throws Exception - { - // Create RM Manager user - myUser = GUID.generate(); - createPerson(myUser); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, myUser); - filePlanPermissionService.setPermission(rmContainer, myUser, FILING); - // Give user clearance. - securityClearanceService.setUserSecurityClearance(myUser, CLASSIFICATION_LEVEL); - - // Create a record for the user to classify. - record = utils.createRecord(rmFolder, RECORD_NAME); - } - - public void when() throws Exception - { - // As myUser: - doTestInTransaction(new Test() - { - @Override - public Void run() - { - contentClassificationService.classifyContent(propertiesDTO, record); - return null; - } - }, myUser); - } - - public void then() throws Exception - { - assertTrue("Record should have been classified.", - nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED)); - assertEquals("Record should be classified as top secret.", CLASSIFICATION_LEVEL, - nodeService.getProperty(record, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); - } - }); - } - - /** - * Given I have secret clearance - * When I call the classify content API directly using the level "top secret" - * Then I receive an error that the level could not be found. - */ - public void testClearanceNecessaryToClassifyContent() - { - doBehaviourDrivenTest(new BehaviourDrivenTest(LevelIdNotFound.class) - { - private String myUser; - private NodeRef record; - - public void given() throws Exception - { - // Create RM Manager user - myUser = GUID.generate(); - createPerson(myUser); - filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, myUser); - filePlanPermissionService.setPermission(rmContainer, myUser, FILING); - // Give user clearance. - securityClearanceService.setUserSecurityClearance(myUser, LOWER_CLASSIFICATION_LEVEL); - - // Create a record for the user to classify. - record = utils.createRecord(rmFolder, RECORD_NAME); - } - - public void when() throws Exception - { - // As myUser: - doTestInTransaction(new Test() - { - @Override - public Void run() - { - contentClassificationService.classifyContent(propertiesDTO, record); - return null; - } - }, myUser); - } - }); - } - - /** - * Downgrade instructions are mandatory when downgrade date is set. - *

- * RM-2409

-     * Given I am a cleared user
-     * And I am classifying the content for the first time
-     * And I enter a downgrade date and/or event
-     * When I attempt to save the classification information
-     * Then I will be informed that downgrade instructions are mandatory when the downgrade date and/or event are set
-     * And the save will not be successful
-     * 
- */ - public void testMissingDowngradeInstructions() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(MissingDowngradeInstructions.class) - { - private NodeRef record; - - public void given() throws Exception - { - record = utils.createRecord(rmFolder, RECORD_NAME); - } - - public void when() throws Exception - { - propertiesDTO.setDowngradeDate(new Date()); - assertNull("Downgrade instructions should be null.", propertiesDTO.getDowngradeInstructions()); - contentClassificationService.classifyContent(propertiesDTO, record); - } - - public void after() - { - assertFalse("Record should not have been classified.", - nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED)); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ExemptionCategoriesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ExemptionCategoriesTest.java deleted file mode 100644 index 825ac78fba..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ExemptionCategoriesTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap; -import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.springframework.context.ApplicationEvent; - -/** - * Tests of exemption category loading. - * - * @author tpage - * @since 2.4.a - */ -public class ExemptionCategoriesTest extends BaseRMTestCase -{ - /** - * Initial exemption category loading. - *

- * RM-2321

-     * Given that I have a clean system
-     * When I boot it for the first time
-     * Then the default set of exemption categories are loaded
-     * And are available throughout the application
-     * 

- * Note that this test requires a clean db, as otherwise the classification scheme service will use - * the persisted exemption categories in preference to those given on the classpath (see the logic in - * {@link ClassificationServiceBootstrap#onBootstrap(ApplicationEvent)}). - */ - public void testLoadBootstrappedExemptionCategories() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - public void given() throws Exception - { - // NOOP: I have a clean system. - } - - public void when() throws Exception - { - // NOOP: I boot it for the first time. - } - - public void then() throws Exception - { - // Check the classification scheme service exposes the classification reasons. - List exemptionCategories = classificationSchemeService.getExemptionCategories(); - assertNotNull(exemptionCategories); - assertEquals("The default exemption categories in test/resources/alfresco/module/" - + "org_alfresco_module_rm/classification/rm-exemption-categories.json " - + "contains three categories.", 3, exemptionCategories.size()); - // Check a couple of fields in the loaded data. - assertEquals("Unexpected id for the first test category.", "Test Category 1", exemptionCategories.get(0).getId()); - assertEquals("Unexpected displayLabelKey for the third test category.", - "rm.test.exemption-category.three", exemptionCategories.get(2).getDisplayLabel()); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/SecurityClearanceTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/SecurityClearanceTest.java deleted file mode 100644 index 7b7d84cf8a..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/SecurityClearanceTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Application context tests for the security clearance service. - * - * @author tpage - */ -public class SecurityClearanceTest extends BaseRMTestCase -{ - @Override - protected boolean isUserTest() - { - return true; - }; - - /** - * Given I am admin - * When I try to give a user maximum clearance - * Then I am successful. - */ - public void testGiveClearance() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private SecurityClearance securityClearance; - - public void when() throws Exception - { - securityClearance = securityClearanceService.setUserSecurityClearance(userName, "TS"); - } - - public void then() throws Exception - { - ClearanceLevel clearanceLevel = securityClearance.getClearanceLevel(); - ClassificationLevel highestClassificationLevel = clearanceLevel.getHighestClassificationLevel(); - assertEquals("TS", highestClassificationLevel.getId()); - } - }); - } - - /** - * Given I am a user with S access - * And I try to give another user TS access - * Then an exception is thrown. - */ - public void testCantGiveClearance() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest(LevelIdNotFound.class) - { - public void given() throws Exception - { - securityClearanceService.setUserSecurityClearance(userName, "S"); - } - - public void when() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - securityClearanceService.setUserSecurityClearance(rmUserName, "TS"); - return null; - } - }, userName); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/BrowseClassificationEnforcementTestBase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/BrowseClassificationEnforcementTestBase.java deleted file mode 100644 index f4e4767737..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/BrowseClassificationEnforcementTestBase.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.util.GUID.generate; - -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Base class for classification enforcement tests for the browse action - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public abstract class BrowseClassificationEnforcementTestBase extends BaseRMTestCase -{ - protected String testUser; - protected static final String TOP_SECRET_ID = "TS"; - protected static final String SECRET_ID = "S"; - protected static final String REASON = "Test Reason 1"; - /** Classified properties for top secret. */ - protected ClassificationAspectProperties propertiesDTO1; - /** Classified properties for secret. */ - protected ClassificationAspectProperties propertiesDTO2; - - @Override - public void setUp() throws Exception - { - super.setUp(); - propertiesDTO1 = new ClassificationAspectProperties(); - propertiesDTO1.setClassificationLevelId(TOP_SECRET_ID); - propertiesDTO1.setClassifiedBy(generate()); - propertiesDTO1.setClassificationAgency(generate()); - propertiesDTO1.setClassificationReasonIds(Collections.singleton(REASON)); - propertiesDTO2 = new ClassificationAspectProperties(); - propertiesDTO2.setClassificationLevelId(SECRET_ID); - propertiesDTO2.setClassifiedBy(generate()); - propertiesDTO2.setClassificationAgency(generate()); - propertiesDTO2.setClassificationReasonIds(Collections.singleton(REASON)); - } - - protected List browse(NodeRef folder, String userName) - { - return doTestInTransaction(new Test>() - { - @Override - public List run() - { - return nodeService.getChildAssocs(folder); - } - }, userName); - } - - protected List browseAsAdmin(NodeRef folder) - { - return browse(folder, getAdminUserName()); - } - - protected List browseAsTestUser(NodeRef folder) - { - return browse(folder, testUser); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/ClassificationEnforcementPreMethodInvocationTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/ClassificationEnforcementPreMethodInvocationTest.java deleted file mode 100644 index bc81edc8a6..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/ClassificationEnforcementPreMethodInvocationTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static org.alfresco.repo.site.SiteModel.SITE_MANAGER; -import static org.alfresco.util.GUID.generate; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Classification enforcement pre method invocation test - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassificationEnforcementPreMethodInvocationTest extends BaseRMTestCase -{ - private static final String TOP_SECRET_ID = "TS"; - private static final String REASON = "Test Reason 1"; - - private ClassificationAspectProperties propertiesDTO; - - @Override - public void setUp() throws Exception - { - super.setUp(); - propertiesDTO = new ClassificationAspectProperties(); - propertiesDTO.setClassificationLevelId(TOP_SECRET_ID); - propertiesDTO.setClassifiedBy(generate()); - propertiesDTO.setClassificationAgency(generate()); - propertiesDTO.setClassificationReasonIds(Collections.singleton(REASON)); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testClassificationEnforcementPreMethodInvocation() - { - /** - * Given that I am a site manager and not cleared to see a document - * When I try to - * - set a property on that document - * - set properties on that document - * - get property from that document - * - copy the document - * - move document - * Then a classification exception will be thrown - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private String testUser; - private NodeRef folder1; - private NodeRef folder2; - private NodeRef doc; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - - folder1 = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - folder2 = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc = fileFolderService.create(folder1, generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO, doc); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - doTestInTransaction(new FailureTest(AccessDeniedException.class) - { - @Override - public void run() throws Exception - { - nodeService.setProperty(doc, PROP_ADDRESSEE, generate()); - } - }, testUser); - - doTestInTransaction(new FailureTest(AccessDeniedException.class) - { - @Override - public void run() - { - Map properties = new HashMap(); - nodeService.setProperties(doc, properties); - } - }, testUser); - - doTestInTransaction(new FailureTest(AccessDeniedException.class) - { - @Override - public void run() throws Exception - { - nodeService.getProperty(doc, PROP_ADDRESSEE); - } - }, testUser); - - doTestInTransaction(new FailureTest(AccessDeniedException.class) - { - @Override - public void run() throws Exception - { - nodeService.getProperties(doc); - } - }, testUser); - - doTestInTransaction(new FailureTest(AccessDeniedException.class) - { - @Override - public void run() throws Exception - { - fileFolderService.copy(doc, folder2, null); - } - }, testUser); - - doTestInTransaction(new FailureTest(AccessDeniedException.class) - { - @Override - public void run() throws Exception - { - fileFolderService.move(doc, folder2, null); - } - }, testUser); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java deleted file mode 100644 index 7cc1e95e6d..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static com.google.common.collect.Lists.newArrayList; -import static org.alfresco.repo.site.SiteModel.SITE_MANAGER; -import static org.alfresco.util.GUID.generate; - -import java.util.List; - -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Tests for enforcement of classification when browsing documents in the document library - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class DocumentBrowseClassificationEnforcementTest extends BrowseClassificationEnforcementTestBase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testUserWithNoSecurityClearance() - { - /** - * Given that a test user without security clearance exists - * and two documents are created in the document library - * and one of the documents is classified with the highest security level - * - * When I browse the document library as admin - * Then I will see both documents - * - * When I browse the document library as the test user - * Then I will only see the unclassified document - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef folder; - private NodeRef doc1; - private NodeRef doc2; - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - - folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO1, doc1); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = browseAsAdmin(folder); - resultsForTestUser = browseAsTestUser(folder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(2, resultsForAdmin.size()); - - List docs = newArrayList(doc1, doc2); - assertTrue(docs.contains(resultsForAdmin.get(0).getChildRef())); - assertTrue(docs.contains(resultsForAdmin.get(1).getChildRef())); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(1, resultsForTestUser.size()); - assertEquals(doc2, resultsForTestUser.get(0).getChildRef()); - - return null; - } - }, testUser); - } - }); - } - - public void testUserWithMidlevelSecurityClearance() - { - /** - * Given that a test user with mid-level security clearance exists - * and three documents are created in the document library - * and one of the documents is classified with the highest security level - * and another document is classified with the mid-level security level - * - * When I browse the document library as admin - * Then I will see all three documents - * - * When I browse the document library as the test user - * Then I will see the unclassified document - * and the document with the mid-level classification - * and I won't be able to see the document with the classification greater than my clearance level - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef folder; - private NodeRef doc1; - private NodeRef doc2; - private NodeRef doc3; - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - securityClearanceService.setUserSecurityClearance(testUser, SECRET_ID); - - folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO1, doc1); - contentClassificationService.classifyContent(propertiesDTO2, doc2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = browseAsAdmin(folder); - resultsForTestUser = browseAsTestUser(folder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - - List docs = newArrayList(doc1, doc2, doc3); - assertTrue(docs.contains(resultsForAdmin.get(0).getChildRef())); - assertTrue(docs.contains(resultsForAdmin.get(1).getChildRef())); - assertTrue(docs.contains(resultsForAdmin.get(2).getChildRef())); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(2, resultsForTestUser.size()); - - List docs = newArrayList(doc2, doc3); - assertTrue(docs.contains(resultsForTestUser.get(0).getChildRef())); - assertTrue(docs.contains(resultsForTestUser.get(1).getChildRef())); - - return null; - } - }, testUser); - } - }); - } - - public void testUseWithHighestLevelSecurityClearance() - { - /** - * Given that a test user with highest level security clearance exists - * and three documents are created in the document library - * and one of the documents is classified with the highest security level - * and another document is classified with the mid-level security level - * - * When I browse the document library as admin - * The I will see all three documents - * - * When I browse the document library as the test user - * The I will see all three documents - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef folder; - private NodeRef doc1; - private NodeRef doc2; - private NodeRef doc3; - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - securityClearanceService.setUserSecurityClearance(testUser, TOP_SECRET_ID); - - folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO1, doc1); - contentClassificationService.classifyContent(propertiesDTO2, doc2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = browseAsAdmin(folder); - resultsForTestUser = browseAsTestUser(folder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - - List docs = newArrayList(doc1, doc2, doc3); - assertTrue(docs.contains(resultsForAdmin.get(0).getChildRef())); - assertTrue(docs.contains(resultsForAdmin.get(1).getChildRef())); - assertTrue(docs.contains(resultsForAdmin.get(2).getChildRef())); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(3, resultsForTestUser.size()); - - List docs = newArrayList(doc1, doc2, doc3); - assertTrue(docs.contains(resultsForTestUser.get(0).getChildRef())); - assertTrue(docs.contains(resultsForTestUser.get(1).getChildRef())); - assertTrue(docs.contains(resultsForTestUser.get(2).getChildRef())); - - return null; - } - }, testUser); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java deleted file mode 100644 index 982d0075b2..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static java.lang.Integer.MAX_VALUE; -import static org.alfresco.repo.site.SiteModel.SITE_MANAGER; -import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; -import static org.alfresco.service.cmr.search.SearchService.LANGUAGE_FTS_ALFRESCO; -import static org.alfresco.util.GUID.generate; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.search.SearchParameters; - -/** - * Tests for enforcement of classification when searching documents in the document library - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class DocumentSearchClassificationEnforcementTest extends SearchClassificationEnforcementTestBase -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest() - */ - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - public void testUserWithNoSecurityClearance() - { - /** - * Given that a test user without security clearance exists - * and two documents are created in the document library - * and one of the documents is classified with the highest security level - * - * When I search for the documents as admin - * Then I will see both documents - * - * When I search for the documents as the test user - * Then I will only see the unclassified document - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef folder; - private NodeRef doc1; - private NodeRef doc2; - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - - folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc1 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO1, doc1); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = searchAsAdmin(searchQuery); - resultsForTestUser = searchAsTestUser(searchQuery); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(2, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(doc1)); - assertTrue(resultsForAdmin.contains(doc2)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(1, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(doc2)); - - return null; - } - }, testUser); - } - }); - } - - public void testUserWithMidlevelSecurityClearance() - { - /** - * Given that a test user with mid-level security clearance exists - * and three documents are created in the document library - * and one of the documents is classified with the highest security level - * and another document is classified with the mid-level security level - * - * When I search for the documents as admin - * Then I will see all three documents - * - * When I search for the documents as the test user - * Then I will see the unclassified document - * and the document with the mid-level classification - * and I won't be able to see the document with the classification greater than my clearance level - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef folder; - private NodeRef doc1; - private NodeRef doc2; - private NodeRef doc3; - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - securityClearanceService.setUserSecurityClearance(testUser, SECRET_ID); - - folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc1 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO1, doc1); - contentClassificationService.classifyContent(propertiesDTO2, doc2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = searchAsAdmin(searchQuery); - resultsForTestUser = searchAsTestUser(searchQuery); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(doc1)); - assertTrue(resultsForAdmin.contains(doc2)); - assertTrue(resultsForAdmin.contains(doc3)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(2, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(doc2)); - assertTrue(resultsForTestUser.contains(doc3)); - - return null; - } - }, testUser); - } - }); - } - - public void testUseWithHighestLevelSecurityClearance() - { - /** - * Given that a test user with highest level security clearance exists - * and three documents are created in the document library - * and one of the documents is classified with the highest security level - * and another document is classified with the mid-level security level - * - * When I search for the documents as admin - * Then I will see all three documents - * - * When I search for the documents as the test user - * Then I will see all three documents - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef folder; - private NodeRef doc1; - private NodeRef doc2; - private NodeRef doc3; - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - siteService.setMembership(collabSiteId, testUser, SITE_MANAGER); - securityClearanceService.setUserSecurityClearance(testUser, TOP_SECRET_ID); - - folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); - doc1 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - - contentClassificationService.classifyContent(propertiesDTO1, doc1); - contentClassificationService.classifyContent(propertiesDTO2, doc2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = searchAsAdmin(searchQuery); - resultsForTestUser = searchAsTestUser(searchQuery); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(doc1)); - assertTrue(resultsForAdmin.contains(doc2)); - assertTrue(resultsForAdmin.contains(doc3)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(3, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(doc1)); - assertTrue(resultsForTestUser.contains(doc2)); - assertTrue(resultsForTestUser.contains(doc3)); - - return null; - } - }, testUser); - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor.SearchClassificationEnforcementTestBase#search(java.lang.String) - */ - @Override - protected List search(String searchQuery) - { - SearchParameters searchParameters = new SearchParameters(); - searchParameters.setQuery("cm:name:" + searchQuery + "*"); - searchParameters.setLanguage(LANGUAGE_FTS_ALFRESCO); - searchParameters.addStore(STORE_REF_WORKSPACE_SPACESSTORE); - searchParameters.setMaxItems(MAX_VALUE); - return searchService.query(searchParameters).getNodeRefs(); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java deleted file mode 100644 index e8704cf100..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static com.google.common.collect.Lists.newArrayList; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_ADMIN; -import static org.alfresco.util.GUID.generate; - -import java.util.List; - -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Enforcement of classification when browsing records in the file plan - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class RecordBrowseClassificationEnforcementTest extends BrowseClassificationEnforcementTestBase -{ - public void testUserWithNoSecurityClearance() - { - /** - * Given that a test user without security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and two records are created in the file plan - * and one of the records is classified with the highest security level - * - * When I browse the file plan as admin - * Then I will see both documents - * - * When I browse the file plan as the test user - * Then I will only see the unclassified record - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, generate()); - record2 = utils.createRecord(folder, generate()); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = browseAsAdmin(folder); - resultsForTestUser = browseAsTestUser(folder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(2, resultsForAdmin.size()); - - List records = newArrayList(record1, record2); - assertTrue(records.contains(resultsForAdmin.get(0).getChildRef())); - assertTrue(records.contains(resultsForAdmin.get(1).getChildRef())); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(1, resultsForTestUser.size()); - assertEquals(record2, resultsForTestUser.get(0).getChildRef()); - - return null; - } - }, testUser); - } - }); - } - - public void testUserWithMidlevelSecurityClearance() - { - /** - * Given that a test user with mid-level security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and three records are created in the file plan - * and one of the records is classified with the highest security level - * and another record is classified with the mid-level security level - * - * When I browse the file plan as admin - * Then I will see all three records - * - * When I browse the file plan as the test user - * Then I will see the unclassified record - * and the record with the mid-level classification - * and I won't be able to see the record with the classification greater than my clearance level - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private NodeRef record3; - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - securityClearanceService.setUserSecurityClearance(testUser, SECRET_ID); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, generate()); - record2 = utils.createRecord(folder, generate()); - record3 = utils.createRecord(folder, generate()); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - contentClassificationService.classifyContent(propertiesDTO2, record2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = browseAsAdmin(folder); - resultsForTestUser = browseAsTestUser(folder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - - List records = newArrayList(record1, record2, record3); - assertTrue(records.contains(resultsForAdmin.get(0).getChildRef())); - assertTrue(records.contains(resultsForAdmin.get(1).getChildRef())); - assertTrue(records.contains(resultsForAdmin.get(2).getChildRef())); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(2, resultsForTestUser.size()); - - List records = newArrayList(record2, record3); - assertTrue(records.contains(resultsForTestUser.get(0).getChildRef())); - assertTrue(records.contains(resultsForTestUser.get(1).getChildRef())); - - return null; - } - }, testUser); - } - }); - } - - public void testUseWithHighestLevelSecurityClearance() - { - /** - * Given that a test user with highest level security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and three records are created in the file plan - * and one of the records is classified with the highest security level - * and another record is classified with the mid-level security level - * - * When I browse the file plan as admin - * The I will see all three records - * - * When I browse the file plan as the test user - * The I will see all three records - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private NodeRef record3; - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - securityClearanceService.setUserSecurityClearance(testUser, TOP_SECRET_ID); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, generate()); - record2 = utils.createRecord(folder, generate()); - record3 = utils.createRecord(folder, generate()); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - contentClassificationService.classifyContent(propertiesDTO2, record2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = browseAsAdmin(folder); - resultsForTestUser = browseAsTestUser(folder); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - - List records = newArrayList(record1, record2, record3); - assertTrue(records.contains(resultsForAdmin.get(0).getChildRef())); - assertTrue(records.contains(resultsForAdmin.get(1).getChildRef())); - assertTrue(records.contains(resultsForAdmin.get(2).getChildRef())); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(3, resultsForTestUser.size()); - - List records = newArrayList(record1, record2, record3); - assertTrue(records.contains(resultsForTestUser.get(0).getChildRef())); - assertTrue(records.contains(resultsForTestUser.get(1).getChildRef())); - assertTrue(records.contains(resultsForTestUser.get(2).getChildRef())); - - return null; - } - }, testUser); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java deleted file mode 100644 index 1560f3139c..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_ADMIN; -import static org.alfresco.util.GUID.generate; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * Enforcement of classification when searching records in the file plan - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class RecordSearchClassificationEnforcementTest extends SearchClassificationEnforcementTestBase -{ - public void testUserWithNoSecurityClearance() - { - /** - * Given that a test user without security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and two records are created in the file plan - * and one of the records is classified with the highest security level - * - * When I search for the records as admin - * Then I will see both records - * - * When I search for the records as the test user - * Then I will only see the unclassified record - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, searchQuery + generate()); - record2 = utils.createRecord(folder, searchQuery + generate()); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = searchAsAdmin(searchQuery); - resultsForTestUser = searchAsTestUser(searchQuery); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(2, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(record1)); - assertTrue(resultsForAdmin.contains(record2)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(1, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(record2)); - - return null; - } - }, testUser); - } - }); - } - - public void testUserWithMidlevelSecurityClearance() - { - /** - * Given that a test user with mid-level security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and three records are created in the file plan - * and one of the records is classified with the highest security level - * and another record is classified with the mid-level security level - * - * When I search for the records as admin - * The I will see all three records - * - * When I search for the records as the test user - * Then I will see the unclassified document - * and the document with the mid-level classification - * and I won't be able to see the document with the classification greater than my clearance level - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private NodeRef record3; - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - securityClearanceService.setUserSecurityClearance(testUser, SECRET_ID); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, searchQuery + generate()); - record2 = utils.createRecord(folder, searchQuery + generate()); - record3 = utils.createRecord(folder, searchQuery + generate()); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - contentClassificationService.classifyContent(propertiesDTO2, record2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = searchAsAdmin(searchQuery); - resultsForTestUser = searchAsTestUser(searchQuery); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(record1)); - assertTrue(resultsForAdmin.contains(record2)); - assertTrue(resultsForAdmin.contains(record3)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(2, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(record2)); - assertTrue(resultsForTestUser.contains(record3)); - - return null; - } - }, testUser); - } - }); - } - - public void testUseWithHighestLevelSecurityClearance() - { - /** - * Given that a test user with highest level security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and three records are created in the file plan - * and one of the records is classified with the highest security level - * and another record is classified with the mid-level security level - * - * When I search for the records as admin - * The I will see all three records - * - * When I search for the records as the test user - * The I will see all three records - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private NodeRef record3; - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - securityClearanceService.setUserSecurityClearance(testUser, TOP_SECRET_ID); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, searchQuery + generate()); - record2 = utils.createRecord(folder, searchQuery + generate()); - record3 = utils.createRecord(folder, searchQuery + generate()); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - contentClassificationService.classifyContent(propertiesDTO2, record2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - resultsForAdmin = searchAsAdmin(searchQuery); - resultsForTestUser = searchAsTestUser(searchQuery); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(3, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(record1)); - assertTrue(resultsForAdmin.contains(record2)); - assertTrue(resultsForAdmin.contains(record3)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(3, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(record1)); - assertTrue(resultsForTestUser.contains(record2)); - assertTrue(resultsForTestUser.contains(record3)); - - return null; - } - }, testUser); - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor.SearchClassificationEnforcementTestBase#search(java.lang.String) - */ - @Override - protected List search(String searchQuery) - { - String query = "cm:name:" + searchQuery + "*"; - RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); - searchParameters.setIncludeUndeclaredRecords(true); - List> result = rmSearchService.search(siteId, query, searchParameters); - - List filteredResult = new ArrayList<>(); - for (Pair pair : result) - { - filteredResult.add(pair.getSecond()); - } - - return filteredResult; - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java deleted file mode 100644 index 0f87c07316..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static com.google.common.collect.Lists.newArrayList; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_USER; -import static org.alfresco.util.GUID.generate; - -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Enforcement of classification for records with relationship - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class RelationshipClassificationEnforcementTest extends BaseRMTestCase -{ - private static final String TOP_SECRET_ID = "TS"; - private static final String CONFIDENTIAL_ID = "C"; - private static final String REASON = "Test Reason 1"; - private ClassificationAspectProperties propertiesDTO; - - @Override - public void setUp() throws Exception - { - super.setUp(); - propertiesDTO = new ClassificationAspectProperties(); - propertiesDTO.setClassificationLevelId(TOP_SECRET_ID); - propertiesDTO.setClassifiedBy(generate()); - propertiesDTO.setClassificationAgency(generate()); - propertiesDTO.setClassificationReasonIds(Collections.singleton(REASON)); - } - - public void testRelationshipClassification() - { - /** - * Given a test user has been created - * and added to the RM user role - * and a category, a folder and two records have been created - * - * When the user has been granted filing permissions - * and confidential clearance for the test user has been set - * and one of the records has been classified as top secret - * and a relationship between those two records has been created - * - * Then the admin user should see both records in the folder - * and the admin user should see in the relationship table - * (in the details page of the record) the other record - * - * and the test user should see only the unclassified record in the same folder - * and the relationship table should be empty. - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private String myUser; - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - myUser = generate(); - createPerson(myUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_USER, myUser); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, generate()); - record2 = utils.createRecord(folder, generate()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - filePlanPermissionService.setPermission(category, myUser, FILING); - securityClearanceService.setUserSecurityClearance(myUser, CONFIDENTIAL_ID); - contentClassificationService.classifyContent(propertiesDTO, record1); - relationshipService.addRelationship(CUSTOM_REF_RENDITION.getLocalName(), record1, record2); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List childAssocs = nodeService.getChildAssocs(folder); - assertEquals(2, childAssocs.size()); - - List recordList = newArrayList(record1, record2); - assertTrue(recordList.contains(childAssocs.get(0).getChildRef())); - assertTrue(recordList.contains(childAssocs.get(1).getChildRef())); - - Set relationshipsFrom = relationshipService.getRelationshipsFrom(record1); - assertEquals(1, relationshipsFrom.size()); - Relationship relationship1 = relationshipsFrom.iterator().next(); - assertEquals(record1, relationship1.getSource()); - assertEquals(record2, relationship1.getTarget()); - assertEquals(CUSTOM_REF_RENDITION.getLocalName(), relationship1.getUniqueName()); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - List childAssocs = nodeService.getChildAssocs(folder); - assertEquals(1, childAssocs.size()); - assertEquals(record2, childAssocs.get(0).getChildRef()); - - Set relationshipsFrom = relationshipService.getRelationshipsFrom(record2); - assertEquals(0, relationshipsFrom.size()); - - return null; - } - }, myUser); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java deleted file mode 100644 index fe734b73ae..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static java.lang.Integer.MAX_VALUE; -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_ADMIN; -import static org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails.QUERY; -import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; -import static org.alfresco.service.cmr.search.SearchService.LANGUAGE_FTS_ALFRESCO; -import static org.alfresco.util.GUID.generate; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchParameters; -import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.search.SearchParameters; -import org.json.JSONObject; - -/** - * Integration test for saved searches with classification enforcement - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class SavedSearchClassificationEnforcementTest extends SearchClassificationEnforcementTestBase -{ - public void testSavedSearchWithClassificationEnforcement() - { - /** - * Given that a test user with mid-level security clearance exists - * and the test user is added to the RM Admin role - * and a category, a folder and five records are created in the file plan - * and two of the records are classified with the highest security level - * and another record is classified with the mid-level security level - * - * When I view the results of the saved search as admin - * The I will see all five records - * - * When I view the results of the saved search as the test user - * Then I will see the unclassified documents - * and the document with the mid-level classification - * and I won't be able to see the documents with the classification greater than my clearance level - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef category; - private NodeRef folder; - private NodeRef record1; - private NodeRef record2; - private NodeRef record3; - private NodeRef record4; - private NodeRef record5; - private String savedSearchName = generate(); - private String searchQuery = generate(); - private List resultsForAdmin; - private List resultsForTestUser; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - testUser = generate(); - createPerson(testUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_ADMIN, testUser); - securityClearanceService.setUserSecurityClearance(testUser, SECRET_ID); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record1 = utils.createRecord(folder, searchQuery + generate()); - record2 = utils.createRecord(folder, searchQuery + generate()); - record3 = utils.createRecord(folder, searchQuery + generate()); - record4 = utils.createRecord(folder, searchQuery + generate()); - record5 = utils.createRecord(folder, searchQuery + generate()); - - RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); - searchParameters.setIncludeUndeclaredRecords(true); - rmSearchService.saveSearch(siteId, savedSearchName, generate(), searchQuery + "*", searchParameters, true); - - contentClassificationService.classifyContent(propertiesDTO1, record1); - contentClassificationService.classifyContent(propertiesDTO2, record3); - contentClassificationService.classifyContent(propertiesDTO1, record5); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - SavedSearchDetails savedSearchDetails = rmSearchService.getSavedSearch(siteId, savedSearchName); - JSONObject jsonObject = new JSONObject(savedSearchDetails.toJSONString()); - String query = (String) jsonObject.get(QUERY); - - resultsForAdmin = searchAsAdmin(query); - resultsForTestUser = searchAsTestUser(query); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForAdmin); - assertEquals(5, resultsForAdmin.size()); - assertTrue(resultsForAdmin.contains(record1)); - assertTrue(resultsForAdmin.contains(record2)); - assertTrue(resultsForAdmin.contains(record3)); - assertTrue(resultsForAdmin.contains(record4)); - assertTrue(resultsForAdmin.contains(record5)); - - return null; - } - }); - - doTestInTransaction(new Test() - { - @Override - public Void run() - { - assertNotNull(resultsForTestUser); - assertEquals(3, resultsForTestUser.size()); - assertTrue(resultsForTestUser.contains(record2)); - assertTrue(resultsForTestUser.contains(record3)); - assertTrue(resultsForTestUser.contains(record4)); - - return null; - } - }, testUser); - } - }); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor.SearchClassificationEnforcementTestBase#search(java.lang.String) - */ - @Override - protected List search(String searchQuery) - { - SearchParameters searchParameters = new SearchParameters(); - searchParameters.setQuery(searchQuery); - searchParameters.setLanguage(LANGUAGE_FTS_ALFRESCO); - searchParameters.addStore(STORE_REF_WORKSPACE_SPACESSTORE); - searchParameters.setMaxItems(MAX_VALUE); - searchParameters.setNamespace(RM_URI); - searchParameters.addQueryTemplate("keywords", "%(cm:name cm:title cm:description TEXT)"); - return searchService.query(searchParameters).getNodeRefs(); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SearchClassificationEnforcementTestBase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SearchClassificationEnforcementTestBase.java deleted file mode 100644 index 5d659ec0fc..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SearchClassificationEnforcementTestBase.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName; -import static org.alfresco.util.GUID.generate; - -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Base class for classification enforcement tests for the search action - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public abstract class SearchClassificationEnforcementTestBase extends BaseRMTestCase -{ - protected String testUser; - protected static final String TOP_SECRET_ID = "TS"; - protected static final String SECRET_ID = "S"; - protected static final String REASON = "Test Reason 1"; - /** Classified properties for top secret. */ - protected ClassificationAspectProperties propertiesDTO1; - /** Classified properties for secret. */ - protected ClassificationAspectProperties propertiesDTO2; - - @Override - public void setUp() throws Exception - { - super.setUp(); - propertiesDTO1 = new ClassificationAspectProperties(); - propertiesDTO1.setClassificationLevelId(TOP_SECRET_ID); - propertiesDTO1.setClassifiedBy(generate()); - propertiesDTO1.setClassificationAgency(generate()); - propertiesDTO1.setClassificationReasonIds(Collections.singleton(REASON)); - propertiesDTO2 = new ClassificationAspectProperties(); - propertiesDTO2.setClassificationLevelId(SECRET_ID); - propertiesDTO2.setClassifiedBy(generate()); - propertiesDTO2.setClassificationAgency(generate()); - propertiesDTO2.setClassificationReasonIds(Collections.singleton(REASON)); - } - - protected abstract List search(String searchQuery); - - private List search(String searchQuery, String userName) - { - return doTestInTransaction(new Test>() - { - @Override - public List run() - { - return search(searchQuery); - } - }, userName); - } - - protected List searchAsAdmin(String searchQuery) - { - return search(searchQuery, getAdminUserName()); - } - - protected List searchAsTestUser(String searchQuery) - { - return search(searchQuery, testUser); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/destroy/DestroyContentTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/destroy/DestroyContentTest.java index 241720416c..2a43dc3809 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/destroy/DestroyContentTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/destroy/DestroyContentTest.java @@ -20,14 +20,12 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.destroy; import java.io.InputStream; import java.io.Serializable; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; import org.alfresco.module.org_alfresco_module_rm.content.ContentDestructionComponent; import org.alfresco.module.org_alfresco_module_rm.content.EagerContentStoreCleaner; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; @@ -55,10 +53,10 @@ public class DestroyContentTest extends BaseRMTestCase { private static final String BEAN_NAME_CONTENT_CLEANSER = "contentCleanser.test"; - private ContentStore contentStore; - private TestContentCleanser contentCleanser; + protected ContentStore contentStore; + protected TestContentCleanser contentCleanser; + protected ContentDestructionComponent contentDestructionComponent; private EagerContentStoreCleaner eagerContentStoreCleaner; - private ContentDestructionComponent contentDestructionComponent; @SuppressWarnings("unused") private RenditionService renditionService; @@ -301,256 +299,6 @@ public class DestroyContentTest extends BaseRMTestCase }); } - /** - * When the a record is deleted - * Then the content is destroyed - */ - @AlfrescoTest (jira="RM-2461") - public void testRecordDelete() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef recordCategoryRecordLevel; - private NodeRef recordFolder; - private NodeRef deleteableRecord; - private ContentData contentData; - - public void given() throws Exception - { - // create destroyable record - recordCategoryRecordLevel = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategoryRecordLevel, GUID.generate()); - deleteableRecord = utils.createRecord(recordFolder, GUID.generate(), GUID.generate()); - contentData = (ContentData)nodeService.getProperty(deleteableRecord, PROP_CONTENT); - - // assert things are as we expect - assertNotNull(contentData); - assertTrue(contentStore.exists(contentData.getContentUrl())); - - // reset test content cleanser - contentCleanser.reset(); - assertFalse(contentDestructionComponent.isCleansingEnabled()); - } - - public void when() throws Exception - { - // delete the record - nodeService.deleteNode(deleteableRecord); - } - - public void then() throws Exception - { - // record destroyed - assertFalse(nodeService.exists(deleteableRecord)); - assertFalse(contentStore.exists(contentData.getContentUrl())); - - // content cleansing hasn't taken place - assertFalse(contentCleanser.hasCleansed()); - - // ensure the record isn't in the archive store - NodeRef archiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, deleteableRecord.getId()); - assertFalse(nodeService.exists(archiveNodeRef)); - } - }); - } - - /** - * Given cleansing is configured on - * When the a record is deleted - * Then the content is cleansed - * And then the content is destroyed - */ - @AlfrescoTest (jira="RM-2460") - public void testRecordDeleteAndCleanse() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef recordCategoryRecordLevel; - private NodeRef recordFolder; - private NodeRef deleteableRecord; - private ContentData contentData; - - public void given() throws Exception - { - // create destroyable record - recordCategoryRecordLevel = filePlanService.createRecordCategory(filePlan, GUID.generate()); - recordFolder = recordFolderService.createRecordFolder(recordCategoryRecordLevel, GUID.generate()); - deleteableRecord = utils.createRecord(recordFolder, GUID.generate(), GUID.generate()); - contentData = (ContentData)nodeService.getProperty(deleteableRecord, PROP_CONTENT); - - // assert things are as we expect - assertNotNull(contentData); - assertTrue(contentStore.exists(contentData.getContentUrl())); - - // reset test content cleanser and configure on - contentCleanser.reset(); - contentDestructionComponent.setCleansingEnabled(true); - assertTrue(contentDestructionComponent.isCleansingEnabled()); - } - - public void when() throws Exception - { - // delete the record - nodeService.deleteNode(deleteableRecord); - } - - public void then() throws Exception - { - // record destroyed - assertFalse(nodeService.exists(deleteableRecord)); - assertFalse(contentStore.exists(contentData.getContentUrl())); - - // content cleansing has taken place - assertTrue(contentCleanser.hasCleansed()); - - // ensure the record isn't in the archive store - NodeRef archiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, deleteableRecord.getId()); - assertFalse(nodeService.exists(archiveNodeRef)); - } - - public void after() throws Exception - { - // reset cleansing to default - contentDestructionComponent.setCleansingEnabled(false); - } - }); - } - - /** - * When classified content (non-record) is deleted - * Then it is destroyed - */ - @AlfrescoTest (jira="RM-2461") - public void testClassifiedContentDelete() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef deleteableContent; - private ContentData contentData; - - public void given() throws Exception - { - // create deletable classified content - assertTrue(nodeService.exists(folder)); - deleteableContent = fileFolderService.create(folder, "myDocument.txt", TYPE_CONTENT).getNodeRef(); - ContentWriter writer = fileFolderService.getWriter(deleteableContent); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(GUID.generate()); - - // classify the content - ClassificationAspectProperties properties = new ClassificationAspectProperties(); - properties.setClassificationLevelId("TS"); - properties.setClassifiedBy("me"); - properties.setClassificationReasonIds(Collections.singleton("Test Reason 1")); - contentClassificationService.classifyContent(properties, deleteableContent); - - // grab the content data - contentData = (ContentData)nodeService.getProperty(deleteableContent, PROP_CONTENT); - - // assert things are as we expect - assertNotNull(contentData); - assertTrue(contentStore.exists(contentData.getContentUrl())); - - // reset test content cleanser - contentCleanser.reset(); - assertFalse(contentDestructionComponent.isCleansingEnabled()); - } - - public void when() throws Exception - { - // delete the content - nodeService.deleteNode(deleteableContent); - } - - public void then() throws Exception - { - // content destroyed - assertFalse(nodeService.exists(deleteableContent)); - assertFalse(contentStore.exists(contentData.getContentUrl())); - - // content cleansing hasn't taken place - assertFalse(contentCleanser.hasCleansed()); - - // ensure the record isn't in the archive store - NodeRef archiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, deleteableContent.getId()); - assertFalse(nodeService.exists(archiveNodeRef)); - } - }); - } - - /** - * Given data cleansing is configured on - * When classified content (non-record) is deleted - * Then it is cleansed - * And then it is destroyed - */ - @AlfrescoTest (jira="RM-2460") - public void testClassifiedContentDeleteAndCleanse() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef deleteableContent; - private ContentData contentData; - - public void given() throws Exception - { - // create deletable classified content - assertTrue(nodeService.exists(folder)); - deleteableContent = fileFolderService.create(folder, "myDocument.txt", TYPE_CONTENT).getNodeRef(); - ContentWriter writer = fileFolderService.getWriter(deleteableContent); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.putContent(GUID.generate()); - - // classify the content - ClassificationAspectProperties properties = new ClassificationAspectProperties(); - properties.setClassificationLevelId("TS"); - properties.setClassifiedBy("me"); - properties.setClassificationReasonIds(Collections.singleton("Test Reason 1")); - contentClassificationService.classifyContent(properties, deleteableContent); - - // grab the content data - contentData = (ContentData)nodeService.getProperty(deleteableContent, PROP_CONTENT); - - // assert things are as we expect - assertNotNull(contentData); - assertTrue(contentStore.exists(contentData.getContentUrl())); - - // reset test content cleanser and configure on - contentCleanser.reset(); - contentDestructionComponent.setCleansingEnabled(true); - assertTrue(contentDestructionComponent.isCleansingEnabled()); - } - - public void when() throws Exception - { - // delete the content - nodeService.deleteNode(deleteableContent); - } - - public void then() throws Exception - { - // content destroyed - assertFalse(nodeService.exists(deleteableContent)); - assertFalse(contentStore.exists(contentData.getContentUrl())); - - // content cleansing has taken place - assertTrue(contentCleanser.hasCleansed()); - - // ensure the record isn't in the archive store - NodeRef archiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, deleteableContent.getId()); - assertFalse(nodeService.exists(archiveNodeRef)); - } - - public void after() throws Exception - { - // reset cleansing to default - contentDestructionComponent.setCleansingEnabled(false); - } - }); - } - /** * When a unclassified document (non-record) is deleted * Then it is deleted but the the content is not immediately destroyed diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java deleted file mode 100644 index 356e6bf489..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_USER; -import static org.alfresco.util.GUID.generate; - -import java.util.Collections; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Integration test for RM-2260 - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class RM2260Test extends BaseRMTestCase -{ - private static final String LEVEL = "TS"; - private static final String REASON = "Test Reason 1"; - private ClassificationAspectProperties propertiesDTO; - - @Override - public void setUp() throws Exception - { - super.setUp(); - propertiesDTO = new ClassificationAspectProperties(); - propertiesDTO.setClassificationLevelId(LEVEL); - propertiesDTO.setClassifiedBy(generate()); - propertiesDTO.setClassificationAgency(generate()); - propertiesDTO.setClassificationReasonIds(Collections.singleton(REASON)); - } - - public void testClassifiyingContentAsNonAdminUser() - { - /** - * Given that a user (assigned to an RM role) exists - * When filing permissions on a root category and the security clearance for that user are set - * Then the user should be able to classify a record within a folder which is within the given category - */ - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - String myUser; - NodeRef category; - NodeRef folder; - NodeRef record; - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given() - */ - @Override - public void given() throws Exception - { - myUser = generate(); - createPerson(myUser); - filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_USER, myUser); - - category = filePlanService.createRecordCategory(filePlan, generate()); - folder = recordFolderService.createRecordFolder(category, generate()); - record = utils.createRecord(folder, generate()); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when() - */ - @Override - public void when() throws Exception - { - filePlanPermissionService.setPermission(category, myUser, FILING); - securityClearanceService.setUserSecurityClearance(myUser, LEVEL); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then() - */ - @Override - public void then() throws Exception - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - contentClassificationService.classifyContent(propertiesDTO, record); - return null; - } - }, myUser); - } - }); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java index b3894d5e2b..6828e0dc49 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java @@ -18,15 +18,8 @@ */ package org.alfresco.module.org_alfresco_module_rm.test.legacy.jscript; -import static org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager.UNCLASSIFIED_ID; -import static org.alfresco.module.org_alfresco_module_rm.jscript.app.JSONConversionComponent.IS_CLASSIFIED; -import static org.alfresco.util.GUID.generate; - import java.io.Serializable; -import java.util.Collections; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.repo.jscript.app.JSONConversionComponent; import org.alfresco.service.cmr.repository.NodeRef; @@ -39,40 +32,14 @@ import org.json.JSONObject; */ public class JSONConversionComponentTest extends BaseRMTestCase { - private static final String TOP_SECRET_ID = "TS"; - private static final String REASON1 = "Test Reason 1"; - - private JSONConversionComponent converter; - private ContentClassificationService contentClassificationService; - - private NodeRef record; - /** Classification properties for top secret classification. */ - private ClassificationAspectProperties topSecretPropertiesDTO; - /** Classification properties for unclassified content. */ - private ClassificationAspectProperties unclassifiedPropertiesDTO; - - @Override - public void setUp() throws Exception - { - super.setUp(); - topSecretPropertiesDTO = new ClassificationAspectProperties(); - topSecretPropertiesDTO.setClassificationLevelId(TOP_SECRET_ID); - topSecretPropertiesDTO.setClassifiedBy(generate()); - topSecretPropertiesDTO.setClassificationAgency(generate()); - topSecretPropertiesDTO.setClassificationReasonIds(Collections.singleton(REASON1)); - unclassifiedPropertiesDTO = new ClassificationAspectProperties(); - unclassifiedPropertiesDTO.setClassificationLevelId(UNCLASSIFIED_ID); - unclassifiedPropertiesDTO.setClassifiedBy(generate()); - unclassifiedPropertiesDTO.setClassificationAgency(generate()); - unclassifiedPropertiesDTO.setClassificationReasonIds(Collections.singleton(REASON1)); - } + protected JSONConversionComponent converter; + protected NodeRef record; @Override protected void initServices() { super.initServices(); converter = (JSONConversionComponent) applicationContext.getBean("jsonConversionComponent"); - contentClassificationService = (ContentClassificationService) applicationContext.getBean("ContentClassificationService"); } @Override @@ -90,234 +57,6 @@ public class JSONConversionComponentTest extends BaseRMTestCase return true; } - /** - * Given a record exists in the RM site - * When I classify the record with a level not equal to "Unclassified" and convert it - * Then the result should include an attribute "isClassified" with the value "true" - */ - public void testClassifyRecord_classified() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private String jsonString; - - @Override - public void given() throws Exception - { - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - NodeRef folder = recordFolderService.createRecordFolder(category, generate()); - record = utils.createRecord(folder, generate()); - } - - @Override - public void when() throws Exception - { - contentClassificationService.classifyContent(topSecretPropertiesDTO, record); - jsonString = converter.toJSON(record, true); - } - - @Override - public void then() throws Exception - { - assertNotNull(jsonString); - JSONObject jsonObject = new JSONObject(jsonString); - Object isClassifiedObject = jsonObject.get(IS_CLASSIFIED); - assertNotNull(isClassifiedObject); - assertTrue(((Boolean) isClassifiedObject).booleanValue()); - } - }); - } - - /** - * Given a record exists in the RM site - * When I classify the record with the level "Unclassified" and convert it - * Then the result should include an attribute "isClassified" with the value "false" - */ - public void testClassifyRecord_unclassified() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private String jsonString; - - @Override - public void given() throws Exception - { - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - NodeRef folder = recordFolderService.createRecordFolder(category, generate()); - record = utils.createRecord(folder, generate()); - } - - @Override - public void when() throws Exception - { - contentClassificationService.classifyContent(unclassifiedPropertiesDTO, record); - jsonString = converter.toJSON(record, true); - } - - @Override - public void then() throws Exception - { - assertNotNull(jsonString); - JSONObject jsonObject = new JSONObject(jsonString); - Object isClassifiedObject = jsonObject.get(IS_CLASSIFIED); - assertNotNull(isClassifiedObject); - assertFalse(((Boolean) isClassifiedObject).booleanValue()); - } - }); - } - - /** - * Given a record exists in the RM site - * When I classify the record with the level "Unclassified" and convert it - * Then the result should include an attribute "isClassified" with the value "false" - */ - public void testClassifyRecord_notclassified() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef record; - private String jsonString; - - @Override - public void given() throws Exception - { - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - NodeRef folder = recordFolderService.createRecordFolder(category, generate()); - record = utils.createRecord(folder, generate()); - } - - @Override - public void when() throws Exception - { - jsonString = converter.toJSON(record, true); - } - - @Override - public void then() throws Exception - { - assertNotNull(jsonString); - JSONObject jsonObject = new JSONObject(jsonString); - Object isClassifiedObject = jsonObject.get(IS_CLASSIFIED); - assertNotNull(isClassifiedObject); - assertFalse(((Boolean) isClassifiedObject).booleanValue()); - } - }); - } - - /** - * Given a file exists in a collaboration site - * When I classify the file with a level not equal to "Unclassified" and convert it - * Then the result should include an attribute "isClassified" with the value "true" - */ - public void testClassifyFile_classified() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef file; - private String jsonString; - - @Override - public void given() throws Exception - { - file = fileFolderService.create(documentLibrary, generate(), TYPE_CONTENT).getNodeRef(); - } - - @Override - public void when() throws Exception - { - contentClassificationService.classifyContent(topSecretPropertiesDTO, file); - jsonString = converter.toJSON(file, true); - } - - @Override - public void then() throws Exception - { - assertNotNull(jsonString); - JSONObject jsonObject = new JSONObject(jsonString); - Object isClassifiedObject = jsonObject.get(IS_CLASSIFIED); - assertNotNull(isClassifiedObject); - assertTrue(((Boolean) isClassifiedObject).booleanValue()); - } - }); - } - - /** - * Given a file exists in a collaboration site - * When I classify the file with the level "Unclassified" and convert it - * Then the result should include an attribute "isClassified" with the value "false" - */ - public void testClassifyFile_unclassified() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef file; - private String jsonString; - - @Override - public void given() throws Exception - { - file = fileFolderService.create(documentLibrary, generate(), TYPE_CONTENT).getNodeRef(); - } - - @Override - public void when() throws Exception - { - contentClassificationService.classifyContent(unclassifiedPropertiesDTO, file); - jsonString = converter.toJSON(file, true); - } - - @Override - public void then() throws Exception - { - assertNotNull(jsonString); - JSONObject jsonObject = new JSONObject(jsonString); - Object isClassifiedObject = jsonObject.get(IS_CLASSIFIED); - assertNotNull(isClassifiedObject); - assertFalse(((Boolean) isClassifiedObject).booleanValue()); - } - }); - } - - /** - * Given a file exists in a collaboration site - * When I classify the file with the level "Unclassified" and convert it - * Then the result should include an attribute "isClassified" with the value "false" - */ - public void testClassifyFile_notclassified() - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - private NodeRef file; - private String jsonString; - - @Override - public void given() throws Exception - { - NodeRef category = filePlanService.createRecordCategory(filePlan, generate()); - NodeRef folder = recordFolderService.createRecordFolder(category, generate()); - file = utils.createRecord(folder, generate()); - } - - @Override - public void when() throws Exception - { - jsonString = converter.toJSON(file, true); - } - - @Override - public void then() throws Exception - { - assertNotNull(jsonString); - JSONObject jsonObject = new JSONObject(jsonString); - Object isClassifiedObject = jsonObject.get(IS_CLASSIFIED); - assertNotNull(isClassifiedObject); - assertFalse(((Boolean) isClassifiedObject).booleanValue()); - } - }); - } - public void testJSON() throws Exception { doTestInTransaction(new JSONTest diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ClassificationRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ClassificationRestApiTest.java deleted file mode 100644 index 1d8b52476d..0000000000 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/ClassificationRestApiTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.test.legacy.webscript; - -import static org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.Reclassification.DOWNGRADE; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLASSIFICATION_REASONS; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLASSIFIED_BY; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_DECLASSIFICATION_DATE; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_DECLASSIFICATION_EVENT; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_DECLASSIFICATION_EXEMPTIONS; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_DOWNGRADE_DATE; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_DOWNGRADE_EVENT; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_DOWNGRADE_INSTRUCTIONS; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_LAST_RECLASSIFICATION_ACTION; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_LAST_RECLASSIFY_AT; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_LAST_RECLASSIFY_BY; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_LAST_RECLASSIFY_REASON; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFICATION_AGENCY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFICATION_LEVEL_ID; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFICATION_REASONS; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFIED_BY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.DECLASSIFICATION_DATE; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.DECLASSIFICATION_EVENT; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.DECLASSIFICATION_EXEMPTIONS; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.DOWNGRADE_DATE; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.DOWNGRADE_EVENT; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.DOWNGRADE_INSTRUCTIONS; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.LAST_RECLASSIFY_BY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.LAST_RECLASSIFY_REASON; -import static org.alfresco.util.GUID.generate; -import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATE_FORMAT; -import static org.apache.commons.lang3.time.DateUtils.parseDate; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.text.ParseException; -import java.util.Date; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * REST API tests for classification of a content and editing content - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassificationRestApiTest extends BaseRMWebScriptTestCase -{ - /** URL for the REST API */ - private static final String RM_CLASSIFY_ACTIONS_URL = "/api/node/%s/%s/%s/classify"; - - /** Content type */ - private static final String APPLICATION_JSON = "application/json"; - - /** Constant for response */ - private static final String RESPONSE_SUCCESS = "success"; - - /** Constants for classification request body parameters */ - private static final String ID = "id"; - private static final String TOP_SECRET_ID = "TS"; - private static final String SECRET_ID = "S"; - private static final String CLASSIFIED_BY1 = generate(); - private static final String CLASSIFIED_BY2 = generate(); - private static final String CLASSIFICATION_AGENCY1 = generate(); - private static final String CLASSIFICATION_AGENCY2 = generate(); - private static final String CLASSIFICATION_REASON_1_ID_VALUE = "Test Reason 1"; - private static final String CLASSIFICATION_REASON_2_ID_VALUE = "Test Reason 1.2"; - private static final String CLASSIFICATION_REASON_3_ID_VALUE = "Test Reason 1.2(c)"; - private static final String DOWNGRADE_DATE_VALUE = "2015-07-08"; - private static final String DOWNGRADE_EVENT_VALUE = generate(); - private static final String DOWNGRADE_INSTRUCTIONS_VALUE = generate(); - private static final String DECLASSIFICATION_DATE_VALUE = "2015-12-01"; - private static final String DECLASSIFICATION_EVENT_VALUE = generate(); - private static final String DECLASSIFICATION_EXEMPTION_1_ID_VALUE = "Test Category 1"; - private static final String DECLASSIFICATION_EXEMPTION_2_ID_VALUE = "Test Category 2"; - private static final String LAST_RECLASSIFY_BY_VALUE = generate(); - private static final String LAST_RECLASSIFY_REASON_VALUE = generate(); - - /** Tests classifying a content and editing a classified content */ - @SuppressWarnings("unchecked") - public void testClassifyEditContent() throws IOException, JSONException, InvalidNodeRefException, ParseException - { - // Create record to classify - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, generate()); - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, generate()); - NodeRef record = utils.createRecord(recordFolder, generate()); - - // Format the URL - StoreRef storeRef = record.getStoreRef(); - String storeProtocol = storeRef.getProtocol(); - String storeId = storeRef.getIdentifier(); - String id = record.getId(); - String url = String.format(RM_CLASSIFY_ACTIONS_URL, storeProtocol, storeId, id); - - // Classify content - JSONObject requestBody = new JSONObject(); - requestBody.put(CLASSIFICATION_LEVEL_ID, TOP_SECRET_ID); - requestBody.put(CLASSIFIED_BY, CLASSIFIED_BY1); - requestBody.put(CLASSIFICATION_AGENCY, CLASSIFICATION_AGENCY1); - JSONArray classificationReasons = new JSONArray(); - classificationReasons.put(new JSONObject().put(ID, CLASSIFICATION_REASON_1_ID_VALUE)); - classificationReasons.put(new JSONObject().put(ID, CLASSIFICATION_REASON_2_ID_VALUE)); - requestBody.put(CLASSIFICATION_REASONS, classificationReasons); - requestBody.put(DECLASSIFICATION_DATE, DECLASSIFICATION_DATE_VALUE); - requestBody.put(DECLASSIFICATION_EVENT, DECLASSIFICATION_EVENT_VALUE); - JSONArray declassificationExemptions = new JSONArray(); - declassificationExemptions.put(new JSONObject().put(ID, DECLASSIFICATION_EXEMPTION_1_ID_VALUE)); - declassificationExemptions.put(new JSONObject().put(ID, DECLASSIFICATION_EXEMPTION_2_ID_VALUE)); - requestBody.put(DECLASSIFICATION_EXEMPTIONS, declassificationExemptions); - Response response = sendRequest(new PostRequest(url, requestBody.toString(), APPLICATION_JSON), 200); - String responseContent = response.getContentAsString(); - JSONObject responseAsJson = new JSONObject(responseContent); - - assertNotNull(responseAsJson); - assertTrue(responseAsJson.getBoolean(RESPONSE_SUCCESS)); - assertEquals(TOP_SECRET_ID, nodeService.getProperty(record, PROP_CURRENT_CLASSIFICATION)); - assertEquals(CLASSIFIED_BY1, nodeService.getProperty(record, PROP_CLASSIFIED_BY)); - assertEquals(CLASSIFICATION_AGENCY1, nodeService.getProperty(record, PROP_CLASSIFICATION_AGENCY)); - List classificationReasonsList = (List) nodeService.getProperty(record, PROP_CLASSIFICATION_REASONS); - assertNotNull(classificationReasonsList); - assertEquals(2, classificationReasonsList.size()); - assertTrue(classificationReasonsList.contains(CLASSIFICATION_REASON_1_ID_VALUE)); - assertTrue(classificationReasonsList.contains(CLASSIFICATION_REASON_2_ID_VALUE)); - assertEquals(parseDate(DECLASSIFICATION_DATE_VALUE, ISO_DATE_FORMAT.getPattern()), nodeService.getProperty(record, PROP_DECLASSIFICATION_DATE)); - assertEquals(DECLASSIFICATION_EVENT_VALUE, nodeService.getProperty(record, PROP_DECLASSIFICATION_EVENT)); - List declassificationExemptionsList = (List) nodeService.getProperty(record, PROP_DECLASSIFICATION_EXEMPTIONS); - assertNotNull(declassificationExemptionsList); - assertEquals(2, declassificationExemptionsList.size()); - assertTrue(declassificationExemptionsList.contains(DECLASSIFICATION_EXEMPTION_1_ID_VALUE)); - assertTrue(declassificationExemptionsList.contains(DECLASSIFICATION_EXEMPTION_2_ID_VALUE)); - - // Edit classified content - requestBody = new JSONObject(); - requestBody.put(CLASSIFICATION_LEVEL_ID, SECRET_ID); - requestBody.put(CLASSIFIED_BY, CLASSIFIED_BY2); - requestBody.put(CLASSIFICATION_AGENCY, CLASSIFICATION_AGENCY2); - classificationReasons = new JSONArray(); - classificationReasons.put(new JSONObject().put(ID, CLASSIFICATION_REASON_3_ID_VALUE)); - requestBody.put(CLASSIFICATION_REASONS, classificationReasons); - requestBody.put(LAST_RECLASSIFY_BY, LAST_RECLASSIFY_BY_VALUE); - requestBody.put(LAST_RECLASSIFY_REASON, LAST_RECLASSIFY_REASON_VALUE); - response = sendRequest(new PutRequest(url, requestBody.toString(), APPLICATION_JSON), 200); - responseContent = response.getContentAsString(); - responseAsJson = new JSONObject(responseContent); - - assertNotNull(responseAsJson); - assertTrue(responseAsJson.getBoolean(RESPONSE_SUCCESS)); - assertEquals(SECRET_ID, nodeService.getProperty(record, PROP_CURRENT_CLASSIFICATION)); - assertEquals(CLASSIFIED_BY2, nodeService.getProperty(record, PROP_CLASSIFIED_BY)); - assertEquals(CLASSIFICATION_AGENCY2, nodeService.getProperty(record, PROP_CLASSIFICATION_AGENCY)); - List editedClassificationReasonsList = (List) nodeService.getProperty(record, PROP_CLASSIFICATION_REASONS); - assertNotNull(editedClassificationReasonsList); - assertEquals(1, editedClassificationReasonsList.size()); - assertTrue(editedClassificationReasonsList.contains(CLASSIFICATION_REASON_3_ID_VALUE)); - assertEquals(DOWNGRADE.toModelString(), nodeService.getProperty(record, PROP_LAST_RECLASSIFICATION_ACTION)); - String date1 = DateFormatUtils.format(new Date(), ISO_DATE_FORMAT.getPattern()); - String date2 = DateFormatUtils.format((Date) nodeService.getProperty(record, PROP_LAST_RECLASSIFY_AT), ISO_DATE_FORMAT.getPattern()); - assertEquals(date1, date2); - assertEquals(LAST_RECLASSIFY_BY_VALUE, nodeService.getProperty(record, PROP_LAST_RECLASSIFY_BY)); - assertEquals(LAST_RECLASSIFY_REASON_VALUE, nodeService.getProperty(record, PROP_LAST_RECLASSIFY_REASON)); - } - - /** Test downgrade schedule */ - public void testDowngradeSchedule() throws JSONException, UnsupportedEncodingException, IOException, InvalidNodeRefException, ParseException - { - // Create record to classify - NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, generate()); - NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, generate()); - NodeRef record = utils.createRecord(recordFolder, generate()); - - // Format the URL - StoreRef storeRef = record.getStoreRef(); - String storeProtocol = storeRef.getProtocol(); - String storeId = storeRef.getIdentifier(); - String id = record.getId(); - String url = String.format(RM_CLASSIFY_ACTIONS_URL, storeProtocol, storeId, id); - - // Classify content - JSONObject requestBody = new JSONObject(); - requestBody.put(CLASSIFICATION_LEVEL_ID, TOP_SECRET_ID); - requestBody.put(CLASSIFIED_BY, CLASSIFIED_BY1); - requestBody.put(CLASSIFICATION_AGENCY, CLASSIFICATION_AGENCY1); - JSONArray classificationReasons = new JSONArray(); - classificationReasons.put(new JSONObject().put(ID, CLASSIFICATION_REASON_1_ID_VALUE)); - classificationReasons.put(new JSONObject().put(ID, CLASSIFICATION_REASON_2_ID_VALUE)); - requestBody.put(CLASSIFICATION_REASONS, classificationReasons); - - // Set just a downgrade date - requestBody.put(DOWNGRADE_DATE, DOWNGRADE_DATE_VALUE); - // An exception is expected - sendRequest(new PostRequest(url, requestBody.toString(), APPLICATION_JSON), 500); - - // Set just a downgrade event - requestBody.remove(DOWNGRADE_DATE); - requestBody.put(DOWNGRADE_EVENT, DOWNGRADE_EVENT_VALUE); - // An exception is expected - sendRequest(new PostRequest(url, requestBody.toString(), APPLICATION_JSON), 500); - - // Set a downgrade date and downgrade event - requestBody.put(DOWNGRADE_DATE, DOWNGRADE_DATE_VALUE); - // An exception is expected - sendRequest(new PostRequest(url, requestBody.toString(), APPLICATION_JSON), 500); - - // Set a downgrade instructions - requestBody.put(DOWNGRADE_INSTRUCTIONS, DOWNGRADE_INSTRUCTIONS_VALUE); - Response response = sendRequest(new PostRequest(url, requestBody.toString(), APPLICATION_JSON), 200); - - String responseContent = response.getContentAsString(); - JSONObject responseAsJson = new JSONObject(responseContent); - - assertNotNull(responseAsJson); - assertTrue(responseAsJson.getBoolean(RESPONSE_SUCCESS)); - assertEquals(parseDate(DOWNGRADE_DATE_VALUE, ISO_DATE_FORMAT.getPattern()), nodeService.getProperty(record, PROP_DOWNGRADE_DATE)); - assertEquals(DOWNGRADE_EVENT_VALUE, nodeService.getProperty(record, PROP_DOWNGRADE_EVENT)); - assertEquals(DOWNGRADE_INSTRUCTIONS_VALUE, nodeService.getProperty(record, PROP_DOWNGRADE_INSTRUCTIONS)); - } -} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index 3a6cb4428d..883acf31a1 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -29,9 +29,6 @@ import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminSe import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; @@ -163,9 +160,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase protected HoldService holdService; protected InplaceRecordService inplaceRecordService; protected RelationshipService relationshipService; - protected ClassificationSchemeService classificationSchemeService; - protected SecurityClearanceService securityClearanceService; - protected ContentClassificationService contentClassificationService; /** test data */ protected String siteId; @@ -405,9 +399,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase holdService = (HoldService) applicationContext.getBean("HoldService"); inplaceRecordService = (InplaceRecordService) applicationContext.getBean("InplaceRecordService"); relationshipService = (RelationshipService) applicationContext.getBean("RelationshipService"); - classificationSchemeService = (ClassificationSchemeService) applicationContext.getBean("ClassificationSchemeService"); - securityClearanceService = (SecurityClearanceService) applicationContext.getBean("SecurityClearanceService"); - contentClassificationService = (ContentClassificationService) applicationContext.getBean("ContentClassificationService"); } /** diff --git a/rm-server/test/resources/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json b/rm-server/test/resources/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json deleted file mode 100644 index edc3408ed8..0000000000 --- a/rm-server/test/resources/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "id" : "Test Reason 1", - "displayLabel" : "rm.test.classification-reason.militaryPlans" - }, - { - "id" : "Test Reason 1.2", - "displayLabel" : "rm.test.classification-reason.foreignGovernments" - }, - { - "id" : "Test Reason 1.2(c)", - "displayLabel" : "rm.test.classification-reason.intelligenceActivities" - }, - { - "id" : "Test Reason 1.2(c) iv", - "displayLabel" : "rm.test.classification-reason.foreignRelations" - } -] diff --git a/rm-server/test/resources/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json b/rm-server/test/resources/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json deleted file mode 100644 index 3dc7c42239..0000000000 --- a/rm-server/test/resources/alfresco/module/org_alfresco_module_rm/classification/rm-exemption-categories.json +++ /dev/null @@ -1,10 +0,0 @@ -[{ - "id" : "Test Category 1", - "displayLabel" : "rm.test.exemption-category.one" - },{ - "id" : "Test Category 2", - "displayLabel" : "rm.test.exemption-category.two" - },{ - "id" : "Test Category 3", - "displayLabel" : "rm.test.exemption-category.three" -}] \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java index 92bdc889d3..03943c5b28 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/BootstrapImporterModuleComponentUnitTest.java @@ -47,7 +47,6 @@ public class BootstrapImporterModuleComponentUnitTest extends BaseUnitTest @Mock(name="importer") private ImporterBootstrap mockedImporter; @Mock(name="modulePatchExecuter") private ModulePatchExecuter mockedModulePatchExecuter; @Mock(name="recordContributorsGroupBootstrapComponent") private RecordContributorsGroupBootstrapComponent mockedRecordContributorsGroupBootstrapComponent; - @Mock(name="clearanceForAdminBootstrapComponent") private ClearanceForAdminBootstrapComponent mockedClearanceForAdminBootstrapComponent; /** importer */ @InjectMocks diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ClearanceForAdminBootstrapComponentUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ClearanceForAdminBootstrapComponentUnitTest.java deleted file mode 100644 index dfb8baa3d8..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ClearanceForAdminBootstrapComponentUnitTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.bootstrap; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.PersonService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * Unit tests for {@link ClearanceForAdminBootstrapComponent}. - * - * @author tpage - */ -public class ClearanceForAdminBootstrapComponentUnitTest implements ClassifiedContentModel -{ - @InjectMocks ClearanceForAdminBootstrapComponent clearanceForAdminBootstrapComponent; - @Mock AuthenticationUtil mockAuthenticationUtil; - @Mock PersonService mockPersonService; - @Mock NodeService mockNodeService; - @Mock ClassificationServiceBootstrap mockClassificationServiceBootstrap; - - @Before public void setUp() - { - initMocks(this); - } - - /** Check that the admin user gets assigned the provided clearance. */ - @Test public void testCreateClearanceForAdmin() - { - // Allow the classification level id to be found. - ClassificationLevel level = new ClassificationLevel("id", "displayLabelKey"); - ClassificationLevelManager mockClassificationLevelManager = mock(ClassificationLevelManager.class); - when(mockClassificationLevelManager.getMostSecureLevel()).thenReturn(level); - when(mockClassificationServiceBootstrap.getClassificationLevelManager()).thenReturn(mockClassificationLevelManager); - - // Set up the admin user. - when(mockAuthenticationUtil.getAdminUserName()).thenReturn("admin"); - NodeRef admin = new NodeRef("admin://node/"); - when(mockPersonService.getPerson("admin", false)).thenReturn(admin); - - // Call the method under test. - clearanceForAdminBootstrapComponent.createClearanceForAdmin(); - - verify(mockNodeService).setProperty(admin, PROP_CLEARANCE_LEVEL, "id"); - // Check that the classification levels were loaded. - verify(mockClassificationServiceBootstrap).onBootstrap(null); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSONUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSONUnitTest.java deleted file mode 100644 index 0c822a8227..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/caveat/dao/CaveatDAOFromJSONUnitTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.caveat.dao; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.caveat.CaveatException.MalformedConfiguration; -import org.alfresco.module.org_alfresco_module_rm.caveat.scheme.CaveatGroup; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; - -/** - * Unit tests for the {@link CaveatDAOFromJSON}. - * - * @author Tom Page - * @since 2.4.a - */ -public class CaveatDAOFromJSONUnitTest -{ - /** The class under test. */ - CaveatDAOFromJSON caveatDAOFromJSON = new CaveatDAOFromJSON(); - - @Before public void initClassUnderTest() - { - NamespaceService namespaceService = mock(NamespaceService.class); - when(namespaceService.getNamespaceURI(anyString())).thenReturn("{mockedNamespace}"); - - DictionaryService dictionaryService = mock(DictionaryService.class); - PropertyDefinition mockProperty = mock(PropertyDefinition.class); - when(dictionaryService.getProperty(any(QName.class))).thenReturn(mockProperty); - - caveatDAOFromJSON.setDictionaryService(dictionaryService); - caveatDAOFromJSON.setNamespaceService(namespaceService); - } - - /** Test that loading the default caveat configuration file doesn't throw any exceptions. */ - @Test - public void testGetCaveatGroups_defaultConfiguration() - { - caveatDAOFromJSON.setConfigLocation("/alfresco/module/org_alfresco_module_rm/caveat/rm-caveats.json"); - Map caveatGroups = caveatDAOFromJSON.getCaveatGroups(); - assertNotNull(caveatGroups); - } - - /** Test that if the caveat configuration file is missing then an empty set of caveat groups is created. */ - @Test - public void testGetCaveatGroups_missingConfiguration() - { - caveatDAOFromJSON.setConfigLocation("/does/not/exist.json"); - Map caveatGroups = caveatDAOFromJSON.getCaveatGroups(); - assertTrue("A missing configuration file should result in no caveat groups", caveatGroups.keySet().isEmpty()); - } - - /** Test that malformed JSON causes an exception. */ - @Test(expected = MalformedConfiguration.class) - public void testGetCaveatGroups_malformedJSON() - { - caveatDAOFromJSON.setConfigLocation("/alfresco/caveat/rm-caveats-malformedJSON.json"); - caveatDAOFromJSON.getCaveatGroups(); - } - - /** Test that a missing id causes an exception. */ - @Test(expected = MalformedConfiguration.class) - public void testGetCaveatGroups_missingId() - { - caveatDAOFromJSON.setConfigLocation("/alfresco/caveat/rm-caveats-missingMarkId.json"); - caveatDAOFromJSON.getCaveatGroups(); - } - - /** Test that a duplicate group id causes an exception. */ - @Test(expected = MalformedConfiguration.class) - public void testGetCaveatGroups_duplicateGroupId() - { - caveatDAOFromJSON.setConfigLocation("/alfresco/caveat/rm-caveats-duplicateGroupId.json"); - caveatDAOFromJSON.getCaveatGroups(); - } - - /** Test that a duplicate mark id (within a group) causes an exception. */ - @Test(expected = MalformedConfiguration.class) - public void testGetCaveatGroups_duplicateMarkId() - { - caveatDAOFromJSON.setConfigLocation("/alfresco/caveat/rm-caveats-duplicateMarkId.json"); - caveatDAOFromJSON.getCaveatGroups(); - } - - /** Test that a duplicate mark id (in different groups) doesn't cause an exception. */ - @Test - public void testGetCaveatGroups_duplicateMarkIdInDifferentGroups() - { - caveatDAOFromJSON.setConfigLocation("/alfresco/caveat/rm-caveats-duplicateMarkIdInDifferentGroups.json"); - Map caveatGroups = caveatDAOFromJSON.getCaveatGroups(); - assertNotNull(caveatGroups); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelConstraintUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelConstraintUnitTest.java deleted file mode 100644 index ec25624113..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelConstraintUnitTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.mockito.Mockito.doReturn; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.service.cmr.dictionary.ConstraintException; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for the {@link ClassificationLevelConstraint}. - * - * @author tpage - */ -public class ClassificationLevelConstraintUnitTest -{ - private static final ClassificationLevel LEVEL_ONE = new ClassificationLevel("id1", "DisplayKey1"); - private static final ClassificationLevel LEVEL_TWO = new ClassificationLevel("id2", "DisplayKey2"); - private static final List DEFAULT_LEVELS = Arrays.asList(LEVEL_ONE, LEVEL_TWO); - - @InjectMocks ClassificationLevelConstraint classificationLevelConstraint; - @Mock ClassificationSchemeService mockClassificationSchemeService; - - @Before - public void setUp() - { - MockitoAnnotations.initMocks(this); - - // Currently this list of levels suffices for all the tests. - doReturn(DEFAULT_LEVELS).when(mockClassificationSchemeService).getClassificationLevels(); - } - - /** Check that evaluateSingleValue throws no exceptions when an id is found. */ - @Test - public void evaluateSingleValue_valid() - { - classificationLevelConstraint.evaluateSingleValue("id1"); - } - - /** Check that evaluateSingleValue throws an exception when an id is not found. */ - @Test(expected = ConstraintException.class) - public void evaluateSingleValue_stringNotFound() - { - classificationLevelConstraint.evaluateSingleValue("non-existant id"); - } - - /** Check that evaluateSingleValue throws an exception when supplied with something that isn't a String. */ - @Test(expected = ConstraintException.class) - public void evaluateSingleValue_notString() - { - classificationLevelConstraint.evaluateSingleValue(Integer.valueOf(123)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelManagerUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelManagerUnitTest.java deleted file mode 100644 index d658f9a3da..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelManagerUnitTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.junit.Before; -import org.junit.Test; - -/** - * Unit tests for the {@link ClassificationLevelManager}. - * - * @author tpage - */ -public class ClassificationLevelManagerUnitTest -{ - private static final ClassificationLevel LEVEL_1 = new ClassificationLevel("id1", "displayLabelKey1"); - private static final ClassificationLevel LEVEL_2 = new ClassificationLevel("id2", "displayLabelKey2"); - private static final ClassificationLevel LEVEL_3 = new ClassificationLevel("id3", "displayLabelKey3"); - private static final List LEVELS = Arrays.asList(LEVEL_1, LEVEL_2, LEVEL_3); - - private ClassificationLevelManager classificationLevelManager; - - @Before public void setup() - { - classificationLevelManager = new ClassificationLevelManager(); - classificationLevelManager.setClassificationLevels(LEVELS); - } - - @Test public void findClassificationById_found() - { - ClassificationLevel actual = classificationLevelManager.findLevelById("id2"); - assertEquals(LEVEL_2, actual); - } - - @Test(expected=LevelIdNotFound.class) public void findClassificationById_notFound() - { - classificationLevelManager.findLevelById("id_unknown"); - } - - @Test public void getMostSecureLevel() - { - ClassificationLevel actual = classificationLevelManager.getMostSecureLevel(); - assertEquals(LEVEL_1, actual); - } - - /** - * Given that I have created the classification level manager with a list of classification levels - * Then the unclassified level is available - */ - @Test public void getUnclassifiedLevel() - { - assertEquals(LEVELS.size() + 1, classificationLevelManager.getClassificationLevels().size()); - assertEquals(ClassificationLevelManager.UNCLASSIFIED, classificationLevelManager.findLevelById(ClassificationLevelManager.UNCLASSIFIED_ID)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonManagerUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonManagerUnitTest.java deleted file mode 100644 index 42823e9e4f..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReasonManagerUnitTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; -import org.junit.Before; -import org.junit.Test; - -/** - * Unit tests for the {@link ClassificationReasonManager}. - * - * @author tpage - */ -public class ClassificationReasonManagerUnitTest -{ - private static final ClassificationReason REASON_1 = new ClassificationReason("id1", "displayLabelKey1"); - private static final ClassificationReason REASON_2 = new ClassificationReason("id2", "displayLabelKey2"); - private static final ClassificationReason REASON_3 = new ClassificationReason("id3", "displayLabelKey3"); - private static final List REASONS = Arrays.asList(REASON_1, REASON_2, REASON_3); - - private ClassificationReasonManager classificationReasonManager; - - @Before public void setup() - { - classificationReasonManager = new ClassificationReasonManager(); - classificationReasonManager.setClassificationReasons(REASONS); - } - - @Test public void findClassificationById_found() - { - ClassificationReason actual = classificationReasonManager.findReasonById("id2"); - assertEquals(REASON_2, actual); - } - - @Test(expected = ReasonIdNotFound.class) public void findClassificationById_notFound() - { - classificationReasonManager.findReasonById("id_unknown"); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityFactoryUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityFactoryUnitTest.java deleted file mode 100644 index 7212e3dd05..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeEntityFactoryUnitTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import org.json.JSONException; -import org.json.JSONObject; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; - - -/** - * Unit tests for the {@link ClassificationSchemeEntityFactory}. - * - * @author tpage - * @since 2.4.a - */ -public class ClassificationSchemeEntityFactoryUnitTest -{ - ClassificationSchemeEntityFactory classificationSchemeEntityFactory = new ClassificationSchemeEntityFactory(); - @Mock JSONObject mockJsonObject; - - @Before - public void setUp() - { - initMocks(this); - } - - @Test - public void testCreateClassificationLevel() throws JSONException - { - when(mockJsonObject.getString("name")).thenReturn("name1"); - when(mockJsonObject.getString("displayLabel")).thenReturn("displayLabelKey2"); - - ClassificationLevel classificationLevel = classificationSchemeEntityFactory.create(ClassificationLevel.class, mockJsonObject); - - assertEquals("name1", classificationLevel.getId()); - assertEquals("displayLabelKey2", classificationLevel.getDisplayLabelKey()); - } - - @Test - public void testCreateClassificationReason() throws JSONException - { - when(mockJsonObject.getString("id")).thenReturn("id1"); - when(mockJsonObject.getString("displayLabel")).thenReturn("displayLabelKey2"); - - ClassificationReason classificationReason = classificationSchemeEntityFactory.create(ClassificationReason.class, mockJsonObject); - - assertEquals("id1", classificationReason.getId()); - assertEquals("displayLabelKey2", classificationReason.getDisplayLabelKey()); - } - - @Test - public void testCreateExemptionCategory() throws JSONException - { - when(mockJsonObject.getString("id")).thenReturn("id1"); - when(mockJsonObject.getString("displayLabel")).thenReturn("displayLabelKey2"); - - ExemptionCategory exemptionCategory = classificationSchemeEntityFactory.create(ExemptionCategory.class, mockJsonObject); - - assertEquals("id1", exemptionCategory.getId()); - assertEquals("displayLabelKey2", exemptionCategory.getDisplayLabelKey()); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceImplUnitTest.java deleted file mode 100644 index 207d0c74f2..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationSchemeServiceImplUnitTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for {@link ClassificationSchemeServiceImpl}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ClassificationSchemeServiceImplUnitTest -{ - private static final List DEFAULT_CLASSIFICATION_LEVELS = asLevelList("Top Secret", "rm.caveat.classification.mark.ts.label", - "Secret", "rm.caveat.classification.mark.s.label", - "Confidential", "rm.caveat.classification.mark.c.label", - "No Clearance", "rm.classification.noClearance"); - - /** - * A convenience method for turning lists of level id Strings into lists - * of {@code ClassificationLevel} objects. - * - * @param idsAndLabels A varargs/array of Strings like so: [ id0, label0, id1, label1... ] - * @throws IllegalArgumentException if {@code idsAndLabels} has a non-even length. - */ - public static List asLevelList(String ... idsAndLabels) - { - if (idsAndLabels.length % 2 != 0) - { - throw new IllegalArgumentException(String.format("Cannot create %s objects with %d args.", - ClassificationLevel.class.getSimpleName(), idsAndLabels.length)); - } - - final List levels = new ArrayList<>(idsAndLabels.length / 2); - for (int i = 0; i < idsAndLabels.length; i += 2) - { - levels.add(new ClassificationLevel(idsAndLabels[i], idsAndLabels[i+1])); - } - - return levels; - } - - @InjectMocks private ClassificationSchemeServiceImpl classificationSchemeServiceImpl; - - @Mock private NodeService mockNodeService; - @Mock private DictionaryService mockDictionaryService; - @Mock private ClassificationLevelManager mockLevelManager; - @Mock private ClassificationReasonManager mockReasonManager; - @Mock private ExemptionCategoryManager mockExemptionCategoryManager; - @Captor private ArgumentCaptor> propertiesCaptor; - - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - } - - /** - * Check that restrictList returns the three lower security levels when supplied with "secret" (i.e. that it doesn't - * return "top secret"). - */ - @Test public void restrictList_filter() - { - ClassificationLevel targetLevel = new ClassificationLevel("Secret", "rm.caveat.classification.mark.s.label"); - - List actual = classificationSchemeServiceImpl.restrictList(DEFAULT_CLASSIFICATION_LEVELS, targetLevel); - - List expected = asLevelList("Secret", "rm.caveat.classification.mark.s.label", - "Confidential", "rm.caveat.classification.mark.c.label", - "No Clearance", "rm.classification.noClearance"); - assertEquals(expected, actual); - // Check that the returned list can't be modified. - ExceptionUtils.expectedException(UnsupportedOperationException.class, () -> actual.remove(0)); - } - - /** - * Check that restrictList returns an empty list when the target is not contained in the list. - */ - @Test public void restrictList_targetNotFound() - { - ClassificationLevel targetLevel = new ClassificationLevel("UnrecognisedLevel", "rm.classification.IMadeThisUp"); - - List actual = classificationSchemeServiceImpl.restrictList(DEFAULT_CLASSIFICATION_LEVELS, targetLevel); - - assertEquals("Expected an empty list when the target level is not found.", 0, actual.size()); - } - - @Test - public void getClassificationLevelById() - { - String levelId = "classificationLevelId1"; - ClassificationLevel classificationLevel = new ClassificationLevel(levelId, "displayLabelKey"); - when(mockLevelManager.findLevelById(levelId)).thenReturn(classificationLevel); - ClassificationLevel classificationLevelById = classificationSchemeServiceImpl.getClassificationLevelById(levelId); - assertEquals(classificationLevel, classificationLevelById); - } - - @Test(expected = LevelIdNotFound.class) - public void getClassificationLevelById_nonExisting() - { - String classificationLevelId = "aRandomId"; - doThrow(new LevelIdNotFound("Id not found!")).when(mockLevelManager).findLevelById(classificationLevelId); - classificationSchemeServiceImpl.getClassificationLevelById(classificationLevelId); - } - - @Test - public void getClassificationReasonById() - { - String reasonId = "classificationReasonId1"; - ClassificationReason classificationReason = new ClassificationReason(reasonId, "displayLabelKey"); - when(mockReasonManager.findReasonById(reasonId)).thenReturn(classificationReason); - ClassificationReason classificationReasonById = classificationSchemeServiceImpl.getClassificationReasonById(reasonId); - assertEquals(classificationReason, classificationReasonById); - } - - @Test(expected = ReasonIdNotFound.class) - public void getClassificationReasonById_nonExisting() - { - String classificationReasonId = "aRandomId"; - doThrow(new ReasonIdNotFound("Id not found!")).when(mockReasonManager).findReasonById(classificationReasonId); - classificationSchemeServiceImpl.getClassificationReasonById(classificationReasonId); - } - - @Test - public void getExemptionCategoryById() - { - String exemptionCategoryId = "exemptionCategoryId"; - ExemptionCategory exemptionCategory = new ExemptionCategory(exemptionCategoryId, "displayLabelKey"); - when(mockExemptionCategoryManager.findCategoryById(exemptionCategoryId)).thenReturn(exemptionCategory); - classificationSchemeServiceImpl.getExemptionCategoryById(exemptionCategoryId); - } - - @Test(expected = ExemptionCategoryIdNotFound.class) - public void getExemptionCategoryById_nonExisting() - { - String exemptionCategoryId = "aRandomId"; - doThrow(new ExemptionCategoryIdNotFound("Id not found!")).when(mockExemptionCategoryManager).findCategoryById(exemptionCategoryId); - classificationSchemeServiceImpl.getExemptionCategoryById(exemptionCategoryId); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrapUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrapUnitTest.java deleted file mode 100644 index 2367b7c3a6..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceBootstrapUnitTest.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static java.util.Arrays.asList; -import static org.apache.commons.collections.ListUtils.union; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ClassificationLevelFieldsValidator; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ClassificationReasonFieldsValidator; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ClassificationSchemeEntityValidator; -import org.alfresco.module.org_alfresco_module_rm.classification.validation.ExemptionCategoryFieldsValidator; -import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.apache.log4j.Appender; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for the {@link ClassificationServiceBootstrap}. - * - * @author tpage - */ -public class ClassificationServiceBootstrapUnitTest implements ClassifiedContentModel -{ - private static final List DEFAULT_CONFIGURED_CLASSIFICATION_LEVELS = - asLevelList("TS", "rm.caveat.classification.mark.ts.label", - "S", "rm.caveat.classification.mark.s.label", - "C", "rm.caveat.classification.mark.c.label"); - @SuppressWarnings("unchecked") - private static final List DEFAULT_CLASSIFICATION_LEVELS = - union(DEFAULT_CONFIGURED_CLASSIFICATION_LEVELS, - asLevelList("U", "rm.classification.unclassified")); - private static final List ALT_CLASSIFICATION_LEVELS = asLevelList("B", "Board", - "EM", "ExecutiveManagement", - "E", "Employee", - "P", "Public"); - private static final List PLACEHOLDER_CLASSIFICATION_REASONS = asList(new ClassificationReason("id1", "label1"), - new ClassificationReason("id2", "label2")); - private static final List ALTERNATIVE_CLASSIFICATION_REASONS = asList(new ClassificationReason("id8", "label8"), - new ClassificationReason("id9", "label9")); - private static final List EXEMPTION_CATEGORIES = asList(new ExemptionCategory("id1", "label1"), - new ExemptionCategory("id2", "label2")); - private static final List CHANGED_EXEMPTION_CATEGORIES = asList(new ExemptionCategory("id3", "label3")); - - /** - * A convenience method for turning lists of level id Strings into lists - * of {@code ClassificationLevel} objects. - * - * @param idsAndLabels A varargs/array of Strings like so: [ id0, label0, id1, label1... ] - * @throws IllegalArgumentException if {@code idsAndLabels} has a non-even length. - */ - public static List asLevelList(String ... idsAndLabels) - { - if (idsAndLabels.length % 2 != 0) - { - throw new IllegalArgumentException(String.format("Cannot create %s objects with %d args.", - ClassificationLevel.class.getSimpleName(), idsAndLabels.length)); - } - - final List levels = new ArrayList<>(idsAndLabels.length / 2); - - for (int i = 0; i < idsAndLabels.length; i += 2) - { - levels.add(new ClassificationLevel(idsAndLabels[i], idsAndLabels[i+1])); - } - - return levels; - } - - @InjectMocks ClassificationServiceBootstrap classificationServiceBootstrap; - @Mock ClassificationServiceDAO mockClassificationServiceDAO; - @Mock AttributeService mockAttributeService; - @Mock AuthenticationUtil mockAuthenticationUtil; - @Mock ExemptionCategoryManager mockExemptionCategoryManager; - @Mock ClearanceLevelManager mockClearanceLevelManager; - /** Using a mock appender in the class logger so that we can verify some of the logging requirements. */ - @Mock Appender mockAppender; - @Captor ArgumentCaptor> clearanceLevelCaptor; - - private ClassificationLevelFieldsValidator classificationLevelFieldsValidator = new ClassificationLevelFieldsValidator(); - private ClassificationSchemeEntityValidator classificationLevelValidator = new ClassificationSchemeEntityValidator<>(classificationLevelFieldsValidator); - private ClassificationReasonFieldsValidator classificationReasonFieldsValidator = new ClassificationReasonFieldsValidator(); - private ClassificationSchemeEntityValidator classificationReasonValidator = new ClassificationSchemeEntityValidator<>(classificationReasonFieldsValidator); - private ExemptionCategoryFieldsValidator exemptionCategoryFieldsValidator = new ExemptionCategoryFieldsValidator(); - private ClassificationSchemeEntityValidator exemptionCategoryValidator = new ClassificationSchemeEntityValidator<>(exemptionCategoryFieldsValidator); - - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - MockAuthenticationUtilHelper.setup(mockAuthenticationUtil); - // This seems to be necessary because the POJO managers aren't constructor arguments. - classificationServiceBootstrap.setExemptionCategoryManager(mockExemptionCategoryManager); - classificationServiceBootstrap.setClearanceLevelManager(mockClearanceLevelManager); - } - - @Test public void defaultLevelsConfigurationVanillaSystem() - { - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationLevel.class)).thenReturn(DEFAULT_CONFIGURED_CLASSIFICATION_LEVELS); - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn(null); - - classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationLevel.class, LEVELS_KEY, classificationLevelValidator); - - verify(mockAttributeService).setAttribute(eq((Serializable) DEFAULT_CONFIGURED_CLASSIFICATION_LEVELS), - anyString(), anyString(), anyString()); - } - - @Test public void levelsConfigurationChanged() - { - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationLevel.class)).thenReturn(ALT_CLASSIFICATION_LEVELS); - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())) - .thenReturn((Serializable) DEFAULT_CLASSIFICATION_LEVELS); - - List entities = classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationLevel.class, LEVELS_KEY, classificationLevelValidator); - - assertEquals(ALT_CLASSIFICATION_LEVELS, entities); - } - - @Test (expected=MissingConfiguration.class) - public void missingLevelsConfigurationVanillaSystemShouldFail() throws Exception - { - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn(null); - - classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationLevel.class, LEVELS_KEY, classificationLevelValidator); - } - - /** - * Check that we can add a classification entity after the system has been bootstrapped for the first time. - *

- * RM-2484

-     * Given a classification scheme has been installed
-     * When I add new entities into the classification scheme configuration files
-     * And I restart the server
-     * Then the new entities are installed.
-     * 
- */ - @Test public void addClassificationSchemeEntity() - { - List initialList = asLevelList("A", "Admin", "B", "Board Member"); - List correctedList = asLevelList("A", "Admin", "B", "Board Member", "C", "Common Employee"); - - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationLevel.class)).thenReturn(correctedList); - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn((Serializable) initialList); - - List entities = classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationLevel.class, LEVELS_KEY, classificationLevelValidator); - - assertEquals(correctedList, entities); - } - - /** - * Check that we can remove a classification entity after the system has been bootstrapped for the first time. - *

- * RM-2486

-     * Given a classification scheme has been installed
-     * And no content is classified using a given entity
-     * When I delete the entity from the classification scheme configuration
-     * And I restart the server
-     * Then the entity is no longer available in the system.
-     * 
- */ - @Test public void deleteUnusedClassificationSchemeEntity() - { - List initialList = asLevelList("A", "Admin", "B", "Board Member", "T", "Typo - Oops!", "C", "Common Employee"); - List correctedList = asLevelList("A", "Admin", "B", "Board Member", "C", "Common Employee"); - - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationLevel.class)).thenReturn(correctedList); - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn((Serializable) initialList); - - List entities = classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationLevel.class, LEVELS_KEY, classificationLevelValidator); - - assertEquals(correctedList, entities); - } - - @Test public void pristineSystemShouldBootstrapReasonsConfiguration() - { - // There are no classification reasons stored in the AttributeService. - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn(null); - - // We'll use a small set of placeholder classification reasons. - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationReason.class)).thenReturn(PLACEHOLDER_CLASSIFICATION_REASONS); - - classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationReason.class, REASONS_KEY, classificationReasonValidator); - - verify(mockAttributeService).setAttribute(eq((Serializable)PLACEHOLDER_CLASSIFICATION_REASONS), - anyString(), anyString(), anyString()); - } - - @Test public void checkAttributesNotTouchedIfConfiguredReasonsHaveNotChanged() - { - // The classification reasons stored are the same values that are found on the classpath. - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn((Serializable)PLACEHOLDER_CLASSIFICATION_REASONS); - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationReason.class)).thenReturn(PLACEHOLDER_CLASSIFICATION_REASONS); - - classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationReason.class, REASONS_KEY, classificationReasonValidator); - - verify(mockAttributeService, never()).setAttribute(any(Serializable.class), - anyString(), anyString(), anyString()); - } - - /** Check that if the reasons supplied on the classpath differ from those already persisted then they are changed. */ - @Test - public void changeConfiguredReasons() - { - // The classification reasons stored are different from those found on the classpath. - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn( - (Serializable) PLACEHOLDER_CLASSIFICATION_REASONS); - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationReason.class)).thenReturn(ALTERNATIVE_CLASSIFICATION_REASONS); - - // Call the method under test. - List actual = classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationReason.class, REASONS_KEY, classificationReasonValidator); - - assertEquals(ALTERNATIVE_CLASSIFICATION_REASONS, actual); - // Check the persisted values were changed. - verify(mockAttributeService).setAttribute((Serializable) ALTERNATIVE_CLASSIFICATION_REASONS, REASONS_KEY); - } - - @Test(expected = MissingConfiguration.class) - public void noReasonsFoundCausesException() - { - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())) - .thenReturn((Serializable) null); - when(mockClassificationServiceDAO.getConfiguredValues(ClassificationReason.class)).thenReturn(null); - - classificationServiceBootstrap.getConfiguredSchemeEntities(ClassificationReason.class, REASONS_KEY, classificationReasonValidator); - } - - @Test - public void testInitConfiguredExemptionCategories_firstLoad() - { - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())) - .thenReturn((Serializable) null); - when(mockClassificationServiceDAO.getConfiguredValues(ExemptionCategory.class)).thenReturn(EXEMPTION_CATEGORIES); - - List entities = classificationServiceBootstrap.getConfiguredSchemeEntities(ExemptionCategory.class, EXEMPTION_CATEGORIES_KEY, exemptionCategoryValidator); - - assertEquals(EXEMPTION_CATEGORIES, entities); - } - - @Test - public void testInitConfiguredExemptionCategories_secondLoad() - { - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())) - .thenReturn((Serializable) EXEMPTION_CATEGORIES); - when(mockClassificationServiceDAO.getConfiguredValues(ExemptionCategory.class)).thenReturn(EXEMPTION_CATEGORIES); - - List entities = classificationServiceBootstrap.getConfiguredSchemeEntities(ExemptionCategory.class, EXEMPTION_CATEGORIES_KEY, exemptionCategoryValidator); - - assertEquals(EXEMPTION_CATEGORIES, entities); - } - - /** - * Check that if the exemption categories supplied on the classpath differ from those already persisted then the new - * values are persisted. - *

- * RM-2337

-     * Given that I have already started the system once
-     * When I stop the system
-     * And modify the exemption categories
-     * And restart the system
-     * Then the new exemption categories are loaded.
-     * 
- */ - @Test - public void testInitConfiguredExemptionCategories_changedCategories() - { - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())) - .thenReturn((Serializable) EXEMPTION_CATEGORIES); - when(mockClassificationServiceDAO.getConfiguredValues(ExemptionCategory.class)).thenReturn(CHANGED_EXEMPTION_CATEGORIES); - - // Call the method under test. - List actual = classificationServiceBootstrap.getConfiguredSchemeEntities(ExemptionCategory.class, EXEMPTION_CATEGORIES_KEY, exemptionCategoryValidator); - - assertEquals(CHANGED_EXEMPTION_CATEGORIES, actual); - // Check the persisted values were changed. - verify(mockAttributeService).setAttribute((Serializable) CHANGED_EXEMPTION_CATEGORIES, EXEMPTION_CATEGORIES_KEY); - } - - @Test(expected = MissingConfiguration.class) - public void testInitConfiguredExemptionCategories_noCategoriesFound() - { - when(mockAttributeService.getAttribute(anyString(), anyString(), anyString())) - .thenReturn((Serializable) null); - when(mockClassificationServiceDAO.getConfiguredValues(ExemptionCategory.class)).thenReturn(null); - - classificationServiceBootstrap.getConfiguredSchemeEntities(ExemptionCategory.class, EXEMPTION_CATEGORIES_KEY, exemptionCategoryValidator); - } - - /** - * Check that the initialise method creates a clearance level corresponding to each classification level and that - * the display label for the lowest clearance level is "No Clearance" (rather than "Unclassified"). - */ - @Test public void initConfiguredClearanceLevels() - { - ClassificationLevel topSecret = new ClassificationLevel("1", "TopSecret"); - ClassificationLevel secret = new ClassificationLevel("2", "Secret"); - ImmutableList classificationLevels = ImmutableList.of(topSecret, secret, ClassificationLevelManager.UNCLASSIFIED); - doNothing().when(mockClearanceLevelManager).setClearanceLevels(clearanceLevelCaptor.capture()); - - // Call the method under test. - classificationServiceBootstrap.initConfiguredClearanceLevels(classificationLevels); - - List clearanceLevels = clearanceLevelCaptor.getValue(); - assertEquals("There should be one clearance level for each classification level.", classificationLevels.size(), clearanceLevels.size()); - assertEquals("TopSecret", clearanceLevels.get(0).getDisplayLabelKey()); - assertEquals("Secret", clearanceLevels.get(1).getDisplayLabelKey()); - assertEquals("rm.classification.noClearance", clearanceLevels.get(2).getDisplayLabelKey()); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceDAOUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceDAOUnitTest.java deleted file mode 100644 index 2893bd02bf..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceDAOUnitTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MalformedConfiguration; -import org.junit.Test; - -/** - * Unit tests for {@link ClassificationServiceDAO}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ClassificationServiceDAOUnitTest -{ - @Test public void getConfiguredReasons_readingDefaultConfigurationShouldWork() - { - ClassificationServiceDAO c = new ClassificationServiceDAO(); - c.setReasonConfigLocation("/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json"); - List config = c.getConfiguredValues(ClassificationReason.class); - assertFalse(config.isEmpty()); - } - - @Test public void getConfiguredReasons_readingMissingConfigurationShouldProduceEmptyConfig() throws Exception - { - ClassificationServiceDAO c = new ClassificationServiceDAO(); - c.setReasonConfigLocation("/no/such/resource"); - assertTrue(c.getConfiguredValues(ClassificationReason.class).isEmpty()); - } - - @Test (expected = MalformedConfiguration.class) - public void getConfiguredReasons_readingMalformedConfigurationShouldFail() - { - ClassificationServiceDAO c = new ClassificationServiceDAO(); - c.setReasonConfigLocation("/alfresco/classification/rm-classification-reasons-malformed.json"); - c.getConfiguredValues(ClassificationReason.class); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevelManagerUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevelManagerUnitTest.java deleted file mode 100644 index 57d33ec8c0..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClearanceLevelManagerUnitTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import com.google.common.collect.ImmutableList; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.junit.Before; -import org.junit.Test; - -/** - * Unit tests for the {@link ClearanceLevelManager}. - * - * @author tpage - */ -public class ClearanceLevelManagerUnitTest -{ - static final ClassificationLevel TOP_SECRET = new ClassificationLevel("TS", "Top Secret Classification"); - static final ClassificationLevel SECRET = new ClassificationLevel("S", "Secret Classification"); - - static final ClearanceLevel TOP_SECRET_CLEARANCE = new ClearanceLevel(TOP_SECRET , "Top Secret Clearance"); - static final ClearanceLevel SECRET_CLEARANCE = new ClearanceLevel(SECRET, "Secret Clearance"); - - /** The class under test. */ - ClearanceLevelManager clearanceLevelManager; - - /** Reset the {@code ClearanceLevelManager} with the three clearance levels. */ - @Before - public void setup() - { - List clearanceLevels = ImmutableList.of(TOP_SECRET_CLEARANCE, - SECRET_CLEARANCE, - ClearanceLevelManager.NO_CLEARANCE); - clearanceLevelManager = new ClearanceLevelManager(); - clearanceLevelManager.setClearanceLevels(clearanceLevels); - } - - /** Check that the secret clearance can be found from the classification level id "S". */ - @Test - public void findLevelByClassificationLevelId_found() - { - ClearanceLevel actual = clearanceLevelManager.findLevelByClassificationLevelId("S"); - assertEquals(SECRET_CLEARANCE, actual); - } - - /** Check that an exception is thrown when the classification level id is not found. */ - @Test(expected = LevelIdNotFound.class) - public void findLevelByClassificationLevelId_notFound() - { - clearanceLevelManager.findLevelByClassificationLevelId("UNKNOWN ID"); - } - - /** - * Given that I have created a clearance level manager from a list of clearance levels (including the no clearance level) - * Then the no clearance level is available - * - * ...(and not added in the same way as for {@link ClassificationLevelManager#setClassificationLevels(List)}). - */ - @Test public void noClearanceLevel() - { - assertEquals("The three clearance levels should be available.", 3, clearanceLevelManager.getClearanceLevels().size()); - ClearanceLevel noClearance = clearanceLevelManager.findLevelByClassificationLevelId(ClassificationLevelManager.UNCLASSIFIED_ID); - assertEquals("'No clearance' could not be found.", ClearanceLevelManager.NO_CLEARANCE, noClearance); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java deleted file mode 100644 index 86a61ec760..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateNodeRef; -import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateText; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Sets; -import org.alfresco.model.ContentModel; -import org.alfresco.model.QuickShareModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService; -import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.PersonService.PersonInfo; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for {@link ContentClassificationServiceImpl}. - * - * @author tpage - * @since 2.4.a - */ -public class ContentClassificationServiceImplUnitTest implements ClassifiedContentModel -{ - private static final String CLASSIFICATION_LEVEL_ID = "classificationLevelId"; - private static final ClassificationLevel CLASSIFICATION_LEVEL = new ClassificationLevel(CLASSIFICATION_LEVEL_ID, generateText()); - - @InjectMocks ContentClassificationServiceImpl contentClassificationServiceImpl; - @Mock ClassificationLevelManager mockLevelManager; - @Mock ClassificationReasonManager mockReasonManager; - @Mock NodeService mockNodeService; - @Mock DictionaryService mockDictionaryService; - @Mock FreezeService mockFreezeService; - @Mock SecurityClearanceService mockSecurityClearanceService; - @Mock AuthenticationUtil mockAuthenticationUtil; - @Mock ReferredMetadataService mockReferredMetadataService; - @Mock ClassificationAspectProperties mockPropertiesDTO; - @Captor ArgumentCaptor> propertiesCaptor; - - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - MockAuthenticationUtilHelper.setup(mockAuthenticationUtil); - contentClassificationServiceImpl.setAuthenticationUtil(mockAuthenticationUtil); - } - - /** Classify a piece of content with a couple of reasons and check the NodeService is called correctly. */ - @Test public void classifyContent_success() - { - // Create a level and two reasons. - ClassificationLevel level = new ClassificationLevel("levelId1", "displayLabelKey"); - ClassificationReason reason1 = new ClassificationReason("reasonId1", "displayLabelKey1"); - ClassificationReason reason2 = new ClassificationReason("reasonId2", "displayLabelKey2"); - // Set up the managers to return these objects when the ids are provided. - when(mockLevelManager.findLevelById("levelId1")).thenReturn(level); - when(mockReasonManager.findReasonById("reasonId1")).thenReturn(reason1); - when(mockReasonManager.findReasonById("reasonId2")).thenReturn(reason2); - // Create a content node. - NodeRef content = new NodeRef("fake://content/"); - when(mockDictionaryService.isSubClass(mockNodeService.getType(content), ContentModel.TYPE_CONTENT)).thenReturn(true); - when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false); - when(mockFreezeService.isFrozen(any(NodeRef.class))).thenReturn(false); - when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(true); - // Set up the mock DTO. - when(mockPropertiesDTO.getClassificationLevelId()).thenReturn("levelId1"); - when(mockPropertiesDTO.getClassifiedBy()).thenReturn("classifiedBy"); - when(mockPropertiesDTO.getClassificationAgency()).thenReturn("classificationAgency"); - when(mockPropertiesDTO.getClassificationReasonIds()).thenReturn(Sets.newHashSet("reasonId1", "reasonId2")); - - // Call the method under test - contentClassificationServiceImpl.classifyContent(mockPropertiesDTO, content); - - verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED), - propertiesCaptor.capture()); - // Check the properties that were received. - Map properties = propertiesCaptor.getValue(); - HashSet expectedPropertyKeys = Sets.newHashSet( - PROP_INITIAL_CLASSIFICATION, - PROP_CURRENT_CLASSIFICATION, - PROP_CLASSIFICATION_AGENCY, - PROP_CLASSIFIED_BY, - PROP_CLASSIFICATION_REASONS, - PROP_DOWNGRADE_DATE, - PROP_DOWNGRADE_EVENT, - PROP_DOWNGRADE_INSTRUCTIONS, - PROP_DECLASSIFICATION_DATE, - PROP_DECLASSIFICATION_EVENT, - PROP_DECLASSIFICATION_EXEMPTIONS); - assertEquals("Aspect created with unexpected set of keys.", expectedPropertyKeys, properties.keySet()); - assertEquals("Unexpected initial classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); - assertEquals("Unexpected current classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); - assertEquals("Unexpected classifiedBy.", "classifiedBy", properties.get(ClassifiedContentModel.PROP_CLASSIFIED_BY)); - assertEquals("Unexpected agency.", "classificationAgency", properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY)); - Set expectedReasonIds = Sets.newHashSet("reasonId1", "reasonId2"); - assertEquals("Unexpected set of reasons.", expectedReasonIds, properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_REASONS)); - } - - /** Classify a folder using the classifyContent method and check that an exception is raised. */ - @Test(expected = InvalidNode.class) - public void validateContent_notContent() - { - // Create a folder node. - NodeRef notAPieceOfContent = new NodeRef("not://a/piece/of/content/"); - when(mockNodeService.getType(notAPieceOfContent)).thenReturn(ContentModel.TYPE_FOLDER); - - // Call the method under test. - contentClassificationServiceImpl.validateContent(notAPieceOfContent); - } - - /** Classify a piece of content that has already been shared */ - @Test(expected = IllegalStateException.class) - public void validateContent_sharedContent() - { - NodeRef sharedContent = generateNodeRef(mockNodeService); - when(mockDictionaryService.isSubClass(mockNodeService.getType(sharedContent), ContentModel.TYPE_CONTENT)).thenReturn(true); - when(mockNodeService.hasAspect(sharedContent, QuickShareModel.ASPECT_QSHARE)).thenReturn(true); - - // Call the method under test. - contentClassificationServiceImpl.validateContent(sharedContent); - } - - /** - * Check that a user can't classify content with a level that either (a) doesn't exist, or (b) they don't have - * clearance for. (Both cases are covered by the same flow through the code). - */ - @Test(expected = LevelIdNotFound.class) - public void classifyContent_notFound() - { - // The user doesn't have level 1 clearance. - when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(false); - // Set up the mock DTO. - when(mockPropertiesDTO.getClassificationLevelId()).thenReturn("levelId1"); - when(mockPropertiesDTO.getClassifiedBy()).thenReturn("classifiedBy"); - when(mockPropertiesDTO.getClassificationAgency()).thenReturn("classificationAgency"); - when(mockPropertiesDTO.getClassificationReasonIds()).thenReturn(Sets.newHashSet("reasonId1", "reasonId2")); - - // Call the method under test. - contentClassificationServiceImpl.validateProperties(mockPropertiesDTO); - } - - /** - * Check that a user can't classify content that is frozen. - */ - @Test(expected = AccessDeniedException.class) - public void classifyContent_frozen() - { - ClassificationLevel level = new ClassificationLevel("levelId1", "displayLabelKey"); - ClassificationReason reason1 = new ClassificationReason("reasonId1", "displayLabelKey1"); - // Set up the managers to return these objects when the ids are provided. - when(mockLevelManager.findLevelById("levelId1")).thenReturn(level); - when(mockReasonManager.findReasonById("reasonId1")).thenReturn(reason1); - // Create a content node. - NodeRef content = new NodeRef("fake://content/"); - when(mockDictionaryService.isSubClass(mockNodeService.getType(content), ContentModel.TYPE_CONTENT)).thenReturn(true); - when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false); - when(mockFreezeService.isFrozen(any(NodeRef.class))).thenReturn(true); - when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(true); - // Set up the mock DTO. - when(mockPropertiesDTO.getClassificationLevelId()).thenReturn("levelId1"); - when(mockPropertiesDTO.getClassifiedBy()).thenReturn("classifiedBy"); - when(mockPropertiesDTO.getClassificationAgency()).thenReturn("classificationAgency"); - when(mockPropertiesDTO.getClassificationReasonIds()).thenReturn(Sets.newHashSet("reasonId1", "reasonId2")); - - // Call the method under test - contentClassificationServiceImpl.classifyContent(mockPropertiesDTO, content); - } - - /** - * Given that a node does not have the classify aspect applied - * When I ask for the nodes classification - * Then 'Unclassified' is returned - */ - @Test - public void getCurrentClassificationWithoutAspectApplied() - { - NodeRef nodeRef = generateNodeRef(mockNodeService); - when(mockNodeService.hasAspect(nodeRef, ClassifiedContentModel.ASPECT_CLASSIFIED)) - .thenReturn(false); - - ClassificationLevel classificationLevel = contentClassificationServiceImpl.getCurrentClassification(nodeRef); - - assertEquals(ClassificationLevelManager.UNCLASSIFIED, classificationLevel); - verify(mockNodeService).hasAspect(nodeRef, ClassifiedContentModel.ASPECT_CLASSIFIED); - verifyNoMoreInteractions(mockNodeService); - } - - /** - * Given that a node is classified - * When I ask for the node classification - * Then I get the correct classificationlevel - */ - @Test - public void getCurrentClassification() - { - NodeRef nodeRef = generateNodeRef(mockNodeService); - when(mockNodeService.hasAspect(nodeRef, ClassifiedContentModel.ASPECT_CLASSIFIED)) - .thenReturn(true); - when(mockNodeService.getProperty(nodeRef, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)) - .thenReturn(CLASSIFICATION_LEVEL_ID); - when(mockLevelManager.findLevelById(CLASSIFICATION_LEVEL_ID)) - .thenReturn(CLASSIFICATION_LEVEL); - - ClassificationLevel classificationLevel = contentClassificationServiceImpl.getCurrentClassification(nodeRef); - - assertEquals(CLASSIFICATION_LEVEL, classificationLevel); - verify(mockNodeService).hasAspect(nodeRef, ClassifiedContentModel.ASPECT_CLASSIFIED); - verify(mockNodeService).getProperty(nodeRef, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION); - verify(mockLevelManager).findLevelById(CLASSIFICATION_LEVEL_ID); - verifyNoMoreInteractions(mockNodeService, mockLevelManager); - } - - /** - * Given that the node is classified - * And the user has no security clearance - * When I ask if the current user has clearance - * Then false - */ - @Test public void userWithNoClearanceIsntClearedOnClassifiedNode() - { - // assign test classification to node - NodeRef nodeRef = generateNodeRef(mockNodeService); - when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true); - String classificationLevelId = generateText(); - when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn(classificationLevelId); - ClassificationLevel classificationLevel = new ClassificationLevel(classificationLevelId, generateText()); - when(mockLevelManager.findLevelById(classificationLevelId)).thenReturn(classificationLevel); - - // create user with no clearance - SecurityClearance clearance = new SecurityClearance(mock(PersonInfo.class), ClearanceLevelManager.NO_CLEARANCE); - when(mockSecurityClearanceService.getUserSecurityClearance()).thenReturn(clearance); - - assertFalse(contentClassificationServiceImpl.hasClearance(nodeRef)); - } - - /** - * Given that the node is classified - * And the user has clearance greater or equal to the the classification - * When I ask if the user has clearance - * Then true - */ - @Test public void classifiedNodeUserClearanceAtLeast() - { - // init classification levels - ClassificationLevel topSecret = new ClassificationLevel("TopSecret", generateText()); - String secretId = "Secret"; - ClassificationLevel secret = new ClassificationLevel(secretId, generateText()); - ClassificationLevel confidential = new ClassificationLevel("Confidential", generateText()); - List classificationLevels = Arrays.asList(topSecret, secret, confidential, ClassificationLevelManager.UNCLASSIFIED); - when(mockLevelManager.getClassificationLevels()).thenReturn(ImmutableList.copyOf(classificationLevels)); - - // set nodes classification - NodeRef nodeRef = generateNodeRef(mockNodeService); - when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true); - when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn(secretId); - when(mockLevelManager.findLevelById(secretId)).thenReturn(secret); - - // set users security clearance - when(mockSecurityClearanceService.isCurrentUserClearedForClassification("Secret")).thenReturn(true); - - assertTrue(contentClassificationServiceImpl.hasClearance(nodeRef)); - } - - /** - * Given that the node is classified - * And the user has clearance less than the classification - * When I ask if the user has clearance - * Then false - */ - @Test public void classifiedNodeUserClearanceLess() - { - // init classification levels - ClassificationLevel topSecret = new ClassificationLevel("TopSecret", generateText()); - String secretId = "Secret"; - ClassificationLevel secret = new ClassificationLevel(secretId, generateText()); - ClassificationLevel confidential = new ClassificationLevel("Confidential", generateText()); - List classificationLevels = Arrays.asList(topSecret, secret, confidential, ClassificationLevelManager.UNCLASSIFIED); - when(mockLevelManager.getClassificationLevels()).thenReturn(ImmutableList.copyOf(classificationLevels)); - - // set nodes classification - NodeRef nodeRef = generateNodeRef(mockNodeService); - when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true); - when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn(secretId); - when(mockLevelManager.findLevelById(secretId)).thenReturn(secret); - - // set users security clearance - when(mockSecurityClearanceService.isCurrentUserClearedForClassification("Secret")).thenReturn(false); - - assertFalse(contentClassificationServiceImpl.hasClearance(nodeRef)); - } - - /** - * Given that I classify a node with a level not equal to "Unclassified" - * When I ask if the node is classified - * Then return true - */ - @Test public void contentClassified_levelNotUnclassified() - { - NodeRef nodeRef = generateNodeRef(mockNodeService); - - when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn("level1"); - when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true); - - assertTrue(contentClassificationServiceImpl.isClassified(nodeRef)); - } - - /** - * Given that I classify a node with level "Unclassified" - * When I ask if the node is classified - * Then return false - */ - @Test public void contentClassified_levelUnclassified() - { - NodeRef nodeRef = generateNodeRef(mockNodeService); - - when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn(ClassificationLevelManager.UNCLASSIFIED_ID); - when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true); - - assertFalse(contentClassificationServiceImpl.isClassified(nodeRef)); - } - - /** - * Given that a node is not classified - * When I ask if the node is classified - * Then return false - */ - @Test public void contentNotClassified() - { - NodeRef nodeRef = generateNodeRef(mockNodeService); - - when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(false); - - assertFalse(contentClassificationServiceImpl.isClassified(nodeRef)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryManagerUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryManagerUnitTest.java deleted file mode 100644 index b85eda4811..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ExemptionCategoryManagerUnitTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound; -import org.junit.Before; -import org.junit.Test; - -/** - * Unit tests for the {@link ExemptionCategoryManager}. - * - * @author tpage - */ -public class ExemptionCategoryManagerUnitTest -{ - private static final ExemptionCategory CATEGORY_1 = new ExemptionCategory("id1", "displayLabelKey1"); - private static final ExemptionCategory CATEGORY_2 = new ExemptionCategory("id2", "displayLabelKey2"); - private static final ExemptionCategory CATEGORY_3 = new ExemptionCategory("id3", "displayLabelKey3"); - private static final List CATEGORIES = Arrays.asList(CATEGORY_1, CATEGORY_2, CATEGORY_3); - - private ExemptionCategoryManager exemptionCategoryManager; - - @Before public void setup() - { - exemptionCategoryManager = new ExemptionCategoryManager(); - exemptionCategoryManager.setExemptionCategories(CATEGORIES); - } - - @Test public void findClassificationById_found() - { - ExemptionCategory actual = exemptionCategoryManager.findCategoryById("id2"); - assertEquals(CATEGORY_2, actual); - } - - @Test(expected = ExemptionCategoryIdNotFound.class) public void findClassificationById_notFound() - { - exemptionCategoryManager.findCategoryById("id_unknown"); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java deleted file mode 100644 index d00517f452..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.ASPECT_SECURITY_CLEARANCE; -import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLEARANCE_LEVEL; -import static org.alfresco.util.GUID.generate; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound; -import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper; -import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.security.PersonService.PersonInfo; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import com.google.common.collect.ImmutableList; - -/** - * Unit tests for {@link SecurityClearanceServiceImpl}. - * - * @author Neil Mc Erlean - * @author David Webster - * @since 2.4.a - */ -public class SecurityClearanceServiceImplUnitTest -{ - @InjectMocks private SecurityClearanceServiceImpl securityClearanceServiceImpl; - - @Mock private AuthenticationUtil mockAuthenticationUtil; - @Mock private ClassificationLevelManager mockClassificationLevelManager; - @Mock private DictionaryService mockDictionaryService; - @Mock private NodeService mockNodeService; - @Mock private PersonService mockPersonService; - @Mock private ClassificationSchemeService mockClassificationSchemeService; - @Mock private ClearanceLevelManager mockClearanceLevelManager; - @Mock private ClassificationLevelComparator mockClassificationLevelComparator; - - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - } - - private PersonInfo createMockPerson(String userName, String firstName, String lastName, String clearanceLevel) - { - final NodeRef userNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, userName); - final PersonInfo info = new PersonInfo(userNode, userName, firstName, lastName); - - when(mockPersonService.getPerson(eq(userName), anyBoolean())).thenReturn(userNode); - when(mockPersonService.getPerson(userNode)).thenReturn(info); - - when(mockNodeService.hasAspect(userNode, ASPECT_SECURITY_CLEARANCE)).thenReturn(clearanceLevel != null); - when(mockNodeService.getProperty(userNode, PROP_CLEARANCE_LEVEL)).thenReturn(clearanceLevel); - - if (clearanceLevel != null) - { - final ClassificationLevel dummyValue = new ClassificationLevel(clearanceLevel, clearanceLevel); - when(mockClassificationLevelManager.findLevelById(clearanceLevel)).thenReturn(dummyValue); - } - - return info; - } - - @Test public void userWithNoClearanceGetsDefaultClearance() - { - final PersonInfo user1 = createMockPerson("user1", "User", "One", null); - MockAuthenticationUtilHelper.setup(mockAuthenticationUtil, user1.getUserName()); - when(mockClassificationSchemeService.getUnclassifiedClassificationLevel()) - .thenReturn(ClassificationLevelManager.UNCLASSIFIED); - when(mockClearanceLevelManager.findLevelByClassificationLevelId(ClassificationLevelManager.UNCLASSIFIED_ID)) - .thenReturn(ClearanceLevelManager.NO_CLEARANCE); - - final SecurityClearance clearance = securityClearanceServiceImpl.getUserSecurityClearance(); - - assertEquals(ClassificationLevelManager.UNCLASSIFIED, clearance.getClearanceLevel().getHighestClassificationLevel()); - - } - - /** Check that a user can have their clearance set by an authorised user. */ - @Test public void setUserSecurityClearance_setClearance() - { - // Create the user who will have their clearance set. - String userName = "User 1"; - NodeRef personNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, userName); - PersonInfo personInfo = new PersonInfo(personNode, userName, "first", "last"); - when(mockPersonService.getPerson(userName, false)).thenReturn(personNode); - when(mockPersonService.getPerson(personNode)).thenReturn(personInfo); - - // Create the authorised user. - String authorisedUserName = "authorisedUser"; - when(mockAuthenticationUtil.getRunAsUser()).thenReturn(authorisedUserName); - NodeRef authorisedPersonNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, authorisedUserName); - PersonInfo authorisedPersonInfo = new PersonInfo(authorisedPersonNode, authorisedUserName, "first", "last"); - when(mockPersonService.getPerson(authorisedUserName, false)).thenReturn(authorisedPersonNode); - when(mockPersonService.getPerson(authorisedPersonNode)).thenReturn(authorisedPersonInfo); - // The current user is not system. - when(mockAuthenticationUtil.isRunAsUserTheSystemUser()).thenReturn(false); - - // Create the clearance level. - String topSecretId = "ClearanceId"; - ClassificationLevel level = new ClassificationLevel(topSecretId, "TopSecretKey"); - ClearanceLevel clearanceLevel = new ClearanceLevel(level, "TopSecretKey"); - when(mockClearanceLevelManager.findLevelByClassificationLevelId(topSecretId)).thenReturn(clearanceLevel); - - // The authorised user is cleared to use this clearance. - when(mockNodeService.hasAspect(authorisedPersonNode, ASPECT_SECURITY_CLEARANCE)).thenReturn(true); - when(mockNodeService.getProperty(authorisedPersonNode, PROP_CLEARANCE_LEVEL)).thenReturn(topSecretId); - // The authenticated user's clearance level is at least as secure as the level being used. - when(mockClassificationLevelComparator.compare(level, level)).thenReturn(0); - - // Once the user's clearance has been set then the node service is queried about it. - when(mockNodeService.hasAspect(personNode, ASPECT_SECURITY_CLEARANCE)).thenReturn(true); - when(mockNodeService.getProperty(personNode, PROP_CLEARANCE_LEVEL)).thenReturn(topSecretId); - - // Call the method under test. - SecurityClearance securityClearance = securityClearanceServiceImpl.setUserSecurityClearance(userName, topSecretId); - - // Check the returned value. - assertEquals(personInfo, securityClearance.getPersonInfo()); - assertEquals(clearanceLevel, securityClearance.getClearanceLevel()); - // Check the value stored in the node service. - verify(mockNodeService).setProperty(personNode, PROP_CLEARANCE_LEVEL, topSecretId); - } - - /** Check that a user cannot raise someone else's clearance above their own. */ - @Test(expected = LevelIdNotFound.class) - public void setUserSecurityClearance_insufficientClearance() - { - // Create the "Top Secret" and "Confidential" clearances. - String topSecretId = "TopSecretClearanceId"; - ClassificationLevel topSecret = new ClassificationLevel(topSecretId, "TopSecretKey"); - when(mockClassificationLevelManager.findLevelById(topSecretId)).thenReturn(topSecret); - String confidentialId = "ConfidentialClearanceId"; - ClassificationLevel confidential = new ClassificationLevel(confidentialId, "ConfidentialKey"); - ClearanceLevel confidentialClearance = new ClearanceLevel(confidential, "ConfidentialKey"); - when(mockClearanceLevelManager.findLevelByClassificationLevelId(confidentialId)).thenReturn(confidentialClearance); - - // Create the user attempting to use the API with "Confidential" clearance. - String userName = "unauthorisedUser"; - when(mockAuthenticationUtil.getRunAsUser()).thenReturn(userName); - NodeRef personNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, userName); - PersonInfo personInfo = new PersonInfo(personNode, userName, "first", "last"); - when(mockPersonService.getPerson(userName, false)).thenReturn(personNode); - when(mockPersonService.getPerson(personNode)).thenReturn(personInfo); - - // The authorised user is cleared to use this clearance. - when(mockNodeService.hasAspect(personNode, ASPECT_SECURITY_CLEARANCE)).thenReturn(true); - when(mockNodeService.getProperty(personNode, PROP_CLEARANCE_LEVEL)).thenReturn(confidentialId); - // The authenticated user's clearance level not high enough. - when(mockClassificationLevelComparator.compare(confidential, topSecret)).thenReturn(-1); - - // Create the user who will have their clearance set. - String targetUserName = "Target User"; - NodeRef targetPersonNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, targetUserName); - PersonInfo targetPersonInfo = new PersonInfo(targetPersonNode, targetUserName, "first", "last"); - when(mockPersonService.getPerson(targetUserName, false)).thenReturn(targetPersonNode); - when(mockPersonService.getPerson(targetPersonNode)).thenReturn(targetPersonInfo); - - // Call the method under test and expect an exception. - securityClearanceServiceImpl.setUserSecurityClearance(targetUserName, topSecretId); - } - - /** - * Check that a user with "Secret" clearance is cleared to use the "Secret" classification. - */ - @Test public void isCurrentUserClearedForClassification_hasClearance() - { - ClassificationLevel secret = new ClassificationLevel("2", "Secret"); - when(mockClassificationLevelManager.findLevelById("2")).thenReturn(secret); - - createMockPerson("Cleared", "Cleared", "Cleared", "2"); - when(mockAuthenticationUtil.getRunAsUser()).thenReturn("Cleared"); - when(mockClearanceLevelManager.findLevelByClassificationLevelId("2")).thenReturn(new ClearanceLevel(secret, "Secret")); - - // The authenticated user's clearance level is high enough to view the classification. - when(mockClassificationLevelComparator.compare(secret, secret)).thenReturn(0); - - // Call the method under test. - boolean result = securityClearanceServiceImpl.isCurrentUserClearedForClassification("2"); - - assertTrue("A user with 'Secret' clearance should be able to access the 'Secret' classification.", result); - } - - /** - * Check that a user with no clearance is not cleared to use the "Secret" classification. - */ - @Test public void isCurrentUserClearedForClassification_noClearance() - { - ClassificationLevel secret = new ClassificationLevel("2", "Secret"); - when(mockClassificationLevelManager.findLevelById("2")).thenReturn(secret); - - createMockPerson("Uncleared", "Uncleared", "Uncleared", ClassificationLevelManager.UNCLASSIFIED_ID); - when(mockAuthenticationUtil.getRunAsUser()).thenReturn("Uncleared"); - when(mockClearanceLevelManager.findLevelByClassificationLevelId(ClassificationLevelManager.UNCLASSIFIED_ID)).thenReturn(ClearanceLevelManager.NO_CLEARANCE); - - // The authenticated user's clearance level not high enough. - when(mockClassificationLevelComparator.compare(ClassificationLevelManager.UNCLASSIFIED, secret)).thenReturn(-1); - - // Call the method under test. - boolean result = securityClearanceServiceImpl.isCurrentUserClearedForClassification("2"); - - assertFalse("A user with no clearance should not be able to access the 'Secret' classification.", result); - } - - /** - * Check that a user with "Top Secret" clearance is not cleared to use a non-existent classification. - */ - @Test public void isCurrentUserClearedForClassification_classificationNotFound() - { - ClassificationLevel topSecret = new ClassificationLevel("1", "TopSecret"); - createMockPerson("Cleared", "Cleared", "Cleared", "1"); - when(mockAuthenticationUtil.getRunAsUser()).thenReturn("Cleared"); - when(mockClearanceLevelManager.findLevelByClassificationLevelId("1")).thenReturn(new ClearanceLevel(topSecret, "TopSecret")); - // Set up the made up classification. - String madeUpId = "Made Up Id"; - when(mockClassificationLevelManager.findLevelById(madeUpId)).thenThrow(new LevelIdNotFound(madeUpId)); - - // Call the method under test. - boolean result = securityClearanceServiceImpl.isCurrentUserClearedForClassification(madeUpId); - - assertFalse("No one should be cleared to use a fictional classification.", result); - } - - /** - * Check that all levels are returned - */ - @Test public void getClearanceLevels() - { - - // Create a list of clearance levels - ImmutableList mockClearanceLevels = ImmutableList.of( - new ClearanceLevel(new ClassificationLevel("level1", "Level One"), "Clearance One"), - new ClearanceLevel(new ClassificationLevel("level2", "Level Two"), "Clearance Two"), - new ClearanceLevel(new ClassificationLevel("level3", "Level Three"), "Clearance Three") - ); - - when(mockClearanceLevelManager.getClearanceLevels()) - .thenReturn(mockClearanceLevels); - when(mockClearanceLevelManager.getMostSecureLevel()) - .thenReturn(mockClearanceLevels.get(0)); - - List actualClearanceLevels = securityClearanceServiceImpl.getClearanceLevels(); - - assertEquals(mockClearanceLevels.size(), actualClearanceLevels.size()); - assertEquals(mockClearanceLevels.get(0), actualClearanceLevels.get(0)); - assertEquals(mockClearanceLevels.get(1), actualClearanceLevels.get(1)); - assertEquals(mockClearanceLevels.get(2), actualClearanceLevels.get(2)); - } - - /** - * Check that a user with restricted access only gets some of the levels. - */ - @Test - public void getRestrictedClearanceLevels() - { - - // Create a list of clearance levels - ImmutableList mockClearanceLevels = ImmutableList.of( - new ClearanceLevel(new ClassificationLevel("level1", "Level One"), "Clearance One"), - new ClearanceLevel(new ClassificationLevel("level2", "Level Two"), "Clearance Two"), - new ClearanceLevel(new ClassificationLevel("level3", "Level Three"), "Clearance Three") - ); - - when(mockClearanceLevelManager.getClearanceLevels()).thenReturn(mockClearanceLevels); - when(mockClearanceLevelManager.getMostSecureLevel()).thenReturn(mockClearanceLevels.get(1)); - - List restrictedClearanceLevels = securityClearanceServiceImpl.getClearanceLevels(); - - assertEquals(2, restrictedClearanceLevels.size()); - assertEquals(mockClearanceLevels.get(1), restrictedClearanceLevels.get(0)); - assertEquals(mockClearanceLevels.get(2), restrictedClearanceLevels.get(1)); - } - - @Test - public void hasUserClearance() - { - // Check if the current user has clearance - PersonInfo user1 = createMockPerson(generate(), generate(), generate(), null); - MockAuthenticationUtilHelper.setup(mockAuthenticationUtil, user1.getUserName()); - assertFalse(securityClearanceServiceImpl.hasCurrentUserClearance()); - - // Check if a user with a given id has clearance - String user2 = generate(); - String classificationLevelId = generate(); - ClassificationLevel classificationLevel = new ClassificationLevel(classificationLevelId, generate()); - ClearanceLevel clearanceLevel = new ClearanceLevel(classificationLevel, generate()); - - when(mockClearanceLevelManager.findLevelByClassificationLevelId(classificationLevelId)).thenReturn(clearanceLevel); - - createMockPerson(user2, generate(), generate(), classificationLevelId); - MockAuthenticationUtilHelper.setup(mockAuthenticationUtil, user2); - assertTrue(securityClearanceServiceImpl.hasUserClearance(user2)); - } - -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/UserQueryParamsUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/UserQueryParamsUnitTest.java deleted file mode 100644 index 3c4883e031..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/UserQueryParamsUnitTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; - -import org.alfresco.service.namespace.QName; -import org.junit.Test; - -/** - * Unit tests for the {@link UserQueryParams}. - * - * @author tpage - * @since 2.4.a - */ -public class UserQueryParamsUnitTest -{ - private static final QName QNAME1 = QName.createQName("1"); - private static final QName QNAME2 = QName.createQName("2"); - - /** Check that the constructor escapes backslashes correctly. */ - @Test - public void testConstructor_backSlashes() - { - UserQueryParams userQueryParams = new UserQueryParams("\\Hello\\\\World!"); - assertEquals("\\\\Hello\\\\\\\\World!", userQueryParams.getSearchTerm()); - } - - /** Check that the constructor rejects null. */ - @Test(expected = IllegalArgumentException.class) - public void testConstructor_null() - { - new UserQueryParams(null); - } - - /** Check that providing two properties results in a list being returned. */ - @Test - public void testWithFilterProps_twoProperties() - { - UserQueryParams userQueryParams = new UserQueryParams("Search term"); - userQueryParams.withFilterProps(QNAME1, QNAME2); - assertEquals(Arrays.asList(QNAME1, QNAME2), userQueryParams.getFilterProps()); - } - - /** Check that the first parameter can't be null. */ - @Test(expected = IllegalArgumentException.class) - public void testWithFilterProps_firstPropertyNull() - { - UserQueryParams userQueryParams = new UserQueryParams("Search term"); - userQueryParams.withFilterProps(null); - } - - /** Check that providing a null after the first argument fails. */ - @Test(expected = IllegalArgumentException.class) - public void testWithFilterProps_containsNull() - { - UserQueryParams userQueryParams = new UserQueryParams("Search term"); - userQueryParams.withFilterProps(QNAME1, (QName) null); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessorUnitTest.java deleted file mode 100644 index 7dbf1ed870..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessorUnitTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.permission; - -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.util.Triple; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import com.google.common.collect.Sets; - -/** - * Classification permission pre-processor unit test - * - * @author Roy Wetherall - * @since 2.4.a - */ -public class ClassificationPermissionPreProcessorUnitTest extends BaseUnitTest -{ - /** test artifact */ - private @InjectMocks ClassificationPermissionPreProcessor processor; - - /** mocks */ - private @Mock ClassificationServiceBootstrap mockedClassificationServiceBootstrap; - private @Mock ContentClassificationService mockedContentClassificationService; - - /** test data */ - private NodeRef nodeRef; - private String perm = AlfMock.generateText(); - private String user = AlfMock.generateText(); - - @Before - @Override - public void before() throws Exception - { - super.before(); - nodeRef = generateCmContent(AlfMock.generateText()); - } - - /** - * Given that the classification hierarchy hasn't been bootstraped - * When the classification permission pre processor is executed - * Then an undetermined result will be returned - */ - @Test - public void classificationServiceNotBootstraped() - { - when(mockedClassificationServiceBootstrap.isInitialised()) - .thenReturn(false); - - assertEquals(AccessStatus.UNDETERMINED, processor.process(nodeRef, perm)); - - verify(mockedContentClassificationService, never()) - .hasClearance(nodeRef); - } - - /** - * Given that the node being evaluated is already being processed - * When the classification permission pre processor is executed - * Then an undetermined result will be returned - */ - @Test - public void nodeBeingProcessed() - { - when(mockedClassificationServiceBootstrap.isInitialised()) - .thenReturn(true); - when(mockedTransactionalResourceHelper.getSet(ClassificationPermissionPreProcessor.KEY_PROCESSING)) - .thenReturn(Sets.newHashSet(nodeRef)); - - assertEquals(AccessStatus.UNDETERMINED, processor.process(nodeRef, perm)); - - verify(mockedContentClassificationService, never()) - .hasClearance(nodeRef); - } - - /** - * Given that the node already exists in the transaction cache - * When the classification permission pre processor is executed - * Then the result will be returned from the cache - */ - @Test - public void resultAlreadyCached() - { - when(mockedClassificationServiceBootstrap.isInitialised()) - .thenReturn(true); - NodeRef notTheNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedTransactionalResourceHelper.getSet(ClassificationPermissionPreProcessor.KEY_PROCESSING)) - .thenReturn(Sets.newHashSet(notTheNodeRef)); - when(mockedAuthenticationUtil.getRunAsUser()) - .thenReturn(user); - - Map cache = new HashMap(1); - cache.put(new Triple(nodeRef, perm, user), AccessStatus.ALLOWED); - when(mockedTransactionalResourceHelper.getMap(ClassificationPermissionPreProcessor.KEY_CACHE)) - .thenReturn(cache); - - assertEquals(AccessStatus.ALLOWED, processor.process(nodeRef, perm)); - - verify(mockedContentClassificationService, never()) - .hasClearance(nodeRef); - } - - /** - * Given that the user does have clearance - * When the classification permission pre processor is executed - * Then an undetermined result will be returned - */ - @Test - public void userHasClearance() - { - when(mockedClassificationServiceBootstrap.isInitialised()) - .thenReturn(true); - NodeRef notTheNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedTransactionalResourceHelper.getSet(ClassificationPermissionPreProcessor.KEY_PROCESSING)) - .thenReturn(Sets.newHashSet(notTheNodeRef)); - when(mockedAuthenticationUtil.getRunAsUser()) - .thenReturn(user); - - Map cache = new HashMap(1); - cache.put(new Triple(notTheNodeRef, perm, user), AccessStatus.ALLOWED); - when(mockedTransactionalResourceHelper.getMap(ClassificationPermissionPreProcessor.KEY_CACHE)) - .thenReturn(cache); - - when(mockedContentClassificationService.hasClearance(nodeRef)) - .thenReturn(true); - - assertEquals(AccessStatus.UNDETERMINED, processor.process(nodeRef, perm)); - - verify(mockedContentClassificationService) - .hasClearance(nodeRef); - } - - /** - * Given that the user doesn't have clearance - * When the classification permission pre processor is executed - * Then an undetermined result will be returned - */ - @Test - public void userDoesNotHaveClearance() - { - when(mockedClassificationServiceBootstrap.isInitialised()) - .thenReturn(true); - NodeRef notTheNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedTransactionalResourceHelper.getSet(ClassificationPermissionPreProcessor.KEY_PROCESSING)) - .thenReturn(Sets.newHashSet(notTheNodeRef)); - when(mockedAuthenticationUtil.getRunAsUser()) - .thenReturn(user); - - Map cache = new HashMap(1); - cache.put(new Triple(notTheNodeRef, perm, user), AccessStatus.ALLOWED); - when(mockedTransactionalResourceHelper.getMap(ClassificationPermissionPreProcessor.KEY_CACHE)) - .thenReturn(cache); - - when(mockedContentClassificationService.hasClearance(nodeRef)) - .thenReturn(false); - - assertEquals(AccessStatus.DENIED, processor.process(nodeRef, perm)); - - verify(mockedContentClassificationService) - .hasClearance(nodeRef); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelFieldsValidatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelFieldsValidatorUnitTest.java deleted file mode 100644 index b3dafd1e7b..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationLevelFieldsValidatorUnitTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import static java.util.Arrays.asList; -import static org.alfresco.module.org_alfresco_module_rm.classification.validation.FilenameFieldValidator.ILLEGAL_ABBREVIATION_CHARS; -import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; -import static org.hamcrest.CoreMatchers.allOf; -import static org.hamcrest.core.IsCollectionContaining.hasItem; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalAbbreviationChars; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.junit.Test; - -/** - * Unit tests for the {@link ClassificationLevelFieldsValidator}. - * - * @author Neil Mc Erlean - * @author tpage - */ -public class ClassificationLevelFieldsValidatorUnitTest -{ - private final ClassificationLevelFieldsValidator validator = new ClassificationLevelFieldsValidator(); - - /** Ensures that null, empty or whitespace-only IDs are rejected. */ - @Test public void nonEmptyAbbreviationsAreMandatory() - { - // A missing or empty level ID is illegal. - for (String illegalID : asList(null, "", " ", "\t")) - { - expectedException(IllegalArgumentException.class, () -> - { - validator.validate(new ClassificationLevel(illegalID, "value.does.not.matter")); - return null; - }); - } - } - - @Test(expected=IllegalConfiguration.class) - public void systemUnclassifiedAbbreviationIsReserved() - { - validator.validate(new ClassificationLevel("U", "value.does.not.matter")); - } - - @Test(expected=IllegalConfiguration.class) - public void longAbbreviationsAreIllegal() - { - validator.validate(new ClassificationLevel("12345678901", "value.does.not.matter")); - } - - - - /** - * This test ensures that validation will catch any and all illegal characters in a - * {@link ClassificationLevel#getId() level ID} and report them all. - */ - @Test public void someCharactersAreBannedInAbbreviations() - { - for (Character illegalChar : ILLEGAL_ABBREVIATION_CHARS) - { - IllegalAbbreviationChars e = expectedException(IllegalAbbreviationChars.class, () -> - { - validator.validate(new ClassificationLevel("Hello" + illegalChar, "value.does.not.matter")); - return null; - }); - assertTrue("Exception did not contain helpful example of illegal character", - e.getIllegalChars().contains(illegalChar)); - } - - // We also expect an abbreviation with multiple illegal chars in it to have them all reported in the exception. - final List someIllegalChars = ILLEGAL_ABBREVIATION_CHARS.subList(0, 3); - - IllegalAbbreviationChars e = expectedException(IllegalAbbreviationChars.class, () -> - { - validator.validate(new ClassificationLevel(someIllegalChars.toString(), - "value.does.not.matter")); - return null; - }); - - assertThat(e.getIllegalChars(), allOf(hasItem('"'), hasItem('*'), hasItem('\\'))); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationSchemeEntityValidatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationSchemeEntityValidatorUnitTest.java deleted file mode 100644 index 45f58cabd8..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ClassificationSchemeEntityValidatorUnitTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import static java.util.Arrays.asList; -import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; -import static org.hamcrest.CoreMatchers.allOf; -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.util.Collections; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; - -/** - * Unit tests for the {@link ClassificationSchemeEntityValidator}. - * - * @author Neil Mc Erlean - * @author tpage - * @since 2.4.a - */ -public class ClassificationSchemeEntityValidatorUnitTest -{ - private static final String ENTITY_NAME = "ENTITY_NAME"; - @Mock - private EntityFieldsValidator mockFieldsValidator; - /** The class under test. */ - private ClassificationSchemeEntityValidator classificationEntitySchemeValidator = new ClassificationSchemeEntityValidator<>(mockFieldsValidator ); - - @Before - public void setUp() - { - initMocks(this); - } - - @Test(expected=MissingConfiguration.class) - public void classificationLevelsAreRequired() - { - classificationEntitySchemeValidator.validate(Collections.emptyList(), ENTITY_NAME); - } - - @Test public void ensureUniquenessOfAbbreviationIds() - { - IllegalConfiguration e = expectedException(IllegalConfiguration.class, () -> - { - List objects = asList(new ClassificationLevel("FOO", "value.does.not.matter"), - new ClassificationLevel("BAR", "value.does.not.matter"), - new ClassificationLevel("---", "value.does.not.matter"), - new ClassificationLevel("BAR", "value.does.not.matter"), - new ClassificationLevel("FOO", "value.does.not.matter")); - classificationEntitySchemeValidator.validate(objects, ENTITY_NAME); - return null; - }); - assertThat("Exception message did not identify the duplicate IDs", e.getMessage(), - allOf(containsString("FOO"), containsString("BAR"))); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ExemptionCategoryFieldsValidatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ExemptionCategoryFieldsValidatorUnitTest.java deleted file mode 100644 index 865eaac1fc..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/ExemptionCategoryFieldsValidatorUnitTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory; -import org.junit.Test; - -/** - * Unit tests for the {@link ExemptionCategoryFieldsValidator}. - * - * @author Oana Nechiforescu - * @since 2.4.a - */ -public class ExemptionCategoryFieldsValidatorUnitTest -{ - /** Exemption category fields validator */ - ExemptionCategoryFieldsValidator exemptionCategoryFieldsValidator = new ExemptionCategoryFieldsValidator(); - - @Test(expected = IllegalArgumentException.class) - public void testMissingExemptionCategoryID() - { - ExemptionCategory exemptionCategory = new ExemptionCategory("", "label"); - exemptionCategoryFieldsValidator.validate(exemptionCategory); - } - - @Test(expected = IllegalArgumentException.class) - public void testMissingExemptionCategoryLabel() - { - ExemptionCategory exemptionCategory = new ExemptionCategory("12@1", ""); - exemptionCategoryFieldsValidator.validate(exemptionCategory); - } - - @Test(expected = IllegalConfiguration.class) - public void testExemptionIDStartingWithNonAlphanumericCharacter() - { - ExemptionCategory exemptionCategory = new ExemptionCategory(" 12", "critical"); - exemptionCategoryFieldsValidator.validate(exemptionCategory); - } -} \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/LengthFieldValidatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/LengthFieldValidatorUnitTest.java deleted file mode 100644 index 1931d86f41..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/LengthFieldValidatorUnitTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration; -import org.junit.Test; - -/** - * Unit tests for the {@link LengthFieldValidator}. - * - * @author tpage - * @since 2.4.a - */ -public class LengthFieldValidatorUnitTest -{ - private static final String FIELD_NAME = "FIELD_NAME"; - /** The class under test. */ - LengthFieldValidator lengthFieldValidator; - - @Test - public void testValidate_passMinOnly() - { - lengthFieldValidator = new LengthFieldValidator(1); - lengthFieldValidator.validate("acceptable", FIELD_NAME); - } - - @Test(expected = MissingConfiguration.class) - public void testValidate_missingConfiguration() - { - lengthFieldValidator = new LengthFieldValidator(1); - lengthFieldValidator.validate("", FIELD_NAME); - } - - @Test(expected = IllegalConfiguration.class) - public void testValidate_tooShort() - { - lengthFieldValidator = new LengthFieldValidator(6); - lengthFieldValidator.validate("short", FIELD_NAME); - } - - @Test - public void testValidate_passMinAndMax() - { - lengthFieldValidator = new LengthFieldValidator(5,5); - lengthFieldValidator.validate("super", FIELD_NAME); - } - - @Test(expected = IllegalConfiguration.class) - public void testValidate_tooLong() - { - lengthFieldValidator = new LengthFieldValidator(6, 7); - lengthFieldValidator.validate("too long", FIELD_NAME); - } - - @Test(expected = IllegalArgumentException.class) - public void testValidate_invalidArguments() - { - lengthFieldValidator = new LengthFieldValidator(3, 1); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/StartCharacterFieldValidatorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/StartCharacterFieldValidatorUnitTest.java deleted file mode 100644 index e4b7d834ce..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/validation/StartCharacterFieldValidatorUnitTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.classification.validation; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration; -import org.junit.Test; - -/** - * Unit tests for the {@link StartCharacterFieldValidator}. - * - * @author tpage - * @since 2.4.a - */ -public class StartCharacterFieldValidatorUnitTest -{ - private static final String FIELD_NAME = "FIELD_NAME"; - /** The class under test. */ - StartCharacterFieldValidator startCharacterFieldValidator = new StartCharacterFieldValidator(); - - @Test - public void testValidate_pass() - { - startCharacterFieldValidator.validate("acceptable!", FIELD_NAME); - } - - @Test(expected = IllegalConfiguration.class) - public void testValidate_fail() - { - startCharacterFieldValidator.validate("!unacceptable", FIELD_NAME); - } - - @Test - public void testValidate_passIfEmpty() - { - startCharacterFieldValidator.validate(null, FIELD_NAME); - startCharacterFieldValidator.validate("", FIELD_NAME); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponentUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponentUnitTest.java deleted file mode 100644 index 56a6ad674e..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponentUnitTest.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.content; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.content.cleanser.ContentCleanser; -import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -/** - * Content destruction component unit test. - * - * @author Roy Wetherall - * @since 2.4.a - */ -public class ContentDestructionComponentUnitTest extends BaseUnitTest -{ - @InjectMocks private ContentDestructionComponent contentDestructionComponent; - - @Mock private ContentClassificationService mockedContentClassificationService; - @Mock private ContentCleanser mockedContentCleanser; - @Mock private EagerContentStoreCleaner mockedEagerContentStoreCleaner; - - /** - * Given a non-sensitive node - * When it is deleted - * Then nothing happens - */ - @Test - public void deleteNonSensitiveNode() - { - NodeRef nodeRef = generateCmContent("myContent.txt"); - - when(mockedRecordService.isRecord(nodeRef)) - .thenReturn(false); - when(mockedContentClassificationService.isClassified(nodeRef)) - .thenReturn(false); - - contentDestructionComponent.beforeDeleteNode(nodeRef); - - verifyZeroInteractions(mockedEagerContentStoreCleaner, mockedDictionaryService); - } - - /** - * Given a record - * And that by default cleansing is off - * When it is deleted - * Then it is sent for immediate destruction - * And not cleansed - */ - @Test - public void deleteRecord() - { - String contentURL = AlfMock.generateText(); - NodeRef nodeRef = generateDeletedNodeRef(contentURL); - - when(mockedRecordService.isRecord(nodeRef)) - .thenReturn(true); - when(mockedContentClassificationService.isClassified(nodeRef)) - .thenReturn(false); - - contentDestructionComponent.beforeDeleteNode(nodeRef); - - verify(mockedEagerContentStoreCleaner).registerOrphanedContentUrl(contentURL, true); - } - - /** - * Given classified content - * And that by default cleansing is off - * When it is deleted - * Then it is send for immediate destruction - * And not cleansed - */ - @Test - public void deleteClassifiedContent() - { - String contentURL = AlfMock.generateText(); - NodeRef nodeRef = generateDeletedNodeRef(contentURL); - - when(mockedRecordService.isRecord(nodeRef)) - .thenReturn(false); - when(mockedContentClassificationService.isClassified(nodeRef)) - .thenReturn(true); - - contentDestructionComponent.beforeDeleteNode(nodeRef); - - verify(mockedEagerContentStoreCleaner).registerOrphanedContentUrl(contentURL, true); - } - - /** - * Given that content cleansing is turned on - * When a sensitive node is deleted - * Then it is scheduled for cleansing before destruction - */ - @Test - public void contentCleansingOn() - { - String contentURL = AlfMock.generateText(); - NodeRef nodeRef = generateDeletedNodeRef(contentURL); - - when(mockedRecordService.isRecord(nodeRef)) - .thenReturn(false); - when(mockedContentClassificationService.isClassified(nodeRef)) - .thenReturn(true); - - contentDestructionComponent.setCleansingEnabled(true); - contentDestructionComponent.beforeDeleteNode(nodeRef); - - verify(mockedEagerContentStoreCleaner).registerOrphanedContentUrlForCleansing(contentURL); - } - - /** - * Given that content cleansing is turned off - * When a sensitive node is deleted - * Then it is not scheduled for cleansing before destruction - */ - @Test - public void contentCleansingOff() - { - String contentURL = AlfMock.generateText(); - NodeRef nodeRef = generateDeletedNodeRef(contentURL); - - when(mockedRecordService.isRecord(nodeRef)) - .thenReturn(false); - when(mockedContentClassificationService.isClassified(nodeRef)) - .thenReturn(true); - - contentDestructionComponent.setCleansingEnabled(false); - contentDestructionComponent.beforeDeleteNode(nodeRef); - - verify(mockedEagerContentStoreCleaner).registerOrphanedContentUrl(contentURL, true); - - } - - /** - * Given that a sensitive node has more than one content property - * When is it deleted - * Then all the content properties are scheduled for destruction - */ - @Test - public void moreThanOneContentProperty() - { - String contentURL = AlfMock.generateText(); - NodeRef nodeRef = generateDeletedNodeRef(contentURL, 2); - - when(mockedRecordService.isRecord(nodeRef)) - .thenReturn(false); - when(mockedContentClassificationService.isClassified(nodeRef)) - .thenReturn(true); - - contentDestructionComponent.setCleansingEnabled(true); - contentDestructionComponent.beforeDeleteNode(nodeRef); - - verify(mockedEagerContentStoreCleaner, times(2)).registerOrphanedContentUrlForCleansing(contentURL); - - } - - /** - * Helper method that creates deleted node reference - */ - private NodeRef generateDeletedNodeRef(String contentURL) - { - return generateDeletedNodeRef(contentURL, 1); - } - - /** - * Helper method that creates deleted node reference - */ - private NodeRef generateDeletedNodeRef(String contentURL, int contentPropertiesCount) - { - NodeRef nodeRef = generateCmContent("myContent.txt"); - - ContentData mockedContentData = mock(ContentData.class); - when(mockedContentData.getContentUrl()) - .thenReturn(contentURL); - - Map propertiesMap = new HashMap(contentPropertiesCount); - for(int i = 0; i < contentPropertiesCount; i++) - { - propertiesMap.put(AlfMock.generateQName(), mockedContentData); - } - - when(mockedNodeService.getProperties(nodeRef)) - .thenReturn(propertiesMap); - - return nodeRef; - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspectUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspectUnitTest.java deleted file mode 100644 index 0d2729b503..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspectUnitTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.model.clf.aspect; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import org.alfresco.model.RenditionModel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingDowngradeInstructions; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService; -import org.alfresco.module.org_alfresco_module_rm.util.CoreServicesExtras; -import org.alfresco.service.cmr.rendition.RenditionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Date; - -/** - * Unit tests for the {@link ClassifiedAspect}. - * - * @author Tom Page - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ClassifiedAspectUnitTest implements ClassifiedContentModel -{ - private static final NodeRef NODE_REF = new NodeRef("node://Ref/"); - private static final NodeRef RENDITION_1 = new NodeRef("node://rendition1/"); - private static final NodeRef RENDITION_2 = new NodeRef("node://rendition2/"); - - @InjectMocks ClassifiedAspect classifiedAspect; - @Mock ClassificationSchemeService mockClassificationSchemeService; - @Mock CoreServicesExtras mockCoreServicesExtras; - @Mock NodeService mockNodeService; - @Mock RenditionService mockRenditionService; - @Mock ReferralAdminService mockReferralAdminService; - - @Before - public void setUp() - { - initMocks(this); - } - - /** Check that providing an event and instructions is valid. */ - @Test - public void testCheckConsistencyOfProperties_success() - { - when(mockNodeService.hasAspect(NODE_REF, ASPECT_CLASSIFIED)).thenReturn(true); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_DATE)).thenReturn(null); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_EVENT)).thenReturn("Event"); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_INSTRUCTIONS)).thenReturn("Instructions"); - - classifiedAspect.checkConsistencyOfProperties(NODE_REF); - } - - /** Check that omitting all downgrade fields is valid. */ - @Test - public void testCheckConsistencyOfProperties_notSpecified() - { - when(mockNodeService.hasAspect(NODE_REF, ASPECT_CLASSIFIED)).thenReturn(true); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_DATE)).thenReturn(null); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_EVENT)).thenReturn(null); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_INSTRUCTIONS)).thenReturn(null); - - classifiedAspect.checkConsistencyOfProperties(NODE_REF); - } - - /** Check that a date without instructions throws an exception. */ - @Test(expected = MissingDowngradeInstructions.class) - public void testCheckConsistencyOfProperties_dateMissingInstructions() - { - when(mockNodeService.hasAspect(NODE_REF, ASPECT_CLASSIFIED)).thenReturn(true); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_DATE)).thenReturn(new Date(123)); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_EVENT)).thenReturn(null); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_INSTRUCTIONS)).thenReturn(null); - - classifiedAspect.checkConsistencyOfProperties(NODE_REF); - } - - /** Check that an event without instructions throws an exception. */ - @Test(expected = MissingDowngradeInstructions.class) - public void testCheckConsistencyOfProperties_eventMissingInstructions() - { - when(mockNodeService.hasAspect(NODE_REF, ASPECT_CLASSIFIED)).thenReturn(true); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_DATE)).thenReturn(null); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_EVENT)).thenReturn("Event"); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_INSTRUCTIONS)).thenReturn(null); - - classifiedAspect.checkConsistencyOfProperties(NODE_REF); - } - - /** Check that blank instructions are treated in the same way as null instructions. */ - @Test(expected = MissingDowngradeInstructions.class) - public void testCheckConsistencyOfProperties_emptyStringsSupplied() - { - for (NodeRef n : asList(NODE_REF, RENDITION_1, RENDITION_2)) - { - when(mockNodeService.hasAspect(n, ASPECT_CLASSIFIED)).thenReturn(true); - } - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_DATE)).thenReturn(""); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_EVENT)).thenReturn("Event"); - when(mockNodeService.getProperty(NODE_REF, PROP_DOWNGRADE_INSTRUCTIONS)).thenReturn(""); - - classifiedAspect.checkConsistencyOfProperties(NODE_REF); - } - - @Test public void newlyClassifiedNodeShouldLinkItsMetadataToAllRenditions() - { - when(mockRenditionService.getRenditions(NODE_REF)) - .thenReturn(asList(rendition(NODE_REF, RENDITION_1), rendition(NODE_REF, RENDITION_2))); - for (final NodeRef rendition : asList(RENDITION_1, RENDITION_2)) - { - when(mockRenditionService.getSourceNode(rendition)).thenReturn(rendition(NODE_REF, rendition)); - } - - classifiedAspect.onAddAspect(NODE_REF, ASPECT_CLASSIFIED); - - for (NodeRef rendition : asList(RENDITION_1, RENDITION_2)) - { - verify(mockReferralAdminService).attachReferrer(rendition, NODE_REF, ASPECT_CLASSIFIED); - } - } - - /** Creates a test Rendition ChildAssociationRef. */ - private ChildAssociationRef rendition(NodeRef source, NodeRef rendition) - { - return new ChildAssociationRef(RenditionModel.ASSOC_RENDITION, source, RenditionModel.ASSOC_RENDITION, rendition); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/MetadataReferralUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/MetadataReferralUnitTest.java deleted file mode 100644 index 1f9210608b..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/MetadataReferralUnitTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static java.util.Collections.emptySet; -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.InvalidMetadataReferral; -import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; -import static org.alfresco.module.org_alfresco_module_rm.test.util.FPUtils.asListFrom; -import static org.alfresco.module.org_alfresco_module_rm.test.util.FPUtils.asSet; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.AssociationDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for {@link MetadataReferral}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class MetadataReferralUnitTest -{ - @Mock DictionaryService mockDictionaryService; - @Mock NodeService mockNodeService; - - private final ReferralAdminServiceImpl referralAdminService = new ReferralAdminServiceImpl(); - - private final QName aspect1 = QName.createQName("test", "aspect1"); - private final QName aspect2 = QName.createQName("test", "aspect2"); - private final QName assoc1 = QName.createQName("test", "assoc1"); - - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - - referralAdminService.setNodeService(mockNodeService); - } - - @Test public void nullOrEmptyReferralsAreForbidden() - { - asListFrom(() -> new MetadataReferral(), - () -> { - MetadataReferral mr = new MetadataReferral(); - mr.setAssocType(assoc1); - mr.setAspects(null); - mr.setDictionaryService(mockDictionaryService); - return mr; - }, - () -> { - MetadataReferral mr = new MetadataReferral(); - mr.setAssocType(assoc1); - mr.setAspects(emptySet()); - mr.setDictionaryService(mockDictionaryService); - return mr; - }, - () -> { - MetadataReferral mr = new MetadataReferral(); - mr.setAssocType(null); - mr.setAspects(asSet(aspect1, aspect2)); - mr.setDictionaryService(mockDictionaryService); - return mr; - }) - .forEach(mr -> expectedException(InvalidMetadataReferral.class, () -> { - mr.validateAndRegister(); - return null; - }) - ); - } - - @Test(expected=InvalidMetadataReferral.class) - public void referralMustHaveAssocThatExists() - { - when(mockDictionaryService.getAssociation(assoc1)).thenReturn(null); - when(mockDictionaryService.getAspect(aspect1)).thenReturn(mock(AspectDefinition.class)); - - MetadataReferral mr = new MetadataReferral(); - mr.setAssocType(assoc1); - mr.setAspects(asSet(aspect1)); - mr.setDictionaryService(mockDictionaryService); - mr.validateAndRegister(); - } - - @Test(expected=InvalidMetadataReferral.class) - public void referralMustHaveAspectsAllOfWhichExist() - { - when(mockDictionaryService.getAssociation(assoc1)).thenReturn(mock(AssociationDefinition.class)); - when(mockDictionaryService.getAspect(aspect1)).thenReturn(mock(AspectDefinition.class)); - when(mockDictionaryService.getAspect(aspect2)).thenReturn(null); - - MetadataReferral mr = new MetadataReferral(); - mr.setAssocType(assoc1); - mr.setAspects(asSet(aspect1, aspect2)); - mr.setDictionaryService(mockDictionaryService); - mr.validateAndRegister(); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImplUnitTest.java deleted file mode 100644 index f5388c9f06..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImplUnitTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static java.util.Arrays.asList; -import static org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.ChainedMetadataReferralUnsupported; -import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; -import static org.alfresco.module.org_alfresco_module_rm.test.util.FPUtils.asSet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for {@link ReferralAdminServiceImpl}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReferralAdminServiceImplUnitTest -{ - @InjectMocks private final ReferralAdminServiceImpl referralAdminService = new ReferralAdminServiceImpl(); - - @Mock DictionaryService mockDictionaryService; - @Mock NodeService mockNodeService; - @Mock ReferralRegistry mockRegistry; - @Mock ReferredMetadataServiceImpl mockReferredMetadataService; - - private final NodeRef node1 = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "node1"); - private final NodeRef node2 = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "node2"); - private final NodeRef node3 = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "node3"); - - private final QName assoc1 = QName.createQName("test", "assoc1"); - private final QName aspect1 = QName.createQName("test", "aspect1"); - private final QName aspect2 = QName.createQName("test", "aspect2"); - - private final QName assoc2 = QName.createQName("test", "assoc2"); - private final QName aspect3 = QName.createQName("test", "aspect3"); - - private final MetadataReferral referral1 = new MetadataReferral() - {{ - this.setAssocType(assoc1); - this.setAspects(asSet(aspect1, aspect2)); - }}; - private final MetadataReferral referral2 = new MetadataReferral() - {{ - this.setAssocType(assoc2); - this.setAspects(asSet(aspect3)); - }}; - - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - - when(mockRegistry.getMetadataReferrals()).thenReturn(asSet(referral1, referral2)); - } - - @Test(expected=IllegalArgumentException.class) - public void attachingReferrerWithNoAspectConfiguredShouldFail() - { - referralAdminService.attachReferrer(node2, node1, aspect1); - } - - @Test public void attachDetach() - { - when(mockRegistry.getReferralForAspect(aspect1)).thenReturn(referral1); - - // attach - MetadataReferral d = attachReferrer(node1, node2, aspect1); - - // validate - assertEquals(assoc1, d.getAssocType()); - assertEquals(asSet(aspect1, aspect2), d.getAspects()); - assertTrue(mockReferredMetadataService.isReferringMetadata(node1, aspect1)); - assertFalse(mockReferredMetadataService.isReferringMetadata(node1, aspect3)); - - // detach - assertEquals(d, referralAdminService.detachReferrer(node1, aspect1)); - } - - private MetadataReferral attachReferrer(NodeRef referrer, NodeRef referent, QName aspectName) - { - MetadataReferral mr = referralAdminService.attachReferrer(referrer, referent, aspectName); - final QName assocType = mr.getAssocType(); - when(mockNodeService.getSourceAssocs(referent, assocType)).thenReturn(asList(new AssociationRef(referrer, assocType, referent))); - when(mockNodeService.getTargetAssocs(referrer, assocType)).thenReturn(asList(new AssociationRef(referrer, assocType, referent))); - for (QName aspect : mr.getAspects()) - { - when(mockReferredMetadataService.isReferringMetadata(referrer, aspect)).thenReturn(true); - } - return mr; - } - - @Test public void chainsOfDelegationShouldBePrevented() - { - when(mockRegistry.getReferralForAspect(aspect1)).thenReturn(referral1); - - // The node already has a delegation in place: node1 -> node2. We're trying to add to the - // end of the chain: node2 -> node3 - when(mockNodeService.getSourceAssocs(node2, assoc1)).thenReturn(asList(new AssociationRef(node1, assoc1, node2))); - when(mockNodeService.getTargetAssocs(node1, assoc1)).thenReturn(asList(new AssociationRef(node1, assoc1, node2))); - - expectedException(ChainedMetadataReferralUnsupported.class, () -> { - referralAdminService.attachReferrer(node2, node3, aspect1); - return null; - }); - - // Now try to add to the start of the chain: node3 -> node1 - expectedException(ChainedMetadataReferralUnsupported.class, () -> { - referralAdminService.attachReferrer(node3, node1, aspect1); - return null; - }); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataServiceImplUnitTest.java deleted file mode 100644 index 4fd2a5eb7a..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferredMetadataServiceImplUnitTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.referredmetadata; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyMap; -import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; -import static org.alfresco.module.org_alfresco_module_rm.test.util.FPUtils.asSet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.MetadataReferralNotFound; -import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataException.ReferentNodeNotFound; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Unit tests for {@link ReferredMetadataServiceImpl}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class ReferredMetadataServiceImplUnitTest -{ - @InjectMocks private final ReferredMetadataServiceImpl referredMetadataService = new ReferredMetadataServiceImpl(); - - @Mock DictionaryService mockDictionaryService; - @Mock NodeService mockNodeService; - @Mock ReferralAdminServiceImpl mockReferralAdminService; - @Mock ReferralRegistry mockReferralRegistry; - - /** This node has a referent node. */ - private final NodeRef referringNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "referringNode"); - /** This is the referent for {@link #referringNode}. */ - private final NodeRef referentNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "referentNode"); - /** This node has no referent node. */ - private final NodeRef nodeWithoutReferent = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "nodeWithoutReferent"); - - /** The type of the peer association that links the referringNode to its source. */ - private final QName referralAssocType = QName.createQName("test", "referralAssocType"); - /** The instance of the association between {@link #referringNode} and {@link #referentNode}. */ - private final AssociationRef attachedReferralAssocRef = new AssociationRef(referringNode, referralAssocType, referentNode); - - /** Name of an aspect that has been referred. */ - private final QName referredAspect1 = QName.createQName("test", "referredAspect1"); - /** Name of an aspect that has been referred. */ - private final QName referredAspect2 = QName.createQName("test", "referredAspect2"); - /** Name of a content class (a type in this case) that has not been referred. - * N.B. Types can't be referred currently. */ - private final QName unreferredType = QName.createQName("test", "unreferredType"); - - private final QName referredProp = QName.createQName("test", "referredProp"); - private final Serializable referredPropValue = "hello"; - private final QName unreferredProp = QName.createQName("test", "unreferredProp"); - - private final MetadataReferral referral = new MetadataReferral() - {{ - this.setAssocType(referralAssocType); - this.setAspects(asSet(referredAspect1, referredAspect2)); - }}; - - @SuppressWarnings("serial") - @Before public void setUp() - { - MockitoAnnotations.initMocks(this); - - final PropertyDefinition aspectProp = mock(PropertyDefinition.class); - final ClassDefinition aspectDefn = mock(ClassDefinition.class); - when(aspectDefn.getName()).thenReturn(referredAspect1); - when(aspectProp.getContainerClass()).thenReturn(aspectDefn); - when(aspectDefn.isAspect()).thenReturn(true); - - final PropertyDefinition typeProp = mock(PropertyDefinition.class); - final ClassDefinition typeDefn = mock(ClassDefinition.class); - when(typeDefn.getName()).thenReturn(unreferredType); - when(typeProp.getContainerClass()).thenReturn(typeDefn); - when(typeDefn.isAspect()).thenReturn(false); - - when(mockDictionaryService.getProperty(referredProp)).thenReturn(aspectProp); - - when(mockReferralAdminService.getAttachedReferralsFrom(referringNode)).thenReturn(asSet(referral)); - for (QName referredAspect : asSet(referredAspect1, referredAspect2)) - { - when(mockReferralRegistry.getReferralForAspect(referredAspect)).thenReturn(referral); - when(mockNodeService.hasAspect(referentNode, referredAspect)).thenReturn(true); - } - when(mockNodeService.getSourceAssocs(referentNode, referralAssocType)).thenReturn(asList(attachedReferralAssocRef)); - when(mockNodeService.getTargetAssocs(referringNode, referralAssocType)).thenReturn(asList(attachedReferralAssocRef)); - when(mockNodeService.exists(any(NodeRef.class))).thenReturn(true); - when(mockNodeService.getProperties(referentNode)) - .thenReturn(new HashMap() - {{ - this.put(referredProp, referredPropValue); - }}); - } - - @Test public void isReferringMetadata() - { - assertTrue(referredMetadataService.isReferringMetadata(referringNode, referredAspect1)); - expectedException(MetadataReferralNotFound.class, - () -> referredMetadataService.isReferringMetadata(nodeWithoutReferent, unreferredType)); - assertFalse(referredMetadataService.isReferringMetadata(nodeWithoutReferent, referredAspect1)); - } - - @Test public void getReferentNode() - { - assertEquals(referentNode, referredMetadataService.getReferentNode(referringNode, referredAspect1)); - expectedException(MetadataReferralNotFound.class, - () -> { - referredMetadataService.getReferentNode(referringNode, unreferredType); - return null; - }); - assertNull(referredMetadataService.getReferentNode(nodeWithoutReferent, referredAspect1)); - } - - @Test public void getReferredProperties() - { - final Map expectedProps = new HashMap<>(); - expectedProps.put(referredProp, referredPropValue); - - assertEquals(expectedProps, referredMetadataService.getReferredProperties(referringNode, referredAspect1)); - - expectedException(MetadataReferralNotFound.class, - () -> referredMetadataService.getReferredProperties(referringNode, unreferredType)); - - expectedException(ReferentNodeNotFound.class, - () -> referredMetadataService.getReferredProperties(nodeWithoutReferent, referredAspect1)); - } - - @Test public void getReferredProperty() - { - assertEquals(referredPropValue, referredMetadataService.getReferredProperty(referringNode, referredProp)); - - expectedException(IllegalArgumentException.class, - () -> referredMetadataService.getReferredProperty(referringNode, unreferredProp)); - - expectedException(MetadataReferralNotFound.class, - () -> referredMetadataService.getReferredProperties(nodeWithoutReferent, referredProp)); - } - - @Test public void hasReferredAspect() - { - assertTrue(referredMetadataService.hasReferredAspect(referringNode, referredAspect1)); - - expectedException(MetadataReferralNotFound.class, - () -> referredMetadataService.hasReferredAspect(referringNode, unreferredType)); - - expectedException(ReferentNodeNotFound.class, - () -> referredMetadataService.hasReferredAspect(nodeWithoutReferent, referredAspect1)); - } - - @Test public void getAttachedReferrals() - { - final Map expectedReferrals = new HashMap<>(); - expectedReferrals.put(referral, referentNode); - - assertEquals(expectedReferrals, referredMetadataService.getAttachedReferrals(referringNode)); - assertEquals(emptyMap(), referredMetadataService.getAttachedReferrals(nodeWithoutReferent)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassificationLevelsGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassificationLevelsGetUnitTest.java deleted file mode 100644 index 4173b766c7..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassificationLevelsGetUnitTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Tests for the get classification levels API. - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassificationLevelsGetUnitTest extends BaseWebScriptUnitTest -{ - /** Classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/classificationlevels.get.json.ftl"; - - /** ClassificationLevelsGet webscript instance */ - private @Spy @InjectMocks ClassificationLevelsGet webScript; - private @Mock ClassificationSchemeService mockClassificationSchemeService; - - private List classificationLevels; - - /** {@inheritDoc} */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** {@inheritDoc} */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test the successful retrieval of two classification levels. - */ - @Test - public void getClassificationLevels() throws Exception - { - // Create test data. - classificationLevels = Arrays.asList( - new ClassificationLevel("id1", "labelKey1"), - new ClassificationLevel("id2", "labelKey2")); - - // setup interactions - doReturn(classificationLevels).when(mockClassificationSchemeService).getClassificationLevels(); - - // execute web script - JSONObject json = executeJSONWebScript(new HashMap()); - assertNotNull(json); - String actualJSONString = json.toString(); - - // check the JSON result using Jackson to allow easy equality testing. - ObjectMapper mapper = new ObjectMapper(); - String expectedJSONString = "{\"data\":{\"items\":[{\"displayLabel\":\"labelKey1\",\"id\":\"id1\"},{\"displayLabel\":\"labelKey2\",\"id\":\"id2\"}]}}"; - JsonNode expected = mapper.readTree(expectedJSONString); - assertEquals(expected, mapper.readTree(actualJSONString)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java deleted file mode 100644 index 8929bbf2fe..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFICATION_AGENCY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFICATION_LEVEL_ID; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFICATION_REASONS; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.CLASSIFIED_BY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.LAST_RECLASSIFY_BY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.LAST_RECLASSIFY_REASON; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.RECLASSIFY_BY; -import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentBase.RECLASSIFY_REASON; -import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; -import static org.alfresco.util.WebScriptUtils.is4xxError; -import static org.alfresco.util.WebScriptUtils.putValuetoJSONObject; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.Map; - -import com.google.common.collect.Sets; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationAspectProperties; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReasonManager; -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.WebScriptException; - -/** - * Classify content REST API POST implementation unit test. - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest -{ - /** Classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/classifycontent.post.json.ftl"; - - /** Constants */ - private static final String STORE_TYPE = "store_type"; - private static final String STORE_ID = "store_id"; - private static final String ID = "id"; - private static final String SUCCESS = "success"; - private static final String LEVEL_ID = "aLevelId"; - private static final String BY = "bySomeone"; - private static final String AGENCY = "anAgency"; - private static final String REASON1_ID = "reason1Id"; - private static final String REASON2_ID = "reason2Id"; - - /** ClassifyContentPost webscript instance */ - private @Spy @InjectMocks ClassifyContentPost webScript; - - /** Mocked content classification service */ - private @Mock ContentClassificationService mockedContentClassificationService; - /** Mocked classification level manager */ - private @Mock ClassificationLevelManager mockedClassificationLevelManager; - /** Mocked classification reason manager */ - private @Mock ClassificationReasonManager mockedClassificationReasonManager; - - /** Captor for the classification aspect properties. */ - private @Captor ArgumentCaptor propertiesDTOCaptor; - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript() - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScriptTemplate() - */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - @Test - public void testClassifyContent() throws Exception - { - // Setup web script parameters - Map parameters = buildClassifyRecordParams(); - - // Build JSON to send to server - String content = buildContent().toString(); - - // Execute web script - JSONObject json = executeJSONWebScript(parameters, content); - assertNotNull(json); - assertTrue(json.has(SUCCESS)); - assertEquals(getStringValueFromJSONObject(json, SUCCESS), Boolean.TRUE.toString()); - - // Verify that the classify content method was called - verify(mockedContentClassificationService, times(1)).classifyContent(propertiesDTOCaptor.capture(), eq(record)); - - // Check the values in the DTO. - ClassificationAspectProperties propertiesDTO = propertiesDTOCaptor.getValue(); - assertEquals(LEVEL_ID, propertiesDTO.getClassificationLevelId()); - assertEquals(BY, propertiesDTO.getClassifiedBy()); - assertEquals(AGENCY, propertiesDTO.getClassificationAgency()); - assertEquals(Sets.newHashSet(REASON1_ID, REASON2_ID), propertiesDTO.getClassificationReasonIds()); - } - - @Test - public void classifyingWithBlankClassifiedByShouldReturn4xxResponse() throws Exception - { - // Setup web script parameters - Map parameters = buildClassifyRecordParams(); - - final String whitespace = " \t "; - - JSONObject jsonObj = buildContent(); - putValuetoJSONObject(jsonObj, CLASSIFIED_BY, whitespace); - String json = jsonObj.toString(); - - // Execute web script - boolean exceptionThrown = false; - try - { - executeJSONWebScript(parameters, json); - } - catch (WebScriptException expected) - { - exceptionThrown = true; - assertTrue("HTTP rsp should have been a 400 error. Was " + expected.getStatus(), - is4xxError(expected)); - } - - assertTrue("Expected exception was not thrown", exceptionThrown); - } - - /** - * Check that no error is thrown if both the "Reclassify" and "Last Reclassify" sets of fields are blank (as would - * be the case for the initial classification). Check that null is used for the last reclassification data. - */ - @Test - public void testClassifyContent_lastReclassifyNullForFirstClassification() throws Exception - { - Map parameters = buildClassifyRecordParams(); - - // Build JSON to send to server with no previous classification data. - JSONObject jsonContent = buildContent(); - - // Execute web script - executeJSONWebScript(parameters, jsonContent.toString()); - - // Check the last classification event data. - verify(mockedContentClassificationService).classifyContent(propertiesDTOCaptor.capture(), eq(record)); - ClassificationAspectProperties propertiesDTO = propertiesDTOCaptor.getValue(); - assertNull("Expected last reclassfied by to be null.", propertiesDTO.getLastReclassifyBy()); - assertNull("Expected last reclassfied reason to be null.", propertiesDTO.getLastReclassifyReason()); - } - - /** - * Check that if the "Last Reclassify" fields are set (and the "Reclassify" fields aren't) then they are used for the - * last reclassification data. This simulates editing the classification data (without changing the level). - */ - @Test - public void testClassifyContent_lastReclassifyWhenEditingClassification() throws Exception - { - Map parameters = buildClassifyRecordParams(); - JSONObject jsonContent = buildContent(); - - // Set the last reclassification data (as would be set if changing anything other than the level). - putValuetoJSONObject(jsonContent, LAST_RECLASSIFY_BY, "user 1"); - putValuetoJSONObject(jsonContent, LAST_RECLASSIFY_REASON, "reason 1"); - - // Execute web script - executeJSONWebScript(parameters, jsonContent.toString()); - - // Check the "Last Reclassify" values are used. - verify(mockedContentClassificationService).classifyContent(propertiesDTOCaptor.capture(), eq(record)); - ClassificationAspectProperties propertiesDTO = propertiesDTOCaptor.getValue(); - assertEquals("user 1", propertiesDTO.getLastReclassifyBy()); - assertEquals("reason 1", propertiesDTO.getLastReclassifyReason()); - } - - /** - * Check that if the "Reclassify" fields are set then they are used for the last reclassification data, even if the - * "Last Reclassify" fields are set too. This simulates changing the classification level. - */ - @Test - public void testClassifyContent_lastReclassifyForReclassification() throws Exception - { - Map parameters = buildClassifyRecordParams(); - JSONObject jsonContent = buildContent(); - - // Set the reclassification data (as if we've classified once and are reclassifying). - putValuetoJSONObject(jsonContent, LAST_RECLASSIFY_BY, "user 1"); - putValuetoJSONObject(jsonContent, LAST_RECLASSIFY_REASON, "reason 1"); - putValuetoJSONObject(jsonContent, RECLASSIFY_BY, "user 2"); - putValuetoJSONObject(jsonContent, RECLASSIFY_REASON, "reason 2"); - - executeJSONWebScript(parameters, jsonContent.toString()); - - verify(mockedContentClassificationService).classifyContent(propertiesDTOCaptor.capture(), eq(record)); - ClassificationAspectProperties propertiesDTO = propertiesDTOCaptor.getValue(); - assertEquals("user 2", propertiesDTO.getLastReclassifyBy()); - assertEquals("reason 2", propertiesDTO.getLastReclassifyReason()); - } - - /** Build the parameters map that is used when classifying a record. */ - private Map buildClassifyRecordParams() - { - return buildParameters - ( - STORE_TYPE, record.getStoreRef().getProtocol(), - STORE_ID, record.getStoreRef().getIdentifier(), - ID, record.getId() - ); - } - - /** Helper method to build the request content. */ - private JSONObject buildContent() - { - JSONObject content = new JSONObject(); - putValuetoJSONObject(content, CLASSIFICATION_LEVEL_ID, LEVEL_ID); - putValuetoJSONObject(content, CLASSIFIED_BY, BY); - putValuetoJSONObject(content, CLASSIFICATION_AGENCY, AGENCY); - - JSONObject classificationReason1 = new JSONObject(); - putValuetoJSONObject(classificationReason1, ID, REASON1_ID); - JSONObject classificationReason2 = new JSONObject(); - putValuetoJSONObject(classificationReason2, ID, REASON2_ID); - - JSONArray classificationReasons = new JSONArray(); - classificationReasons.put(classificationReason1); - classificationReasons.put(classificationReason2); - putValuetoJSONObject(content, CLASSIFICATION_REASONS, classificationReasons); - - return content; - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClearanceLevelsGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClearanceLevelsGetUnitTest.java deleted file mode 100644 index b491a71ffe..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClearanceLevelsGetUnitTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -/** - * Tests for the get clearance levels API. - * - * @author David Webster - * @since 2.4.a - */ -public class ClearanceLevelsGetUnitTest extends BaseWebScriptUnitTest -{ - /** Classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/clearancelevels.get.json.ftl"; - - /** ClearanceLevelsGet webscript instance */ - private @Spy @InjectMocks ClearanceLevelsGet webScript; - private @Mock SecurityClearanceService mockSecurityClearanceService; - - private List clearanceLevels; - - /** {@inheritDoc} */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** {@inheritDoc} */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test the successful retrieval of two clearance levels. - */ - @Test - public void getClearanceLevels() throws Exception - { - // Create test data. - ClassificationLevel classificationLevelOne = new ClassificationLevel("id1", "classificationLabelKey1"); - ClassificationLevel classificationLevelTwo = new ClassificationLevel("id2", "classificationLabelKey2"); - clearanceLevels = Arrays.asList( - new ClearanceLevel(classificationLevelOne, "labelKey1"), - new ClearanceLevel(classificationLevelTwo, "labelKey2")); - - // setup interactions - doReturn(clearanceLevels).when(mockSecurityClearanceService).getClearanceLevels(); - - // execute web script - JSONObject json = executeJSONWebScript(new HashMap()); - assertNotNull(json); - String actualJSONString = json.toString(); - - // check the JSON result using Jackson to allow easy equality testing. - ObjectMapper mapper = new ObjectMapper(); - String expectedJSONString = "{\"data\":{\"items\":[{\"displayLabel\":\"labelKey1\",\"id\":\"id1\"},{\"displayLabel\":\"labelKey2\",\"id\":\"id2\"}]}}"; - JsonNode expected = mapper.readTree(expectedJSONString); - assertEquals(expected, mapper.readTree(actualJSONString)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ExemptionCategoriesGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ExemptionCategoriesGetUnitTest.java deleted file mode 100644 index 522bf7f967..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ExemptionCategoriesGetUnitTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static java.util.Arrays.asList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -/** - * Tests for the get exemption categories API. - * - * @author tpage - */ -public class ExemptionCategoriesGetUnitTest extends BaseWebScriptUnitTest -{ - /** Classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/exemptioncategories.get.json.ftl"; - - /** Webscript instance */ - private @Spy @InjectMocks ExemptionCategoriesGet webScript; - private @Mock ClassificationSchemeService mockClassificationSchemeService; - - /** {@inheritDoc} */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** {@inheritDoc} */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test the successful retrieval of two exemption categories. - */ - @Test - public void getExemptionCategories() throws Exception - { - // Create test data. - ExemptionCategory exemptionCategoryA = new ExemptionCategory("idA", "labelA"); - ExemptionCategory exemptionCategoryB = new ExemptionCategory("idB", "labelB"); - List exemptionCategories = asList(exemptionCategoryA, exemptionCategoryB); - - // setup interactions - doReturn(exemptionCategories).when(mockClassificationSchemeService).getExemptionCategories(); - - // setup web script parameters - Map parameters = new HashMap<>(); - - // execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - String actualJSONString = json.toString(); - - // check the JSON result using Jackson to allow easy equality testing. - ObjectMapper mapper = new ObjectMapper(); - String expectedJSONString = "{\"data\":{" + - "\"items\":[" + - "{\"displayLabel\":\"labelA\"," + "\"id\":\"idA\"," + "\"fullCategory\":\"idA: labelA\"}," + - "{\"displayLabel\":\"labelB\",\"id\":\"idB\",\"fullCategory\":\"idB: labelB\"}" + - "]" + - "}}"; - JsonNode expected = mapper.readTree(expectedJSONString); - assertEquals(expected, mapper.readTree(actualJSONString)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGetUnitTest.java deleted file mode 100644 index 39f02f934d..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGetUnitTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReason; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Tests for the get classification reasons API. - * - * @author tpage - */ -public class ReasonsGetUnitTest extends BaseWebScriptUnitTest -{ - /** Classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/reasons.get.json.ftl"; - - /** ReasonsGet webscript instance */ - private @Spy @InjectMocks ReasonsGet webScript; - private @Mock ClassificationSchemeService mockClassificationSchemeService; - - private List reasonsList; - - /** {@inheritDoc} */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webScript; - } - - /** {@inheritDoc} */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test the successful retrieval of two classification reasons. - */ - @Test - public void getReasons() throws Exception - { - // Create test data. - ClassificationReason reasonA = new ClassificationReason("idA", "labelA"); - ClassificationReason reasonB = new ClassificationReason("idB", "labelB"); - reasonsList = Arrays.asList(reasonA, reasonB); - - // setup interactions - doReturn(reasonsList).when(mockClassificationSchemeService).getClassificationReasons(); - - // setup web script parameters - Map parameters = new HashMap(); - - // execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - String actualJSONString = json.toString(); - - // check the JSON result using Jackson to allow easy equality testing. - ObjectMapper mapper = new ObjectMapper(); - String expectedJSONString = "{\"data\":{\"items\":[{\"displayLabel\":\"labelA\",\"id\":\"idA\",\"fullReason\":\"idA: labelA\"},{\"displayLabel\":\"labelB\",\"id\":\"idB\",\"fullReason\":\"idB: labelB\"}]}}"; - JsonNode expected = mapper.readTree(expectedJSONString); - assertEquals(expected, mapper.readTree(actualJSONString)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearanceGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearanceGetUnitTest.java deleted file mode 100644 index 1e3fb5706a..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearanceGetUnitTest.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.classification.UserQueryParams; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.jscript.ScriptNode; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PersonService.PersonInfo; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.WebScriptRequest; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Test for get user security clearance API - * - * @author Tuna Aksoy - * @since 2.4.a - */ -public class UserSecurityClearanceGetUnitTest extends BaseWebScriptUnitTest -{ - /** Classpath location of ftl template for web script */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/usersecurityclearance.get.json.ftl"; - - /** User security clearance webscript instance*/ - private @Spy @InjectMocks UserSecurityClearanceGet webscript; - - /** Mocked security clearance service */ - private @Mock SecurityClearanceService mockedSecurityClearanceService; - - /** {@inheritDoc} */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webscript; - } - - /** {@inheritDoc} */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test to get all security clearances (no filtering) - * @throws Exception - */ - @Test - public void getUserSecurityClearances() throws Exception - { - String userName = "aUserName0"; - String firstName = "aFirstName0"; - String lastName = "aLastName0"; - String classificationLevelId = "id0"; - String classificationLevelDisplayLabel = "displayLabel0"; - - doReturn(new PagingResults() - { - @Override - public List getPage() - { - return createSecurityClearances(1); - } - - @Override - public String getQueryExecutionId() - { - return anyString(); - } - - @Override - public Pair getTotalResultCount() - { - return new Pair(1, 1); - } - - @Override - public boolean hasMoreItems() - { - return false; - } - }).when(mockedSecurityClearanceService).getUsersSecurityClearance(any(UserQueryParams.class)); - - JSONObject response = executeJSONWebScript(buildParameters("nameFilter", "userName")); - assertNotNull(response); - - JSONObject data = response.getJSONObject("data"); - assertNotNull(data); - - assertEquals(1, data.getInt("total")); - assertEquals(0, data.getInt("startIndex")); - assertEquals(10, data.getInt("pageSize")); - assertEquals(1, data.getInt("itemCount")); - - JSONArray items = data.getJSONArray("items"); - assertNotNull(items); - assertEquals(1, items.length()); - - JSONObject securityClearance = items.getJSONObject(0); - assertNotNull(securityClearance); - assertEquals(userName, securityClearance.getString("userName")); - assertEquals(firstName, securityClearance.getString("firstName")); - assertEquals(lastName, securityClearance.getString("lastName")); - assertEquals(classificationLevelId, securityClearance.getString("classificationId")); - assertEquals(classificationLevelDisplayLabel, securityClearance.getString("clearanceLabel")); - String fullName = firstName + " " + lastName; - assertEquals(fullName, securityClearance.getString("fullName")); - assertEquals(fullName + " (" + userName + ")", securityClearance.getString("completeName")); - } - - /** - * Test to get all security clearances (with paging) - * @throws Exception - */ - @Test - public void getUserSecurityClearancesWithPaging() throws Exception - { - int startIndex = 0; - int pageSize = 5; - int numberOfUsers = 25; - int fromIndex = startIndex * pageSize; - int toIndex = fromIndex + pageSize > numberOfUsers ? numberOfUsers : fromIndex + pageSize; - List securityClearances = createSecurityClearances(numberOfUsers); - List items = securityClearances.subList(fromIndex, toIndex); - - doReturn(new PagingResults() - { - @Override - public List getPage() - { - return items; - } - - @Override - public String getQueryExecutionId() - { - return anyString(); - } - - @Override - public Pair getTotalResultCount() - { - return new Pair<>(numberOfUsers, numberOfUsers); - } - - @Override - public boolean hasMoreItems() - { - return true; - } - }).when(mockedSecurityClearanceService).getUsersSecurityClearance(any(UserQueryParams.class)); - - JSONObject response = executeJSONWebScript(buildParameters("nameFilter", "userName", "pageSize", Integer.toString(pageSize), "startIndex", Integer.toString(startIndex))); - assertNotNull(response); - - ObjectMapper mapper = new ObjectMapper(); - JsonNode expected = mapper.readTree(getExpectedResult(numberOfUsers, startIndex, pageSize, fromIndex, toIndex - 1, items.size())); - assertEquals(expected, mapper.readTree(response.toString())); - } - - @Override protected Map getMockedPeople() - { - final Map people = super.getMockedPeople(); - - return people; - } - - - /** - * Check that when supplying a single field with no sort direction, the UserQueryParams are populated with the - * specified field and the default direction (true). - */ - @Test - public void testSetSortProps_singleField() - { - UserQueryParams userQueryParams = mock(UserQueryParams.class); - WebScriptRequest req = mock(WebScriptRequest.class); - when(req.getParameter("sortField")).thenReturn("field"); - when(mockedNamespaceService.getNamespaceURI("")).thenReturn("namespace"); - - // Call the method under test. - webscript.setSortProps(userQueryParams, req); - - // Check the userQueryParams contains the field (and the direction has defaulted to ascending (TRUE)). - Pair sortPair = new Pair<>(QName.createQName("field", mockedNamespaceService), Boolean.TRUE); - List> expectedSortProps = Arrays.asList(sortPair); - verify(userQueryParams).withSortProps(expectedSortProps); - } - - /** - * Check that when supplying three fields with different sort directions (ascending, descending, unspecified), the - * UserQueryParams gets populated correctly. - */ - @Test - public void testSetSortProps_multipleFieldsAndDirections() - { - UserQueryParams userQueryParams = mock(UserQueryParams.class); - WebScriptRequest req = mock(WebScriptRequest.class); - when(req.getParameter("sortField")).thenReturn("fieldA,fieldB,fieldC"); - // The sort order for the fields is ascending, descending, unspecified (which should default to ascending). - when(req.getParameter("sortAscending")).thenReturn("true,false"); - when(mockedNamespaceService.getNamespaceURI("")).thenReturn("namespace"); - - // Call the method under test. - webscript.setSortProps(userQueryParams, req); - - Pair sortPairA = new Pair<>(QName.createQName("fieldA", mockedNamespaceService), Boolean.TRUE); - Pair sortPairB = new Pair<>(QName.createQName("fieldB", mockedNamespaceService), Boolean.FALSE); - Pair sortPairC = new Pair<>(QName.createQName("fieldC", mockedNamespaceService), Boolean.TRUE); - List> expectedSortProps = Arrays.asList(sortPairA, sortPairB, sortPairC); - verify(userQueryParams).withSortProps(expectedSortProps); - } - - /** Check that if no sort information is given there are no exceptions. */ - @Test - public void testSetSortProps_noFields() - { - UserQueryParams userQueryParams = mock(UserQueryParams.class); - WebScriptRequest req = mock(WebScriptRequest.class); - when(req.getParameter("sortField")).thenReturn(null); - when(mockedNamespaceService.getNamespaceURI("")).thenReturn("namespace"); - - // Call the method under test. - webscript.setSortProps(userQueryParams, req); - - verifyNoMoreInteractions(userQueryParams); - } - - private String getExpectedResult(int total, int startIndex, int pageSize, int fromIndex, int toIndex, int itemCount) - { - return "{" + - "\"data\": {" + - "\"total\": " + total + "," + - "\"startIndex\": " + startIndex + "," + - "\"pageSize\": " + pageSize + "," + - "\"items\": [" + - getItems(fromIndex, toIndex) + - "]," + - "\"itemCount\": " + itemCount + - "}" + - "}"; - } - - private String getItems(int fromIndex, int toIndex) - { - String items = ""; - for (; fromIndex <= toIndex; fromIndex++) - { - items += "{" + - "\"firstName\": \"aFirstName" + fromIndex + "\"," + - "\"lastName\": \"aLastName" + fromIndex + "\"," + - "\"clearanceLabel\": \"displayLabel" + fromIndex + "\"," + - "\"isEditable\": true," + - "\"completeName\": \"aFirstName" + fromIndex + " aLastName" + fromIndex + " (aUserName" + fromIndex + ")\"," + - "\"fullName\": \"aFirstName" + fromIndex + " aLastName" + fromIndex + "\"," + - "\"userName\": \"aUserName" + fromIndex + "\"," + - "\"classificationId\": \"id" + fromIndex + "\"" + - "}"; - if (fromIndex <= toIndex - 1) - { - items += ","; - } - } - return items; - } - - private List createSecurityClearances(int number) - { - List securityClearances = new ArrayList<>(); - for (int i = 0; i < number; i++) - { - PersonInfo personInfo = new PersonInfo(new NodeRef("a://noderef/" + i), "aUserName" + i, "aFirstName" + i, "aLastName" + i); - ClassificationLevel classificationLevel = new ClassificationLevel("id" + i, "displayLabel" + i); - ClearanceLevel clearanceLevel = new ClearanceLevel(classificationLevel, "displayLabel" + i); - SecurityClearance securityClearance = new SecurityClearance(personInfo, clearanceLevel); - securityClearances.add(securityClearance); - } - return securityClearances; - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearancePutUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearancePutUnitTest.java deleted file mode 100644 index 3f6b52eb93..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/UserSecurityClearancePutUnitTest.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.alfresco.module.org_alfresco_module_rm.script.classification; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.when; - -import java.util.Map; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException; -import org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance; -import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest; -import org.alfresco.service.cmr.security.PersonService; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; - -public class UserSecurityClearancePutUnitTest extends BaseWebScriptUnitTest -{ - /** - * Classpath location of ftl template for web script - */ - private static final String WEBSCRIPT_TEMPLATE = WEBSCRIPT_ROOT_RM + "classification/usersecurityclearance.put.json.ftl"; - private static final String USERNAME = "username"; - private static final String CLEARANCE_ID = "clearanceId"; - - /** - * User security clearance webscript instance - */ - private @Spy @InjectMocks - UserSecurityClearancePut webscript; - - /** - * Mock Security Clearance Service - */ - private @Mock - SecurityClearanceService mockSecurityClearanceService; - - /** - * {@inheritDoc} - */ - @Override - protected DeclarativeWebScript getWebScript() - { - return webscript; - } - - /** - * {@inheritDoc} - */ - @Override - protected String getWebScriptTemplate() - { - return WEBSCRIPT_TEMPLATE; - } - - /** - * Test the Security Clearance webscript - * - * @throws Exception - */ - @Test - public void testExecuteImpl() throws Exception - { - String username = "user1"; - String clearanceId = "Top Secret"; - String clearanceDisplay = "Don't tell anyone"; - String firstName = "Firstname"; - String lastName = "Lastname"; - PersonService.PersonInfo personInfo = new PersonService.PersonInfo(generateNodeRef(), username, firstName, lastName); - ClassificationLevel classificationLevel = new ClassificationLevel(clearanceId, clearanceDisplay); - ClearanceLevel clearanceLevel = new ClearanceLevel(classificationLevel, clearanceDisplay); - - SecurityClearance securityClearance = new SecurityClearance(personInfo, clearanceLevel); - - // Setup web script parameters - Map parameters = buildParameters(USERNAME, username, CLEARANCE_ID, clearanceId); - - when(mockSecurityClearanceService.setUserSecurityClearance(username, clearanceId)).thenReturn(securityClearance); - - // Execute web script - JSONObject json = executeJSONWebScript(parameters); - assertNotNull(json); - - // check the JSON result using Jackson to allow easy equality testing. - ObjectMapper mapper = new ObjectMapper(); - String expectedJSONString = "{\"data\":{\"firstName\":\"Firstname\",\"lastName\":\"Lastname\"," + - "\"clearanceLabel\":\"Don't tell anyone\"," + - "\"isEditable\":true," + - "\"userName\":\"user1\"," + - "\"completeName\":\"Firstname Lastname (user1)\",\"fullName\":\"Firstname Lastname\"," + - "\"classificationId\":\"Top Secret\"}}"; - JsonNode expected = mapper.readTree(expectedJSONString); - assertEquals(expected, mapper.readTree(json.toString())); - } - - /** - * Test the Security Clearance webscript can't be called by a user with insufficient clearance - * - * @throws Exception - */ - @Test (expected = WebScriptException.class) - public void testNonClearedUser() throws Exception - { - String username = "user1"; - String clearanceId = "Top Secret"; - - // Setup web script parameters - Map parameters = buildParameters(USERNAME, username, CLEARANCE_ID, clearanceId); - - when(mockSecurityClearanceService.setUserSecurityClearance(username, clearanceId)) - .thenThrow(new ClassificationException.LevelIdNotFound(clearanceId)); - - // Execute web script - this should throw the expected exception. - executeJSONWebScript(parameters); - } - - /** - * Test the Security Clearance WebScript throws an appropriate error if the clearanceId isn't known. - * - * @throws Exception - */ - @Test - public void testIncorrectClearanceId() throws Exception - { - String username = "user1"; - String clearanceId = "ThisClearanceDoesNotExist"; - - // Setup web script parameters - Map parameters = buildParameters(USERNAME, username, CLEARANCE_ID, clearanceId); - - when(mockSecurityClearanceService.setUserSecurityClearance(username, clearanceId)).thenThrow( - new ClassificationException.LevelIdNotFound(clearanceId)); - - try - { - // This should throw an exception because the clearanceId doesn't exist - executeJSONWebScript(parameters); - - fail("WebScript didn't throw an error when this missing clearance ID was passed in: " + clearanceId); - } - catch (WebScriptException e) - { - assertEquals(e.getStatus(), Status.STATUS_BAD_REQUEST); - } - } -} \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/CoreServicesExtrasUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/CoreServicesExtrasUnitTest.java deleted file mode 100644 index eeca3efa73..0000000000 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/CoreServicesExtrasUnitTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ - -package org.alfresco.module.org_alfresco_module_rm.util; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.mock; - -import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; -import static org.junit.Assert.assertEquals; - -import static java.util.Arrays.asList; - -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryException; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Unit tests for {@link CoreServicesExtras}. - * - * @author Neil Mc Erlean - * @since 2.4.a - */ -public class CoreServicesExtrasUnitTest -{ - private CoreServicesExtras serviceExtras; - - private final QName testAspect = QName.createQName("test", "aspect"); - private final QName testProp1 = QName.createQName("test", "prop1"); - private final QName testProp2 = QName.createQName("test", "prop2"); - private final QName testProp3 = QName.createQName("test", "prop3"); - private final NodeRef testNode1 = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "1"); - private final NodeRef testNode2 = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "2"); - - @Before public void setUp() - { - serviceExtras = new CoreServicesExtras(); - } - - @Test public void copyingAnUnknownAspectShouldResultInAnException() - { - final DictionaryService mockDS = mock(DictionaryService.class); - - when(mockDS.getAspect(any(QName.class))).thenReturn(null); - serviceExtras.setDictionaryService(mockDS); - - expectedException(DictionaryException.class, () -> serviceExtras.copyAspect(testNode1, testNode2, testAspect)); - } - - @Test public void copyingAnAspectWithNoProperties() - { - final DictionaryService mockDS = mock(DictionaryService.class); - final NodeService mockNS = mock(NodeService.class); - - final AspectDefinition mockAspect = mock(AspectDefinition.class); - when(mockAspect.getProperties()).thenReturn(Collections.emptyMap()); - - when(mockDS.getAspect(eq(testAspect))).thenReturn(mockAspect); - when(mockNS.getProperties(eq(testNode1))).thenReturn(Collections.emptyMap()); - serviceExtras.setDictionaryService(mockDS); - serviceExtras.setNodeService(mockNS); - - assertEquals(Collections.emptyMap(), serviceExtras.copyAspect(testNode1, testNode2, testAspect)); - } - - @Test public void copyingAnAspectWithProperties() - { - final DictionaryService mockDS = mock(DictionaryService.class); - final NodeService mockNS = mock(NodeService.class); - - final AspectDefinition mockAspect = mock(AspectDefinition.class); - when(mockAspect.getName()).thenReturn(testAspect); - - final Map props = new HashMap<>(); - final PropertyDefinition mockProp1 = mock(PropertyDefinition.class); - final PropertyDefinition mockProp2 = mock(PropertyDefinition.class); - for (PropertyDefinition p : asList(mockProp1, mockProp2)) - { - when(p.getContainerClass()).thenReturn(mockAspect); - } - props.put(testProp1, mockProp1); - props.put(testProp2, mockProp2); - when(mockAspect.getProperties()).thenReturn(props); - - final Map propVals = new HashMap<>(); - propVals.put(testProp1, "one"); - propVals.put(testProp2, "two"); - propVals.put(testProp3, "three"); // Not defined on the aspect above. - when(mockDS.getAspect(eq(testAspect))).thenReturn(mockAspect); - when(mockNS.getProperties(eq(testNode1))).thenReturn(propVals); - - serviceExtras.setDictionaryService(mockDS); - serviceExtras.setNodeService(mockNS); - - Map expected = new HashMap<>(); - expected.put(testProp1, "one"); - expected.put(testProp2, "two"); - assertEquals(expected, serviceExtras.copyAspect(testNode1, testNode2, testAspect)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/repo/jscript/app/ClassificationReasonsPropertyDecoratorUnitTest.java b/rm-server/unit-test/java/org/alfresco/repo/jscript/app/ClassificationReasonsPropertyDecoratorUnitTest.java deleted file mode 100644 index 6cb30aace7..0000000000 --- a/rm-server/unit-test/java/org/alfresco/repo/jscript/app/ClassificationReasonsPropertyDecoratorUnitTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.repo.jscript.app; - -import static org.alfresco.repo.jscript.app.ClassificationReasonsPropertyDecorator.DISPLAY_LABEL; -import static org.alfresco.repo.jscript.app.ClassificationReasonsPropertyDecorator.FULL_REASON; -import static org.alfresco.repo.jscript.app.ClassificationReasonsPropertyDecorator.ID; -import static org.alfresco.repo.jscript.app.ClassificationReasonsPropertyDecorator.LABEL; -import static org.alfresco.repo.jscript.app.ClassificationReasonsPropertyDecorator.VALUE; -import static org.alfresco.util.GUID.generate; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationReason; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; - -/** - * Classification reasons property decorator unit test - * - * @author Tuna Aksoy - * @since 2.4.a - */ -@RunWith(MockitoJUnitRunner.class) -public class ClassificationReasonsPropertyDecoratorUnitTest -{ - /** Classification reasons property decorator */ - private @InjectMocks ClassificationReasonsPropertyDecorator decorator = new ClassificationReasonsPropertyDecorator(); - - /** Mocked classification scheme service */ - private @Mock ClassificationSchemeService mockedClassificationSchemeService; - - /** - * Given that no classification reason id is supplied - * When decorated - * Then an {@link IllegalArgumentException} is thrown - */ - @Test(expected = IllegalArgumentException.class) - public void testDecoratorWithoutClassificationId() - { - decorator.decorate(null, null, null); - } - - /** - * Given that a classification reason id in an invalid format is supplied - * When decorated - * Then an {@link JsonSyntaxException} is thrown - */ - @Test(expected = JsonSyntaxException.class) - public void testDecoratorWithInvalidClassificationReasonId() - { - String classificationReasonId = generate(); - String classificationReasonDisplayLabel = generate(); - - ClassificationReason classificationReason = new ClassificationReason(classificationReasonId, classificationReasonDisplayLabel); - doReturn(classificationReason).when(mockedClassificationSchemeService).getClassificationReasonById(classificationReasonId); - - decorator.decorate(null, null, classificationReasonId); - } - - /** - * Given that a classification reason id is supplied - * When decorated - * Then the result is a {@link JSONArray} containing the classification reason id, label, value, display label and full reason - */ - @SuppressWarnings("unchecked") - @Test - public void testDecoratorWithClassificationReasonId() - { - String classificationReasonId = generate(); - String classificationReasonDisplayLabel = generate(); - String classificationFullReason = classificationReasonId + ": " + classificationReasonDisplayLabel; - - ClassificationReason classificationReason = new ClassificationReason(classificationReasonId, classificationReasonDisplayLabel); - doReturn(classificationReason).when(mockedClassificationSchemeService).getClassificationReasonById(classificationReasonId); - - JSONArray classificationReasonIds = new JSONArray(); - classificationReasonIds.add(classificationReasonId); - - JSONArray decoratedProperty = (JSONArray) decorator.decorate(null, null, new Gson().toJson(classificationReasonIds)); - assertNotNull(decoratedProperty); - assertEquals(1, decoratedProperty.size()); - - JSONObject jsonObject = (JSONObject) decoratedProperty.get(0); - assertNotNull(jsonObject); - - assertEquals(classificationReasonId, jsonObject.get(ID)); - assertEquals(classificationFullReason, jsonObject.get(LABEL)); - assertEquals(classificationReasonId, jsonObject.get(VALUE)); - assertEquals(classificationReasonDisplayLabel, jsonObject.get(DISPLAY_LABEL)); - assertEquals(classificationFullReason, jsonObject.get(FULL_REASON)); - } - - /** - * Given that two classification reason id are supplied - * When decorated - * Then the result is a {@link JSONArray} containing the classification reason ids, - * labels, values, display labels and full reasons of both classification reasons - */ - @SuppressWarnings("unchecked") - @Test - public void testDecorateWithMultipleClassificationReasonIds() - { - String classificationReasonId1 = generate(); - String classificationReasonDisplayLabel1 = generate(); - String classificationFullReason1 = classificationReasonId1 + ": " + classificationReasonDisplayLabel1; - - String classificationReasonId2 = generate(); - String classificationReasonDisplayLabel2 = generate(); - String classificationFullReason2 = classificationReasonId2 + ": " + classificationReasonDisplayLabel2; - - ClassificationReason classificationReason1 = new ClassificationReason(classificationReasonId1, classificationReasonDisplayLabel1); - ClassificationReason classificationReason2 = new ClassificationReason(classificationReasonId2, classificationReasonDisplayLabel2); - doReturn(classificationReason1).when(mockedClassificationSchemeService).getClassificationReasonById(classificationReasonId1); - doReturn(classificationReason2).when(mockedClassificationSchemeService).getClassificationReasonById(classificationReasonId2); - - JSONArray classificationReasonIds = new JSONArray(); - classificationReasonIds.add(classificationReasonId1); - classificationReasonIds.add(classificationReasonId2); - - JSONArray decoratedProperty = (JSONArray) decorator.decorate(null, null, new Gson().toJson(classificationReasonIds)); - assertNotNull(decoratedProperty); - assertEquals(2, decoratedProperty.size()); - - JSONObject jsonObject1 = (JSONObject) decoratedProperty.get(0); - assertNotNull(jsonObject1); - - assertEquals(classificationReasonId1, jsonObject1.get(ID)); - assertEquals(classificationFullReason1, jsonObject1.get(LABEL)); - assertEquals(classificationReasonId1, jsonObject1.get(VALUE)); - assertEquals(classificationReasonDisplayLabel1, jsonObject1.get(DISPLAY_LABEL)); - assertEquals(classificationFullReason1, jsonObject1.get(FULL_REASON)); - - JSONObject jsonObject2 = (JSONObject) decoratedProperty.get(1); - assertNotNull(jsonObject2); - - assertEquals(classificationReasonId2, jsonObject2.get(ID)); - assertEquals(classificationFullReason2, jsonObject2.get(LABEL)); - assertEquals(classificationReasonId2, jsonObject2.get(VALUE)); - assertEquals(classificationReasonDisplayLabel2, jsonObject2.get(DISPLAY_LABEL)); - assertEquals(classificationFullReason2, jsonObject2.get(FULL_REASON)); - } -} \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/repo/jscript/app/CurrentClassificationPropertyDecoratorUnitTest.java b/rm-server/unit-test/java/org/alfresco/repo/jscript/app/CurrentClassificationPropertyDecoratorUnitTest.java deleted file mode 100644 index 51afa9c061..0000000000 --- a/rm-server/unit-test/java/org/alfresco/repo/jscript/app/CurrentClassificationPropertyDecoratorUnitTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.repo.jscript.app; - -import static org.alfresco.repo.jscript.app.CurrentClassificationPropertyDecorator.ID; -import static org.alfresco.repo.jscript.app.CurrentClassificationPropertyDecorator.LABEL; -import static org.alfresco.util.GUID.generate; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel; -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.json.simple.JSONObject; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -/** - * Current classification property decorator unit test - * - * @author Tuna Aksoy - * @since 2.4.a - */ -@RunWith(MockitoJUnitRunner.class) -public class CurrentClassificationPropertyDecoratorUnitTest -{ - /** Current classification property decorator */ - private @InjectMocks CurrentClassificationPropertyDecorator decorator = new CurrentClassificationPropertyDecorator(); - - /** Mocked classification scheme service */ - private @Mock ClassificationSchemeService mockedClassificationSchemeService; - - /** - * Given that no classification id is supplied - * When decorated - * Then an {@link IllegalArgumentException} is thrown - */ - @Test(expected = IllegalArgumentException.class) - public void testDecoratorWithoutClassificationId() - { - decorator.decorate(null, null, null); - } - - /** - * Given that a classification id is supplied - * When decorated - * Then the result is a {@link JSONObject} containing the classification id and display label - */ - @Test - public void testDecoratorWithClassificationId() - { - String classificationLevelId = generate(); - String classificationDisplayLabel = generate(); - ClassificationLevel classificationLevel = new ClassificationLevel(classificationLevelId, classificationDisplayLabel); - doReturn(classificationLevel).when(mockedClassificationSchemeService).getClassificationLevelById(classificationLevelId); - - JSONObject decoratedProperty = (JSONObject) decorator.decorate(null, null, classificationLevelId); - assertNotNull(decoratedProperty); - assertEquals(classificationLevelId, decoratedProperty.get(ID)); - assertEquals(classificationDisplayLabel, decoratedProperty.get(LABEL)); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/repo/jscript/app/ExemptionCategoriesPropertyDecoratorUnitTest.java b/rm-server/unit-test/java/org/alfresco/repo/jscript/app/ExemptionCategoriesPropertyDecoratorUnitTest.java deleted file mode 100644 index fc375fd1f8..0000000000 --- a/rm-server/unit-test/java/org/alfresco/repo/jscript/app/ExemptionCategoriesPropertyDecoratorUnitTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2005-2015 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 . - */ -package org.alfresco.repo.jscript.app; - -import static org.alfresco.repo.jscript.app.ExemptionsCategoriesPropertyDecorator.DISPLAY_LABEL; -import static org.alfresco.repo.jscript.app.ExemptionsCategoriesPropertyDecorator.FULL_CATEGORY; -import static org.alfresco.repo.jscript.app.ExemptionsCategoriesPropertyDecorator.ID; -import static org.alfresco.repo.jscript.app.ExemptionsCategoriesPropertyDecorator.LABEL; -import static org.alfresco.repo.jscript.app.ExemptionsCategoriesPropertyDecorator.VALUE; -import static org.alfresco.util.GUID.generate; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; - -import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService; -import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; - -/** - * Exemption categories property decorator unit test - * - * @author Tuna Aksoy - * @since 2.4.a - */ -@RunWith(MockitoJUnitRunner.class) -public class ExemptionCategoriesPropertyDecoratorUnitTest -{ - /** Exemption categories property decorator */ - private @InjectMocks ExemptionsCategoriesPropertyDecorator decorator = new ExemptionsCategoriesPropertyDecorator(); - - /** Mocked classification scheme service */ - private @Mock ClassificationSchemeService mockedClassificationSchemeService; - - /** - * Given that no exemption category id is supplied - * When decorated - * Then an {@link IllegalArgumentException} is thrown - */ - @Test(expected = IllegalArgumentException.class) - public void testDecoratorWithoutExemptionCategoryId() - { - decorator.decorate(null, null, null); - } - - /** - * Given that an exemption category id in an invalid format is supplied - * When decorated - * Then an {@link JsonSyntaxException} is thrown - */ - @Test(expected = JsonSyntaxException.class) - public void testDecoratorWithInvalidExemptionCategoryId() - { - String exemptionCategoryId = generate(); - String exemptionCategoryDisplayLabel = generate(); - - ExemptionCategory exemptionCategory = new ExemptionCategory(exemptionCategoryId, exemptionCategoryDisplayLabel); - doReturn(exemptionCategory).when(mockedClassificationSchemeService).getExemptionCategoryById(exemptionCategoryId); - - decorator.decorate(null, null, exemptionCategoryId); - } - - /** - * Given that an exemption category id is supplied - * When decorated - * Then the result is a {@link JSONArray} containing the exemption category id, label, value, display label and full category - */ - @SuppressWarnings("unchecked") - @Test - public void testDecoratorWithExemptionCategoryId() - { - String exemptionCategoryId = generate(); - String exemptionCategoryDisplayLabel = generate(); - String exemptionCategoryFullCategory = exemptionCategoryId + ": " + exemptionCategoryDisplayLabel; - - ExemptionCategory exemptionCategory = new ExemptionCategory(exemptionCategoryId, exemptionCategoryDisplayLabel); - doReturn(exemptionCategory).when(mockedClassificationSchemeService).getExemptionCategoryById(exemptionCategoryId); - - JSONArray exemptionCategoryIds = new JSONArray(); - exemptionCategoryIds.add(exemptionCategoryId); - - JSONArray decoratedProperty = (JSONArray) decorator.decorate(null, null, new Gson().toJson(exemptionCategoryIds)); - assertNotNull(decoratedProperty); - assertEquals(1, decoratedProperty.size()); - - JSONObject jsonObject = (JSONObject) decoratedProperty.get(0); - assertNotNull(jsonObject); - - assertEquals(exemptionCategoryId, jsonObject.get(ID)); - assertEquals(exemptionCategoryFullCategory, jsonObject.get(LABEL)); - assertEquals(exemptionCategoryId, jsonObject.get(VALUE)); - assertEquals(exemptionCategoryDisplayLabel, jsonObject.get(DISPLAY_LABEL)); - assertEquals(exemptionCategoryFullCategory, jsonObject.get(FULL_CATEGORY)); - } - - /** - * Given that two exemption category ids are supplied - * When decorated - * Then the result is a {@link JSONArray} containing the exemption category ids, - * labels, values, display labels and full category of both exemption categories - */ - @SuppressWarnings("unchecked") - @Test - public void testDecorateWithMultipleExemptionCategoryIds() - { - String exemptionCategoryId1 = generate(); - String exemptionCategoryDisplayLabel1 = generate(); - String exemptionCategoryIdFullCategory1 = exemptionCategoryId1 + ": " + exemptionCategoryDisplayLabel1; - - String exemptionCategoryId2 = generate(); - String exemptionCategoryDisplayLabel2 = generate(); - String exemptionCategoryFullCategory2 = exemptionCategoryId2 + ": " + exemptionCategoryDisplayLabel2; - - ExemptionCategory exemptionCategory1 = new ExemptionCategory(exemptionCategoryId1, exemptionCategoryDisplayLabel1); - ExemptionCategory exemptionCategory2 = new ExemptionCategory(exemptionCategoryId2, exemptionCategoryDisplayLabel2); - doReturn(exemptionCategory1).when(mockedClassificationSchemeService).getExemptionCategoryById(exemptionCategoryId1); - doReturn(exemptionCategory2).when(mockedClassificationSchemeService).getExemptionCategoryById(exemptionCategoryId2); - - JSONArray exemptionCategoryIds = new JSONArray(); - exemptionCategoryIds.add(exemptionCategoryId1); - exemptionCategoryIds.add(exemptionCategoryId2); - - JSONArray decoratedProperty = (JSONArray) decorator.decorate(null, null, new Gson().toJson(exemptionCategoryIds)); - assertNotNull(decoratedProperty); - assertEquals(2, decoratedProperty.size()); - - JSONObject jsonObject1 = (JSONObject) decoratedProperty.get(0); - assertNotNull(jsonObject1); - - assertEquals(exemptionCategoryId1, jsonObject1.get(ID)); - assertEquals(exemptionCategoryIdFullCategory1, jsonObject1.get(LABEL)); - assertEquals(exemptionCategoryId1, jsonObject1.get(VALUE)); - assertEquals(exemptionCategoryDisplayLabel1, jsonObject1.get(DISPLAY_LABEL)); - assertEquals(exemptionCategoryIdFullCategory1, jsonObject1.get(FULL_CATEGORY)); - - JSONObject jsonObject2 = (JSONObject) decoratedProperty.get(1); - assertNotNull(jsonObject2); - - assertEquals(exemptionCategoryId2, jsonObject2.get(ID)); - assertEquals(exemptionCategoryFullCategory2, jsonObject2.get(LABEL)); - assertEquals(exemptionCategoryId2, jsonObject2.get(VALUE)); - assertEquals(exemptionCategoryDisplayLabel2, jsonObject2.get(DISPLAY_LABEL)); - assertEquals(exemptionCategoryFullCategory2, jsonObject2.get(FULL_CATEGORY)); - } -} \ No newline at end of file diff --git a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateGroupId.json b/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateGroupId.json deleted file mode 100644 index 1dbad1fee3..0000000000 --- a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateGroupId.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.group", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "model" : - { - "property" : "clf:classification" - }, - "marks" : - [ - { - "id" : "TS", - "displayLabel" : "rm.caveat.classification.mark.ts" - } - ] - }, - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.group", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "marks" : - [ - { - "id" : "XYZ", - "displayLabel" : "rm.caveat.classification.mark.ts" - } - ] - } -] \ No newline at end of file diff --git a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateMarkId.json b/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateMarkId.json deleted file mode 100644 index f0b7e86b32..0000000000 --- a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateMarkId.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.group", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "model" : - { - "property" : "clf:classification" - }, - "marks" : - [ - { - "id" : "TS", - "displayLabel" : "rm.caveat.classification.mark.ts" - }, - { - "id" : "TS", - "displayLabel" : "rm.caveat.classification.mark.s" - } - ] - } -] \ No newline at end of file diff --git a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateMarkIdInDifferentGroups.json b/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateMarkIdInDifferentGroups.json deleted file mode 100644 index 9a9849290a..0000000000 --- a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-duplicateMarkIdInDifferentGroups.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.group", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "model" : - { - "property" : "clf:classification" - }, - "marks" : - [ - { - "id" : "CO", - "displayLabel" : "rm.caveat.classification.mark.confidential" - } - ] - }, - { - "id" : "nationality", - "displayLabel" : "rm.caveat.nationality.group", - "description" : "rm.caveat.nationality.description", - "type" : "USER_REQUIRES_ANY", - "marks" : - [ - { - "id" : "CO", - "displayLabel" : "rm.caveat.nationality.mark.colombia" - } - ] - } -] \ No newline at end of file diff --git a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-malformedJSON.json b/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-malformedJSON.json deleted file mode 100644 index b8a2232143..0000000000 --- a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-malformedJSON.json +++ /dev/null @@ -1,48 +0,0 @@ -[ - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.group", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "model" : - { - "property" : "clf:classification" - }, - "marks" : - [[ - { - "id" : "TS", - "displayLabel" : "rm.caveat.classification.mark.ts" - }, - { - "id" : "S", - "displayLabel" : "rm.caveat.classification.mark.s" - }, - { - "id" : "C", - "displayLabel" : "rm.caveat.classification.mark.c" - } - ] - }, - { - "id" : "nationality", - "displayLabel" : "rm.caveat.nationality.group", - "description" : "rm.caveat.nationality.description", - "type" : "USER_REQUIRES_ANY", - "marks" : - [ - { - "id" : "GBR", - "displayLabel" : "rm.caveat.nationality.mark.gbr" - }, - { - "id" : "CAN", - "displayLabel" : "rm.caveat.nationality.mark.can" - }, - { - "id" : "AUS", - "displayLabel" : "rm.caveat.nationality.mark.aus" - } - ] - } -] \ No newline at end of file diff --git a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-missingMarkId.json b/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-missingMarkId.json deleted file mode 100644 index 84783ad7ed..0000000000 --- a/rm-server/unit-test/resources/alfresco/caveat/rm-caveats-missingMarkId.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "id" : "classification", - "displayLabel" : "rm.caveat.classification.group", - "description" : "rm.caveat.classification.description", - "type" : "HIERARCHICAL", - "model" : - { - "property" : "clf:classification" - }, - "marks" : - [ - { - "id" : "TS", - "displayLabel" : "rm.caveat.classification.mark.ts" - }, - { - "displayLabel" : "rm.caveat.classification.mark.s" - }, - { - "id" : "C", - "displayLabel" : "rm.caveat.classification.mark.c" - } - ] - } -] \ No newline at end of file diff --git a/rm-server/unit-test/resources/alfresco/classification/rm-classification-reasons-malformed.json b/rm-server/unit-test/resources/alfresco/classification/rm-classification-reasons-malformed.json deleted file mode 100644 index f8d84fecc2..0000000000 --- a/rm-server/unit-test/resources/alfresco/classification/rm-classification-reasons-malformed.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "id" : "1.4(a)", - "displayLabel" : "rm.classification-reason.14a" - }, { { -]