Skip to content

Commit

Permalink
ALFREDAPI-562: Fix service injection (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
WimCrols committed Dec 11, 2024
1 parent 3415b2b commit 421dfe7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ public class PeopleService implements IPeopleService {
private PersonService alfrescoPersonService;
private NodeService nodeService;
private AuthorityService authorityService;
private ServiceRegistry serviceRegistry;

@Autowired
public PeopleService(PersonService personService, AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion,
NodeService nodeService, ServiceRegistry serviceRegistry) {
this.alfrescoPersonService = personService;
this.nodeService = nodeService;
public PeopleService(ServiceRegistry serviceRegistry, AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion) {
this.c = alfredApiToAlfrescoConversion;
this.alfrescoPersonService = serviceRegistry.getPersonService();
this.nodeService = serviceRegistry.getNodeService();
this.authorityService = serviceRegistry.getAuthorityService();
this.serviceRegistry = serviceRegistry;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.alfresco.repo.dictionary.Facetable;
import org.alfresco.repo.dictionary.IndexTokenisationMode;
import org.alfresco.repo.i18n.MessageService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
Expand All @@ -34,11 +35,10 @@ public class PropertyServiceImpl implements IPropertyService {
protected AlfredApiToAlfrescoConversion c;

@Autowired
public PropertyServiceImpl(DictionaryService dictionaryService, AlfredApiToAlfrescoConversion c,
MessageService messageService) {
this.dictionaryService = dictionaryService;
public PropertyServiceImpl(ServiceRegistry serviceRegistry, AlfredApiToAlfrescoConversion c) {
this.c = c;
this.messageService = messageService;
dictionaryService = serviceRegistry.getDictionaryService();
messageService = serviceRegistry.getMessageService();
}

public PropertyIndexOptions GetPropertyIndexOptions(PropertyDefinition definition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,25 @@ public class TranslationService implements ITranslationService {

private static final Logger logger = LoggerFactory.getLogger(TranslationService.class);

@Autowired
private NamespaceService namespaceService;

@Autowired
private DictionaryService alfDictionaryService;

@Autowired
private MessageService messageService;

@Autowired
private IDictionaryService alfredApiDictionaryservice;

@Autowired
private AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion;

public TranslationService() {
}
@Autowired
public TranslationService(ServiceRegistry serviceRegistry,
AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion,
IDictionaryService dictionaryService) {
this.alfredApiToAlfrescoConversion = alfredApiToAlfrescoConversion;
this.alfredApiDictionaryservice = dictionaryService;

public TranslationService(ServiceRegistry serviceRegistry, AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion,
IDictionaryService dictionaryService, MessageService messageService) {
this.namespaceService = serviceRegistry.getNamespaceService();
this.alfDictionaryService = serviceRegistry.getDictionaryService();
this.alfredApiToAlfrescoConversion = alfredApiToAlfrescoConversion;
this.alfredApiDictionaryservice = dictionaryService;
this.messageService = messageService;
this.messageService = serviceRegistry.getMessageService();
}


@Override
public long getTranslationsCheckSum(Locale locale) {
try (ByteArrayOutputStream bytesOut = new ByteArrayOutputStream()) {
Expand Down Expand Up @@ -149,8 +140,6 @@ public Translations getTranslations(Locale locale) {
translations.setAssociation(toValueList(associations));

return translations;


}

@Override
Expand All @@ -176,7 +165,6 @@ private void addTranslationValue(ResourceBundleTranslationKey translationKey, Ma
.equals(ResourceBundleTranslationKey.FeatureValueType.DESCRIPTION)) {
translationValue.setDescription(translationKey.getValue());
}

}

private void addPropertyTranslationValue(ResourceBundleTranslationKey translationKey,
Expand Down Expand Up @@ -219,7 +207,6 @@ private TranslationValue getTranslationValueObject(QName qname, Map<QName, Trans
}

return translationValue;

}

private PropertyTranslationValue getPropertyTranslationValueObject(QName qname,
Expand All @@ -234,7 +221,6 @@ private PropertyTranslationValue getPropertyTranslationValueObject(QName qname,
}

return translationValue;

}

private List<TranslationValue> toValueList(Map<QName, TranslationValue> map) {
Expand All @@ -245,7 +231,6 @@ private List<PropertyTranslationValue> toPropertyValueList(Map<QName, PropertyTr
return new ArrayList<PropertyTranslationValue>(map.values());
}


private void addListConstraintsToProperties(MessageLookup messageLookup, Map<QName, PropertyTranslationValue> map) {
Collection<QName> properties = alfDictionaryService.getAllProperties(null);

Expand Down Expand Up @@ -308,9 +293,7 @@ private void addListConstraintsToProperties(MessageLookup messageLookup, Map<QNa
}

PropertyTranslationValue translationValue = getPropertyTranslationValueObject(property, map);

translationValue.setValues(constraintTranslations);

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.version.VersionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand All @@ -23,22 +23,20 @@ public class VersionHistoryService implements IVersionHistoryService {

private AlfredApiToAlfrescoConversion c;
private org.alfresco.service.cmr.version.VersionService alfrescoVersionHistoryService;
private NodeService nodeService;

@Autowired
public VersionHistoryService(org.alfresco.service.cmr.version.VersionService versionService,
AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion, NodeService nodeService) {
this.alfrescoVersionHistoryService = versionService;
this.nodeService = nodeService;
this.c = alfredApiToAlfrescoConversion;
public VersionHistoryService(ServiceRegistry serviceRegistry,
AlfredApiToAlfrescoConversion alfredApiToAlfrescoConversion) {
c = alfredApiToAlfrescoConversion;
alfrescoVersionHistoryService = serviceRegistry.getVersionService();
}

@Override
public VersionHistory GetVersionHistory(NodeRef nodeRef) {
org.alfresco.service.cmr.version.VersionHistory v = alfrescoVersionHistoryService
.getVersionHistory(c.alfresco(nodeRef));
if (v == null) //If no versionhistory, no versionhistory is returned.
{
// If no versionhistory, no versionhistory is returned.
if (v == null) {
return null;
}
Collection<org.alfresco.service.cmr.version.Version> versions = v.getAllVersions();
Expand All @@ -61,10 +59,8 @@ private Version VersionAlfrescoToAlfredApi(org.alfresco.service.cmr.version.Vers
Version.VersionType.MINOR :
Version.VersionType.UNKNOWN);

Version ret =
new Version(modifier, modified, versionLabel, description, vType,
c.alfredApi(version.getFrozenStateNodeRef()));
return ret;
return new Version(modifier, modified, versionLabel, description, vType,
c.alfredApi(version.getFrozenStateNodeRef()));
}

@Override
Expand Down Expand Up @@ -116,5 +112,3 @@ public void revert(NodeRef nodeRef, String versionLabel) {
alfrescoVersionHistoryService.revert(alfNode, alfVersion, false);
}
}


0 comments on commit 421dfe7

Please sign in to comment.